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 (InterfaceNamesMustBeginWithI) to handle conflicting names #436

Closed
sharwell opened this issue Jan 31, 2015 · 4 comments
Closed

Comments

@sharwell
Copy link
Member

The following code results in an SA1302 warning. If the code fix is applied, it introduces a new compiler error.

public interface Foo { }
public interface IFoo { }
public class Bar : Foo { }

We first need to decide how we want to handle this case (and similar), followed by implementation and tests.

@macpak
Copy link
Contributor

macpak commented Feb 1, 2015

First of all we need to check if a type with the new name exists in the same namespace. If it's in a different namespace - it's safe to apply the fix. If the type aleady exists in the namespace, maybe we should append a number to the name, to make it unique (of course, if we have Foo interface, and IFoo and IFoo2 already exist, we should rename it to IFoo3).

@sharwell
Copy link
Member Author

sharwell commented Feb 1, 2015

We could do that. First I'm curious if there is a way to check with Renamer to see if the rename operation introduced new errors, and cancel the code fix if it did.

@macpak
Copy link
Contributor

macpak commented Feb 4, 2015

Isn't it done in #443 ?

@sharwell
Copy link
Member Author

sharwell commented Feb 4, 2015

No, that pull request makes improvements based on the feedback in dotnet/roslyn#197, but this particular issue did not behave in the manner expected by that team. Hopefully the next release of the code fix framework allows us to notify the user of a conflict prior to applying it.

@sharwell sharwell removed this from the 1.0.0 Alpha 2 milestone Feb 8, 2015
@sharwell sharwell modified the milestone: 1.0.0 RC 1 Sep 17, 2015
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Nov 27, 2015
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Nov 27, 2015
@sharwell sharwell assigned sharwell and unassigned macpak Nov 27, 2015
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants