SuppressMessageAttribute Class
Assembly: mscorlib (in mscorlib.dll)
[AttributeUsageAttribute(AttributeTargets.All, Inherited=false, AllowMultiple=true)] [ConditionalAttribute("CODE_ANALYSIS")] public sealed class SuppressMessageAttribute : Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All, Inherited=false, AllowMultiple=true) */
/** @attribute ConditionalAttribute("CODE_ANALYSIS") */
public final class SuppressMessageAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.All, Inherited=false, AllowMultiple=true) ConditionalAttribute("CODE_ANALYSIS") public final class SuppressMessageAttribute extends Attribute
This attribute can be applied to any application element.
Note |
|---|
| The 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.
|
The following code example shows the use of the SuppressMessageAttribute attribute to suppress performance warning messages.
#define CODE_ANALYSIS using System; using System.Diagnostics.CodeAnalysis; namespace CodeAnalysisSample { class Library { [SuppressMessage("Microsoft.Performance", "CA1801:AvoidUnusedParameters", MessageId = "isChecked")] [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "fileIdentifier")] static void FileNode(string name, bool isChecked) { string fileIdentifier = name; string fileName = name; string version = String.Empty; } } }
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Note