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

Syntax

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

Remarks

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.

Note:

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.

Requirements

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