Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule S2302: 'nameof' should be used #1075

Closed
Evangelink opened this issue Jan 9, 2018 · 3 comments
Closed

Rule S2302: 'nameof' should be used #1075

Evangelink opened this issue Jan 9, 2018 · 3 comments
Assignees
Labels
Type: New Feature This hasn't been here before.
Milestone

Comments

@Evangelink
Copy link
Contributor

Evangelink commented Jan 9, 2018

RSPEC-2302

Because parameter names could be changed during refactoring, they should not be spelled out literally in strings. Instead, use nameof(), and the string that's output will always be correct.

@Evangelink Evangelink added Area: Rules Type: New Feature This hasn't been here before. labels Jan 9, 2018
@Evangelink Evangelink assigned Evangelink and unassigned Evangelink Jan 16, 2018
@Evangelink
Copy link
Contributor Author

Let's update the RSPEC description to mention the locations where the rule will check for it.

@michalb-sonar michalb-sonar added this to the 6.8 milestone Jan 17, 2018
@michalb-sonar michalb-sonar self-assigned this Jan 25, 2018
@michalb-sonar michalb-sonar changed the title Rule S2302: "nameof" should be used Rule S2302: 'nameof' should be used Jan 25, 2018
@ghost ghost removed the Status: Needs Review label Jan 29, 2018
@MaxTranced
Copy link

This has the same issue as
dotnet/roslyn-analyzers#1524

The rule should not be triggered for projects that set the advanced build setting "Language version" to C# 5 (any version prior to 6).

@michalb-sonar
Copy link
Contributor

Thanks for suggestion @MaxTranced! I've created a ticket: #1162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature This hasn't been here before.
Projects
None yet
Development

No branches or pull requests

4 participants