1 #region Copyright notice and license 2 // Protocol Buffers - Google's data interchange format 3 // Copyright 2015 Google Inc. All rights reserved. 4 // 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file or at 7 // https://developers.google.com/open-source/licenses/bsd 8 #endregion 9 10 #if !NET5_0_OR_GREATER 11 // Copied with permission from https://github.com/dotnet/runtime/tree/8fbf206d0e518b45ca855832e8bfb391afa85972/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis 12 namespace System.Diagnostics.CodeAnalysis 13 { 14 /// <summary> 15 /// Suppresses reporting of a specific rule violation, allowing multiple suppressions on a 16 /// single code artifact. 17 /// </summary> 18 /// <remarks> 19 /// <see cref="UnconditionalSuppressMessageAttribute"/> is different than 20 /// <see cref="SuppressMessageAttribute"/> in that it doesn't have a 21 /// <see cref="ConditionalAttribute"/>. So it is always preserved in the compiled assembly. 22 /// </remarks> 23 [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] 24 internal sealed class UnconditionalSuppressMessageAttribute : Attribute 25 { 26 /// <summary> 27 /// Initializes a new instance of the <see cref="UnconditionalSuppressMessageAttribute"/> 28 /// class, specifying the category of the tool and the identifier for an analysis rule. 29 /// </summary> 30 /// <param name="category">The category for the attribute.</param> 31 /// <param name="checkId">The identifier of the analysis rule the attribute applies to.</param> UnconditionalSuppressMessageAttribute(string category, string checkId)32 public UnconditionalSuppressMessageAttribute(string category, string checkId) 33 { 34 Category = category; 35 CheckId = checkId; 36 } 37 38 /// <summary> 39 /// Gets the category identifying the classification of the attribute. 40 /// </summary> 41 /// <remarks> 42 /// The <see cref="Category"/> property describes the tool or tool analysis category 43 /// for which a message suppression attribute applies. 44 /// </remarks> 45 public string Category { get; } 46 47 /// <summary> 48 /// Gets the identifier of the analysis tool rule to be suppressed. 49 /// </summary> 50 /// <remarks> 51 /// Concatenated together, the <see cref="Category"/> and <see cref="CheckId"/> 52 /// properties form a unique check identifier. 53 /// </remarks> 54 public string CheckId { get; } 55 56 /// <summary> 57 /// Gets or sets the scope of the code that is relevant for the attribute. 58 /// </summary> 59 /// <remarks> 60 /// The Scope property is an optional argument that specifies the metadata scope for which 61 /// the attribute is relevant. 62 /// </remarks> 63 public string Scope { get; set; } 64 65 /// <summary> 66 /// Gets or sets a fully qualified path that represents the target of the attribute. 67 /// </summary> 68 /// <remarks> 69 /// The <see cref="Target"/> property is an optional argument identifying the analysis target 70 /// of the attribute. An example value is "System.IO.Stream.ctor():System.Void". 71 /// Because it is fully qualified, it can be long, particularly for targets such as parameters. 72 /// The analysis tool user interface should be capable of automatically formatting the parameter. 73 /// </remarks> 74 public string Target { get; set; } 75 76 /// <summary> 77 /// Gets or sets an optional argument expanding on exclusion criteria. 78 /// </summary> 79 /// <remarks> 80 /// The <see cref="MessageId "/> property is an optional argument that specifies additional 81 /// exclusion where the literal metadata target is not sufficiently precise. For example, 82 /// the <see cref="UnconditionalSuppressMessageAttribute"/> cannot be applied within a method, 83 /// and it may be desirable to suppress a violation against a statement in the method that will 84 /// give a rule violation, but not against all statements in the method. 85 /// </remarks> 86 public string MessageId { get; set; } 87 88 /// <summary> 89 /// Gets or sets the justification for suppressing the code analysis message. 90 /// </summary> 91 public string Justification { get; set; } 92 } 93 } 94 #endif 95