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

Update SA1302 code fix to support conflict resolution #1849

Merged
merged 5 commits into from
Nov 27, 2015

Conversation

sharwell
Copy link
Member

Fixes #436

Edit: Need to update this to ensure a nested type isn't renamed to the same name as the enclosing type. This is now working.

@sharwell sharwell added this to the 1.0.0 RC 1 milestone Nov 27, 2015
@codecov-io
Copy link

Current coverage is 79.34%

Merging #1849 into master will decrease coverage by -0.01% as of 39090ba

@@            master   #1849   diff @@
======================================
  Files          554     554       
  Stmts        34068   34153    +85
  Branches      9407    9441    +34
  Methods                          
======================================
+ Hit          27033   27097    +64
- Partial       5455    5477    +22
+ Missed        1580    1579     -1

Review entire Coverage Diff as of 39090ba

Powered by Codecov. Updated on successful CI builds.

@sharwell sharwell self-assigned this Nov 27, 2015
This helper is a combination of work on DotNetAnalyzers#436 and DotNetAnalyzers#437, and offers a more
flexible solution for avoiding conflicts during rename operations.
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Why is the interface renamed to IFoo1 here? There clearly is no conflict.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ It contains a member named IFoo. Members are not allowed to have the same name as the containing type, so either we don't use the name IFoo for the interface, or we have to rename both the interface and the property. I went with the former.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Members can have the same name as the containing type, there is nothing preventing that. The compiler accepts it, and so does StyleCop Analyzers. Its not desirable, but that should the subject for a new diagnostic imho.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is partially correct. If the containing type is a class or struct, you get CS0542. If the containing type is an interface or enum, you don't get an error. I can update this in #1851 if you want.

@vweijsters
Copy link
Contributor

👍 Looks good to me, besides the question about a testcase.

@sharwell sharwell assigned vweijsters and unassigned sharwell Nov 27, 2015
sharwell added a commit that referenced this pull request Nov 27, 2015
Update SA1302 code fix to support conflict resolution
@sharwell sharwell merged commit c05d224 into DotNetAnalyzers:master Nov 27, 2015
@sharwell sharwell deleted the fix-436 branch November 27, 2015 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants