ExportCodeAnalysisRuleAttribute.Description 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
规则的说明。 这应该是一个简短的人类可读描述规则旨在警告或阻止的内容。 此字段是可本地化的,但应执行子类化 ExportCodeAnalysisRuleAttribute 并重写 Description 属性。
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;
}
}
}