SuppressMessageAttribute(String, String) Konstruktor

Definice

Inicializuje novou instanci SuppressMessageAttribute třídy, určuje kategorii nástroje pro analýzu kódu a identifikátor pravidla analýzy.

public:
 SuppressMessageAttribute(System::String ^ category, System::String ^ checkId);
public SuppressMessageAttribute(string category, string checkId);
new System.Diagnostics.CodeAnalysis.SuppressMessageAttribute : string * string -> System.Diagnostics.CodeAnalysis.SuppressMessageAttribute
Public Sub New (category As String, checkId As String)

Parametry

category
String

Kategorie atributu.

checkId
String

Identifikátor pravidla analytického nástroje, na které se atribut vztahuje.

Příklady

Následující příklad kódu ukazuje použití atributu SuppressMessageAttribute k potlačení upozornění pro Microsoft.Performance kategorii a CA1801 identifikátory a CA1804 kontroly. Tento příklad kódu je součástí většího příkladu uvedeného pro třídu SuppressMessageAttribute.

[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", 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;
}
<SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId:="isChecked"), _
 SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId:="fileIdentifier")> _
Shared Sub FileNode(ByVal name As String, ByVal isChecked As Boolean)
    Dim fileIdentifier As String = name
    Dim fileName As String = name
    Dim version As String = String.Empty

End Sub

Poznámky

Hodnota category parametru je specifická pro analytický nástroj a kategorizuje pravidlo identifikované parametrem checkId . Dva parametry zřetězené dohromady tvoří jedinečný identifikátor pravidla.

Note

Aby byl tento atribut efektivní, musí být definován symbol preprocesoru "CODE_ANALYSIS". Absence symbolu preprocesoru způsobí, že se atribut nepoužije.

Platí pro