System.Diagnostics.CodeAnalysis.SuppressMessageAttribute Class

Suppresses reporting of a specific static analysis tool rule violation, allowing multiple suppressions on a single code artifact.

See Also: SuppressMessageAttribute Members


[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true, Inherited=false)]
public sealed class SuppressMessageAttribute : Attribute


This attribute can be applied to any application element. For a complete list of the violations that can be suppressed, see Code Analysis for Managed Code Warnings.


The System.Diagnostics.ConditionalAttribute is applied to this class, specifying the preprocessing symbol "CODE_ANALYSIS" as the conditional symbol that determines whether the attribute call is included or omitted. If the symbol is defined, the attribute call is included; otherwise, the call is omitted.

When you right-click a Code Analysis warning in the Visual Studio Error List and then click Suppress Message(s), a SuppressMessage attribute is added either in your code or to the project's global suppressions file. For more information about the SuppressMessage attribute and its use in Visual Studio, see In Source Suppression Overview.


Namespace: System.Diagnostics.CodeAnalysis
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0