<p>When you use Visual Studio's code analysic (FxCop), and want to suppress a message there are 3 options.</p>

<ol>
<li>Suppress a violation in code.</li>
<li>Suppress a violation in a GlobalSupression.cs file.</li>
<li>Disable the violation check in the project file (via Project -> Properties -> Code Analysic).</li>
</ol>

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

<p>The problem with option 1 and 2 is that you get one suppression line for each violation. E.g like: </p>

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

<p>We would love to do something like this ing GlobalSuppressions.cs:</p>

<pre><code>[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes")]
</code></pre>

<p>But is this possible?</p>

[{'answer_id': 73369, 'author': 'Ishmaeel', 'author_id': 227, 'author_profile': 'https://Stackoverflow.com/users/227', 'pm_score': 4, 'selected': True, 'text': '<p>Suppressing multiple violations with a single <strong>SuppressMessage</strong> attribute is officially not supported. Apparently, this is by design.</p>\n\n<p>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.</p>\n'}, {'answer_id': 18930943, 'author': 'RenniePet', 'author_id': 253938, 'author_profile': 'https://Stackoverflow.com/users/253938', 'pm_score': 1, 'selected': False, 'text': '<p>I think things have changed since this question was posted and answered. For Visual Studio 2010 and 2012 you can create a custom "rule set" file where you can specify which code analysis rules you want to suppress. </p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/dd380660.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd380660.aspx</a></p>\n\n<p>So what I\'ve done is to create a single custom rule set file which is in the top level folder of my repository source collection, and I reference this file in each Visual Studio project. This means I have one central place where I can suppress the code analysis rules that I simply can\'t stand. But if I ever change my mind, or decide I should reconsider my bad coding habits, I can very simply reenable the rule and see how many code analysis messages I get. </p>\n'}]
['https://Stackoverflow.com/questions/72832', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8547/']