-
Notifications
You must be signed in to change notification settings - Fork 4k
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
SuppressMessageAttribute not working with namespaces #152
Comments
@giggio This is as per the design of FxCop source level suppressions, and we have retained that design in Roslyn. Please see the note in section "Global-Level Suppressions" in here: https://msdn.microsoft.com/en-us/library/ms244717.aspx "When you suppress a warning with namespace scope, it suppresses the warning against the namespace itself. It does not suppress the warning against types within the namespace." @srivatsn By Design? |
@shyamnamboodiripad Can you double check if we are fine with the current design for suppress message attribute applied with namespace target? Seems reasonable to me.. |
Let's stick to the FxCop convention for the suppressmessage attribute otherwise we will end up breaking a bunch of suppressions in existing code. |
I agree it makes sense to stick with the FxCop convention in this case. |
Ok, it makes sense not to break everyone. But how would then I suppress diagnostics against types inside the namespace? Is that at all possible? Or will I have to add each one individually? This would be really annoying. |
You can suppress a diagnostic on the entire type in one of the following ways:
If either approach doesn't work, its a bug that must be fixed. |
But yes, you would have to do it on individual type. Alternatively you can suppress it on the entire assembly by having as assembly attribute with no scope and target. |
Ok, this is insufficient. The ability to suppress a diagnostic on a specific namespace, including all its types, is really important. I am seeing that there is no way to do this today? May I suggest that feature? :) |
Just as a follow up, I posted the idea to uservoice: https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/7091554-allow-suppressmessageattribute-to-work-types-withi |
We could just add a new scope called "TypesInNamespace" and specifying a namespace there should suppress in all types in that namespace. |
Created #486 to track this request. |
Yes, I don't think implementing this is tough for us in Roslyn. However, it would be good to know the original thinking behind the current design. Probably Nate remembers, let me follow up with him. |
I will tell you why I need it, and maybe it helps. You can see on my original post above that I am asking for it on the namespace |
…easier way to do this (dotnet/roslyn#152)
I am trying to uses the GlobalSuppressions file to suppress a specific rule on a specific namespace on my test project, like so:
But it does not work. The diagnostic keeps being generated. The method specific works:
I guess this is a bug, right?
The text was updated successfully, but these errors were encountered: