Bewerken

Share via


SuppressMessageAttribute.MessageId Property

Definition

Gets or sets the expanded exclusion criteria.

public:
 property System::String ^ MessageId { System::String ^ get(); void set(System::String ^ value); };
public string MessageId { get; set; }
public string? MessageId { get; set; }
member this.MessageId : string with get, set
Public Property MessageId As String

Property Value

A string containing the expanded exclusion criteria.

Examples

The following code example shows the use of the SuppressMessageAttribute attribute to suppress warnings for a specific parameter in a method declaration and a specific field in the method. This code example is part of a larger example provided for the SuppressMessageAttribute class.

[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

Remarks

The MessageId property is an optional argument that specifies additional exclusion where the literal metadata target is not sufficiently precise. For example, the SuppressMessageAttribute cannot be applied within a method, but you may want to suppress a violation against a single statement in the method.

Note

This property is only respected by legacy code analysis.

Applies to