|
48 | 48 | </Attribute> |
49 | 49 | </Attributes> |
50 | 50 | <Docs> |
51 | | - <summary>Suppresses reporting of a specific static analysis tool rule violation, allowing multiple suppressions on a single code artifact. Does not apply to compiler diagnostics.</summary> |
| 51 | + <summary>Suppresses reporting of a specific code analysis rule violation, allowing multiple suppressions on a single code artifact. Does not apply to compiler diagnostics.</summary> |
52 | 52 | <remarks> |
53 | | - <format type="text/markdown"><. |
57 | | - |
| 53 | + <format type="text/markdown"><. |
| 57 | +
|
58 | 58 | > [!NOTE] |
59 | | -> The <xref: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. |
60 | | -> |
61 | | -> 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](/visualstudio/code-quality/in-source-suppression-overview). |
| 59 | +> The <xref: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. |
| 60 | +> |
| 61 | +> When you right-click a code analysis warning in Visual Studio and choose **Suppress <rule-ID> > in Suppression File** or **Suppress <rule-ID> > in Source (attribute)**, a **SuppressMessage** attribute is added to either the global suppressions file or to the source code file. For more information about the **SuppressMessage** attribute and its use in Visual Studio, see [Suppress code analysis violations](/visualstudio/code-quality/in-source-suppression-overview). |
| 62 | +
|
| 63 | +## Examples |
| 64 | + The following code example shows the use of the <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> attribute to suppress performance warning messages. |
62 | 65 |
|
63 | | -## Examples |
64 | | - The following code example shows the use of the <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> attribute to suppress performance warning messages. |
65 | | - |
66 | 66 | [!code-csharp[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/CS/program.cs#1)] |
67 | | - [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#1)] |
68 | | - |
| 67 | + [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#1)] |
| 68 | +
|
69 | 69 | ]]></format> |
70 | 70 | </remarks> |
71 | 71 | </Docs> |
|
107 | 107 | <Docs> |
108 | 108 | <param name="category">The category for the attribute.</param> |
109 | 109 | <param name="checkId">The identifier of the analysis tool rule the attribute applies to.</param> |
110 | | - <summary>Initializes a new instance of the <see cref="T:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute" /> class, specifying the category of the static analysis tool and the identifier for an analysis rule.</summary> |
| 110 | + <summary>Initializes a new instance of the <see cref="T:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute" /> class, specifying the category of the code analysis tool and the identifier for an analysis rule.</summary> |
111 | 111 | <remarks> |
112 | | - <format type="text/markdown"><![CDATA[ |
113 | | - |
114 | | -## Remarks |
| 112 | + <format type="text/markdown"><![CDATA[ |
| 113 | +
|
| 114 | +## Remarks |
| 115 | +
|
| 116 | +The `category` parameter value is specific to the analysis tool and categorizes the rule identified by the `checkId` parameter. The two parameters concatenated together form a unique identifier for the rule. |
115 | 117 |
|
116 | | -The `category` parameter value is specific to the analysis tool and categorizes the rule identified by the `checkId` parameter. The two parameters concatenated together form a unique identifier for the rule. |
117 | | - |
118 | 118 | > [!NOTE] |
119 | 119 | > The preprocessor symbol "CODE_ANALYSIS" must be defined for this attribute to be effective. The absence of the preprocessor symbol results in the attribute not being applied. |
120 | | - |
121 | | -## Examples |
122 | 120 |
|
123 | | -The following code example shows the use of the <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> attribute to suppress warnings for the `Microsoft.Performance` category and the `CA1801` and `CA1804` check identifiers. This code example is part of a larger example provided for the <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> class. |
124 | | - |
| 121 | +## Examples |
| 122 | +
|
| 123 | +The following code example shows the use of the <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> attribute to suppress warnings for the `Microsoft.Performance` category and the `CA1801` and `CA1804` check identifiers. This code example is part of a larger example provided for the <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> class. |
| 124 | +
|
125 | 125 | [!code-csharp[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/CS/program.cs#2)] |
126 | | - [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#2)] |
127 | | - |
| 126 | + [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#2)] |
| 127 | +
|
128 | 128 | ]]></format> |
129 | 129 | </remarks> |
130 | 130 | </Docs> |
@@ -167,18 +167,18 @@ The following code example shows the use of the <xref:System.Diagnostics.CodeAna |
167 | 167 | <summary>Gets the category identifying the classification of the attribute.</summary> |
168 | 168 | <value>The category identifying the attribute.</value> |
169 | 169 | <remarks> |
170 | | - <format type="text/markdown"><] |
180 | | - [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#2)] |
181 | | - |
| 180 | + [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#2)] |
| 181 | +
|
182 | 182 | ]]></format> |
183 | 183 | </remarks> |
184 | 184 | </Docs> |
@@ -218,21 +218,21 @@ The <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute.Category%2A> |
218 | 218 | <ReturnType>System.String</ReturnType> |
219 | 219 | </ReturnValue> |
220 | 220 | <Docs> |
221 | | - <summary>Gets the identifier of the static analysis tool rule to be suppressed.</summary> |
222 | | - <value>The identifier of the static analysis tool rule to be suppressed.</value> |
| 221 | + <summary>Gets the identifier of the code analysis tool rule to be suppressed.</summary> |
| 222 | + <value>The identifier of the code analysis tool rule to be suppressed.</value> |
223 | 223 | <remarks> |
224 | | - <format type="text/markdown"><] |
234 | | - [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#2)] |
235 | | - |
| 234 | + [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#2)] |
| 235 | +
|
236 | 236 | ]]></format> |
237 | 237 | </remarks> |
238 | 238 | </Docs> |
@@ -310,21 +310,24 @@ Concatenated together, the <xref:System.Diagnostics.CodeAnalysis.SuppressMessage |
310 | 310 | <ReturnType>System.String</ReturnType> |
311 | 311 | </ReturnValue> |
312 | 312 | <Docs> |
313 | | - <summary>Gets or sets an optional argument expanding on exclusion criteria.</summary> |
| 313 | + <summary>Gets or sets the expanded exclusion criteria.</summary> |
314 | 314 | <value>A string containing the expanded exclusion criteria.</value> |
315 | 315 | <remarks> |
316 | | - <format type="text/markdown"><![CDATA[ |
317 | | - |
318 | | -## Remarks |
319 | | -
|
320 | | -The <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute.MessageId%2A> property is an optional argument that specifies additional exclusion where the literal metadata target is not sufficiently precise. For example, the <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> cannot be applied within a method, and it may be desirable to suppress a violation against a statement in the method that will give a rule violation, but not against all statements in the method. |
321 | | - |
322 | | -## Examples |
323 | | - The following code example shows the use of the <xref:System.Diagnostics.CodeAnalysis.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 <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> class. |
324 | | - |
| 316 | + <format type="text/markdown"><![CDATA[ |
| 317 | +
|
| 318 | +## Remarks |
| 319 | +
|
| 320 | +The <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute.MessageId%2A> property is an optional argument that specifies additional exclusion where the literal metadata target is not sufficiently precise. For example, the <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> cannot be applied within a method, but you may want to suppress a violation against a single statement in the method. |
| 321 | +
|
| 322 | +> [!NOTE] |
| 323 | +> This property is only respected by [legacy code analysis](/visualstudio/code-quality/static-code-analysis-for-managed-code-overview). |
| 324 | +
|
| 325 | +## Examples |
| 326 | + The following code example shows the use of the <xref:System.Diagnostics.CodeAnalysis.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 <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute> class. |
| 327 | +
|
325 | 328 | [!code-csharp[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/CS/program.cs#2)] |
326 | | - [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#2)] |
327 | | - |
| 329 | + [!code-vb[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CodeAnalysis.SuppressMessageAttribute/VB/program.vb#2)] |
| 330 | +
|
328 | 331 | ]]></format> |
329 | 332 | </remarks> |
330 | 333 | </Docs> |
@@ -366,12 +369,22 @@ The <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute.MessageId%2A> |
366 | 369 | <summary>Gets or sets the scope of the code that is relevant for the attribute.</summary> |
367 | 370 | <value>The scope of the code that is relevant for the attribute.</value> |
368 | 371 | <remarks> |
369 | | - <format type="text/markdown"><. |
374 | | - |
| 376 | +The <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute.Scope%2A> property is an optional argument that specifies the metadata scope for which the attribute is relevant. The following table shows the possible values. |
| 377 | +
|
| 378 | +| Value | Description | |
| 379 | +| - | - | |
| 380 | +| `"member"` | Suppresses warnings against a member. | |
| 381 | +| `"module"` | Suppresses warnings against an assembly. It is a global suppression that applies to the entire project. | |
| 382 | +| `"namespace"` | This scope suppresses warnings against the namespace itself. It does not suppress warnings against types within the namespace. | |
| 383 | +| `"namespaceanddescendants"` | Suppresses warnings in a namespace and all its descendant symbols. This value is ignored by [legacy code analysis](/visualstudio/code-quality/static-code-analysis-for-managed-code-overview). | |
| 384 | +| `"type"` | Suppresses warnings against a type. | |
| 385 | +
|
| 386 | +For [legacy code analysis](/visualstudio/code-quality/static-code-analysis-for-managed-code-overview), `"resource"` is also a valid value. For more information about scopes, see [Suppress code analysis warnings](/visualstudio/code-quality/in-source-suppression-overview#suppressmessage-attribute). |
| 387 | +
|
375 | 388 | ]]></format> |
376 | 389 | </remarks> |
377 | 390 | </Docs> |
@@ -410,14 +423,14 @@ The <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute.Scope%2A> pro |
410 | 423 | <ReturnType>System.String</ReturnType> |
411 | 424 | </ReturnValue> |
412 | 425 | <Docs> |
413 | | - <summary>Gets or sets a fully qualified path that represents the target of the attribute.</summary> |
414 | | - <value>A fully qualified path that represents the target of the attribute.</value> |
| 426 | + <summary>Gets or sets a fully qualified path that represents the code analysis target.</summary> |
| 427 | + <value>A fully qualified path that represents the code analysis target.</value> |
415 | 428 | <remarks> |
416 | | - <format type="text/markdown"><![CDATA[ |
417 | | - |
418 | | -## Remarks |
419 | | - The <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute.Target%2A> property is an optional argument identifying the analysis target of the attribute. An example value is "System.IO.Stream.ctor():System.Void". Because it is fully qualified, it can be long, particularly for targets such as parameters. The analysis tool user interface should be capable of automatically formatting the parameter. |
420 | | - |
| 429 | + <format type="text/markdown"><![CDATA[ |
| 430 | +
|
| 431 | +## Remarks |
| 432 | + The <xref:System.Diagnostics.CodeAnalysis.SuppressMessageAttribute.Target%2A> property is an optional argument identifying the analysis target of the attribute. An example value is "System.IO.Stream.ctor():System.Void". Because it is fully qualified, it can be long, particularly for targets such as parameters. The analysis tool user interface should be capable of automatically formatting the parameter. |
| 433 | +
|
421 | 434 | ]]></format> |
422 | 435 | </remarks> |
423 | 436 | </Docs> |
|
0 commit comments