SuppressMessageAttribute 클래스

정의

특정 코드 분석 규칙 위반에 대한 보고를 표시하지 않고 단일 코드 아티팩트에 대해 여러 번의 표시 안 을 허용합니다. 컴파일러 진단에는 적용되지 않습니다.

public ref class SuppressMessageAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true, Inherited=false)]
[System.Diagnostics.Conditional("CODE_ANALYSIS")]
public sealed class SuppressMessageAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true, Inherited=false)>]
[<System.Diagnostics.Conditional("CODE_ANALYSIS")>]
type SuppressMessageAttribute = class
    inherit Attribute
Public NotInheritable Class SuppressMessageAttribute
Inherits Attribute
상속
SuppressMessageAttribute
특성

예제

다음 코드 예제에서는 성능 경고 메시지를 표시 하지 않는 특성을 사용 SuppressMessageAttribute 하는 방법을 보여 줍니다.

#define CODE_ANALYSIS
using System;
using System.Diagnostics.CodeAnalysis;

namespace CodeAnalysisSample
{
    class Library
    {
        [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;
        }
    }
}
#Const CODE_ANALYSIS = True
Imports System.Diagnostics.CodeAnalysis



Class Library
    
    <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
End Class

설명

이 특성은 모든 애플리케이션 요소에 적용할 수 있습니다. 표시하지 않을 수 있는 위반의 전체 목록은 코드 품질 규칙을 참조하세요.

메모

ConditionalAttribute 처리 기호 "CODE_ANALYSIS"을 특성 호출이 포함 또는 생략되는지 여부를 결정하는 조건부 기호로 지정하여 이 클래스에 적용됩니다. 기호가 정의되면 특성 호출이 포함됩니다. 그렇지 않으면 호출이 생략됩니다.

Visual Studio 코드 분석 경고를 마우스 오른쪽 단추로 클릭하고 저장 파일에서 rule-ID 또는 업프레스 < 원본(특성)의 />rule-ID SuppressMessage 특성이 전역 억제 파일 또는 소스 코드 파일에 추가됩니다. SuppressMessage 특성 및 Visual Studio 사용에 대한 자세한 내용은 코드 분석 위반 참조하세요.

생성자

Name Description
SuppressMessageAttribute(String, String)

코드 분석 도구의 SuppressMessageAttribute 범주와 분석 규칙의 식별자를 지정하여 클래스의 새 인스턴스를 초기화합니다.

속성

Name Description
Category

특성의 분류를 식별하는 범주를 가져옵니다.

CheckId

표시하지 않을 코드 분석 도구 규칙의 식별자를 가져옵니다.

Justification

코드 분석 메시지를 표시하지 않는 근거를 가져오거나 설정합니다.

MessageId

확장된 제외 조건을 가져오거나 설정합니다.

Scope

특성과 관련된 코드의 범위를 가져오거나 설정합니다.

Target

코드 분석 대상을 나타내는 정규화된 경로를 가져오거나 설정합니다.

TypeId

파생 클래스에서 구현되는 경우 이 Attribute대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)

메서드

Name Description
Equals(Object)

이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

(다음에서 상속됨 Attribute)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

파생 클래스에서 재정의되는 경우 이 인스턴스의 값이 파생 클래스의 기본값인지 여부를 나타냅니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의되는 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

Name Description
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체가 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에 의해 노출되는 속성 및 메서드에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상