Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@stephentoub
Copy link
Member

Via the power of Roslyn and @jaredpar's handy https://github.com/jaredpar/UseNameOf (with a few tweaks), this deploys usage of C# 6's nameof throughout corefx when constructing exceptions, e.g. replacing throw new ArgumentOutOfRangeException("index", ...) with throw new ArgumentOutOfRangeException(nameof(index), ...). This helps to find problems when later refactoring, to remove hand-written strings from the codebase, and to help point out places where the wrong strings are being passed (e.g. a subsequent search for new ArgumentException(nameof(...) is likely to turn up places where the args are being passed in the wrong order, and a subsequent search for new ArgumentOutOfRangeException(" is likely to turn up places where the wrong parameter name is being used).

Separately, I fixed up our usage of MemberData and ConditionalFact/Theory to use nameof for the name of the target member rather than having it written as a string. In addition to helping with refactoring, this makes navigation in VS much easier, as you can now Go To Definition on these.

I've attributed the changes to dotnet-bot.

This will not pass until #6181 is merged and the LangVer constraint is removed.

cc: @weshaggard, @jaredpar, @ellismg

@jaredpar
Copy link
Member

nameof all the things!!!

👍

@weshaggard
Copy link
Member

👍

@stephentoub
Copy link
Member Author

@dotnet-bot test this please

@stephentoub
Copy link
Member Author

@saurabh500, do you want to review the data changes here?
@davidsh, networking?

(And generally let me know if you have concerns about these kinds of changes to those codebases.)

@davidsh
Copy link
Contributor

davidsh commented Feb 19, 2016

This is a great positive step to having a more maintainable codebase.
LGTM

@saurabh500
Copy link
Contributor

LGTM

@stephentoub
Copy link
Member Author

Thanks, all.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants