-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
IDE0065 (Using directives must be placed outside of a namespace declaration) is noisy for alias declarations inside namespace #43271
Comments
I don't mind requiring a suppression for this case. It means you've already introduced a naming ambiguity (though it's sometimes accidental or unavoidable in XML comments). I'd love to have #27712 for this. |
This had 60+ violations in just the analyzers repo, and I suspect would have many more in Roslyn. This makes me feel like it would be noisy enough to warrant an additional option for aliases. We can wait for more customer feedback and decide though. |
@mavasani I was only calling out the case where the alias must appear inside the namespace for correctness. I would be surprised if that was a majority case; generally the alias can be moved outside the namespace as long as the types are fully-qualified at the same time. |
tihs is true, but is often undesirably verbose. I agree that The latter is used commonly for:
|
I've had pull requests rejected from projects because I placed a using alias directive inside the namespace to avoid unnecessary verbosity. This analyzer and refactoring eliminated the tedious work of moving and qualifying it. It would be unfortunate to take that help away. |
Can we add an option to exclude alias declarations from this rule? I think this is a classic case where there would be a proportionately divided group on whether or not they should be included in the rule, and it seems to justify an end user option. |
Marking for design review. |
This issue was discussed during today's design meeting (4/13). It was decided that we will add an option to exclude using alias declarations, however the default configuration will be kept the same (i.e. applies to everything). |
Version Used: Latest
Steps to Reproduce:
Expected Behavior:
Either
IDE0065
does not fire or it has a code style option to allow alias declarations inside namespace. This is a very common pattern and is sometimes essential for correct type resolution.Actual Behavior:
IDE0065
fires. This makes it very difficult to enforce this rule on CI.The text was updated successfully, but these errors were encountered: