visual-studio-2010code-analysissuppressmessage

VS2010 / Code Analysis: Turn off a rule for a project without custom ruleset


...any change?

The scenario is this:

Any way to turn off a code analysis warning for a complete assembly without a custom rule set? We rather have that in a specific file (GlobalSuppressions.cs) than in a rule set for maintenance reasons, and to be more explicit ;)


Solution

  • There is no way to create an assembly-level exclusion that will cover all violations of that rule for types and/or members within the assembly.

    You could probably still use the CodeAnalysisRules element in your project file, but this is essentially just as much work as a custom ruleset, and more difficult to track given that it's not shown in the project properties UI.

    Regardless of the mechanism you would prefer to use, you should also consider whether you want to simply exclude existing violation or whether you want new violations to be introduced. If the former, you should add SuppressMessage attributes for the existing violations. If the latter, you should disable the rule for the assembly.

    BTW, in case you weren't aware of this, you can suppress multiple violations at once in the violation list in VStudio.