ExportCodeAnalysisRuleAttribute.Description 속성

정의

규칙에 대한 설명입니다. 이는 규칙이 경고하거나 차단하기 위한 내용에 대한 간단한 사람이 읽을 수 있는 설명이어야 합니다. 이 필드는 지역화할 수 있지만 이 작업은 설명 속성을 서브클래싱 ExportCodeAnalysisRuleAttribute 하고 재정의해야 합니다.

public virtual string Description { get; set; }
member this.Description : string with get, set
Public Overridable Property Description As String

속성 값

예제

// Example of an Attribute class that supports localized descriptions:
public class TestLocalizedExportCodeAnalysisRuleAttribute : ExportCodeAnalysisRuleAttribute
{
    private readonly string _descriptionResourceName;
    private string _descriptionValue;

    public TestLocalizedExportCodeAnalysisRuleAttribute(string id, string displayName, string descriptionResourceName)
        : base(id, displayName)
    {
        _descriptionResourceName = descriptionResourceName;
    }

    public override string Description
    {
        get
        {
            if (_descriptionValue == null)
            {
                // Using the descriptionResourceName as the key for looking up the description in the resources file. 
                // MyResources is a resource file in the same project as the LocalizedExportCodeAnalysisRuleAttribute class. 
                // For each rule, and entry should be added to the resources file with the descriptionResourceName as the
                // key and the description as the value
                _descriptionValue = MyResources.ResourceManager.GetString(_descriptionResourceName);
            }
            return _descriptionValue;
        }
    }
}

적용 대상