1 #region Copyright notice and license 2 // Protocol Buffers - Google's data interchange format 3 // Copyright 2015 Google Inc. All rights reserved. 4 // https://developers.google.com/protocol-buffers/ 5 // 6 // Redistribution and use in source and binary forms, with or without 7 // modification, are permitted provided that the following conditions are 8 // met: 9 // 10 // * Redistributions of source code must retain the above copyright 11 // notice, this list of conditions and the following disclaimer. 12 // * Redistributions in binary form must reproduce the above 13 // copyright notice, this list of conditions and the following disclaimer 14 // in the documentation and/or other materials provided with the 15 // distribution. 16 // * Neither the name of Google Inc. nor the names of its 17 // contributors may be used to endorse or promote products derived from 18 // this software without specific prior written permission. 19 // 20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 #endregion 32 33 #if !NET5_0_OR_GREATER 34 // Copied with permission from https://github.com/dotnet/runtime/tree/8fbf206d0e518b45ca855832e8bfb391afa85972/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis 35 namespace System.Diagnostics.CodeAnalysis 36 { 37 /// <summary> 38 /// Suppresses reporting of a specific rule violation, allowing multiple suppressions on a 39 /// single code artifact. 40 /// </summary> 41 /// <remarks> 42 /// <see cref="UnconditionalSuppressMessageAttribute"/> is different than 43 /// <see cref="SuppressMessageAttribute"/> in that it doesn't have a 44 /// <see cref="ConditionalAttribute"/>. So it is always preserved in the compiled assembly. 45 /// </remarks> 46 [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] 47 internal sealed class UnconditionalSuppressMessageAttribute : Attribute 48 { 49 /// <summary> 50 /// Initializes a new instance of the <see cref="UnconditionalSuppressMessageAttribute"/> 51 /// class, specifying the category of the tool and the identifier for an analysis rule. 52 /// </summary> 53 /// <param name="category">The category for the attribute.</param> 54 /// <param name="checkId">The identifier of the analysis rule the attribute applies to.</param> UnconditionalSuppressMessageAttribute(string category, string checkId)55 public UnconditionalSuppressMessageAttribute(string category, string checkId) 56 { 57 Category = category; 58 CheckId = checkId; 59 } 60 61 /// <summary> 62 /// Gets the category identifying the classification of the attribute. 63 /// </summary> 64 /// <remarks> 65 /// The <see cref="Category"/> property describes the tool or tool analysis category 66 /// for which a message suppression attribute applies. 67 /// </remarks> 68 public string Category { get; } 69 70 /// <summary> 71 /// Gets the identifier of the analysis tool rule to be suppressed. 72 /// </summary> 73 /// <remarks> 74 /// Concatenated together, the <see cref="Category"/> and <see cref="CheckId"/> 75 /// properties form a unique check identifier. 76 /// </remarks> 77 public string CheckId { get; } 78 79 /// <summary> 80 /// Gets or sets the scope of the code that is relevant for the attribute. 81 /// </summary> 82 /// <remarks> 83 /// The Scope property is an optional argument that specifies the metadata scope for which 84 /// the attribute is relevant. 85 /// </remarks> 86 public string Scope { get; set; } 87 88 /// <summary> 89 /// Gets or sets a fully qualified path that represents the target of the attribute. 90 /// </summary> 91 /// <remarks> 92 /// The <see cref="Target"/> property is an optional argument identifying the analysis target 93 /// of the attribute. An example value is "System.IO.Stream.ctor():System.Void". 94 /// Because it is fully qualified, it can be long, particularly for targets such as parameters. 95 /// The analysis tool user interface should be capable of automatically formatting the parameter. 96 /// </remarks> 97 public string Target { get; set; } 98 99 /// <summary> 100 /// Gets or sets an optional argument expanding on exclusion criteria. 101 /// </summary> 102 /// <remarks> 103 /// The <see cref="MessageId "/> property is an optional argument that specifies additional 104 /// exclusion where the literal metadata target is not sufficiently precise. For example, 105 /// the <see cref="UnconditionalSuppressMessageAttribute"/> cannot be applied within a method, 106 /// and it may be desirable to suppress a violation against a statement in the method that will 107 /// give a rule violation, but not against all statements in the method. 108 /// </remarks> 109 public string MessageId { get; set; } 110 111 /// <summary> 112 /// Gets or sets the justification for suppressing the code analysis message. 113 /// </summary> 114 public string Justification { get; set; } 115 } 116 } 117 #endif 118