This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Deploy nameof throughout corefx #6209
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
👍 |
Mostly automated replacement of parameter name string literals with corresponding usage of nameof.
f4a2f17 to
0f9f72d
Compare
Member
|
👍 |
Member
Author
|
@dotnet-bot test this please |
Member
Author
|
@saurabh500, do you want to review the data changes here? (And generally let me know if you have concerns about these kinds of changes to those codebases.) |
Contributor
|
This is a great positive step to having a more maintainable codebase. |
Contributor
|
LGTM |
Member
Author
|
Thanks, all. |
stephentoub
added a commit
that referenced
this pull request
Feb 19, 2016
Deploy nameof throughout corefx
This was referenced Feb 20, 2016
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
Deploy nameof throughout corefx Commit migrated from dotnet/corefx@1bd332f
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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", ...)withthrow 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 fornew ArgumentException(nameof(...)is likely to turn up places where the args are being passed in the wrong order, and a subsequent search fornew 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