-
Notifications
You must be signed in to change notification settings - Fork 510
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
Conversation
Current coverage is
|
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); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
👍 Looks good to me, besides the question about a testcase. |
Update SA1302 code fix to support conflict resolution
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.