1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+ // See the LICENSE file in the project root for more information.
4
+
5
+ #if ! NET6_0_OR_GREATER
6
+
7
+ namespace System . Diagnostics . CodeAnalysis ;
8
+
9
+ /// <summary>
10
+ /// Suppresses reporting of a specific rule violation, allowing multiple suppressions on a
11
+ /// single code artifact.
12
+ /// </summary>
13
+ /// <remarks>
14
+ /// <see cref="UnconditionalSuppressMessageAttribute"/> is different than
15
+ /// <see cref="SuppressMessageAttribute"/> in that it doesn't have a
16
+ /// <see cref="ConditionalAttribute"/>. So it is always preserved in the compiled assembly.
17
+ /// </remarks>
18
+ [ AttributeUsage ( AttributeTargets . All , Inherited = false , AllowMultiple = true ) ]
19
+ [ Conditional ( "DEBUG" ) ]
20
+ internal sealed class UnconditionalSuppressMessageAttribute : Attribute
21
+ {
22
+ /// <summary>
23
+ /// Initializes a new instance of the <see cref="UnconditionalSuppressMessageAttribute"/>
24
+ /// class, specifying the category of the tool and the identifier for an analysis rule.
25
+ /// </summary>
26
+ /// <param name="category">The category for the attribute.</param>
27
+ /// <param name="checkId">The identifier of the analysis rule the attribute applies to.</param>
28
+ public UnconditionalSuppressMessageAttribute ( string category , string checkId )
29
+ {
30
+ Category = category ;
31
+ CheckId = checkId ;
32
+ }
33
+
34
+ /// <summary>
35
+ /// Gets the category identifying the classification of the attribute.
36
+ /// </summary>
37
+ /// <remarks>
38
+ /// The <see cref="Category"/> property describes the tool or tool analysis category
39
+ /// for which a message suppression attribute applies.
40
+ /// </remarks>
41
+ public string Category { get ; }
42
+
43
+ /// <summary>
44
+ /// Gets the identifier of the analysis tool rule to be suppressed.
45
+ /// </summary>
46
+ /// <remarks>
47
+ /// Concatenated together, the <see cref="Category"/> and <see cref="CheckId"/>
48
+ /// properties form a unique check identifier.
49
+ /// </remarks>
50
+ public string CheckId { get ; }
51
+
52
+ /// <summary>
53
+ /// Gets or sets the scope of the code that is relevant for the attribute.
54
+ /// </summary>
55
+ /// <remarks>
56
+ /// The Scope property is an optional argument that specifies the metadata scope for which
57
+ /// the attribute is relevant.
58
+ /// </remarks>
59
+ public string ? Scope { get ; set ; }
60
+
61
+ /// <summary>
62
+ /// Gets or sets a fully qualified path that represents the target of the attribute.
63
+ /// </summary>
64
+ /// <remarks>
65
+ /// The <see cref="Target"/> property is an optional argument identifying the analysis target
66
+ /// of the attribute. An example value is "System.IO.Stream.ctor():System.Void".
67
+ /// Because it is fully qualified, it can be long, particularly for targets such as parameters.
68
+ /// The analysis tool user interface should be capable of automatically formatting the parameter.
69
+ /// </remarks>
70
+ public string ? Target { get ; set ; }
71
+
72
+ /// <summary>
73
+ /// Gets or sets an optional argument expanding on exclusion criteria.
74
+ /// </summary>
75
+ /// <remarks>
76
+ /// The <see cref="MessageId "/> property is an optional argument that specifies additional
77
+ /// exclusion where the literal metadata target is not sufficiently precise. For example,
78
+ /// the <see cref="UnconditionalSuppressMessageAttribute"/> cannot be applied within a method,
79
+ /// and it may be desirable to suppress a violation against a statement in the method that will
80
+ /// give a rule violation, but not against all statements in the method.
81
+ /// </remarks>
82
+ public string ? MessageId { get ; set ; }
83
+
84
+ /// <summary>
85
+ /// Gets or sets the justification for suppressing the code analysis message.
86
+ /// </summary>
87
+ public string ? Justification { get ; set ; }
88
+ }
89
+
90
+ #endif
0 commit comments