views:

348

answers:

2

...any change?

The scenario is this:

  • For our company we develop a standard how code should look.
  • This will be the MS full rule set as it looks now.
  • For some specific projects we may want to turn off specific rules. Simply because for a specific project this is a "known exception". Example? CA1026 - while perfectly ok in most cases, there are 1-2 specific libraries we dont want to change those.
  • We also want to avoid having a custom rule set. OTOH putting in a suppress attribute on every occurance gets pretty convoluted pretty fast.

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 ;)

+2  A: 

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.

Nicole Calinoiu
THanks. THought so - too bad. Well, suppressing violations in the VS IDE actually makes it manageable ;) SLowly working my way through them. THere are tons, and a lot more.... projects to activate ;) I acutally found some nice possible bugs - very good ;)
TomTom
A: 

You'd actually have more flexibility of exclusions with CodeIt.Right for static analysis. And saved all that time :)

sergeb