views:

643

answers:

1

When you use Visual Studio's code analysic (FxCop), and want to supress a message there are 3 options.

  1. Supress a violation in code.
  2. Supress a violation in a GlobalSupression.cs file.
  3. Disable the violation check in the project file (via Project -> Properties -> Code Analysic).

The later is very hard to review when checking in to Source Control, and it is hard to get an overview of all disabled vioaltions. So we would like to use option 2.

The problem with option 1 and 2 is that you get one supression line for each violation. E.g like:

[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Company.Project.Namespace2")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Company.Project.Namespace1")]

We would love to do something like this ing GlobalSuppressions.cs:

[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes")]

But is this possible?

How are you solving this?

+2  A: 

Suppressing multiple violations with a single SuppressMessage attribute is officially not supported. Apparently, this is by design.

I agree, it might be annoying at times, but I can't say I disagree with the decision, since the attribute is their way to force you to say, "Yes, I know what I am doing", which should be evaluated in a case-by-case basis.

Ishmaeel