DiagnosticDescriptor 构造函数

定义

重载

DiagnosticDescriptor(String, LocalizableString, LocalizableString, String, DiagnosticSeverity, Boolean, LocalizableString, String, String[])

创建 DiagnosticDescriptor,用于提供有关 的说明 Diagnostic

DiagnosticDescriptor(String, String, String, String, DiagnosticSeverity, Boolean, String, String, String[])

创建 DiagnosticDescriptor,用于提供有关 的说明 Diagnostic。 注意:对于可本地化的 titledescription 和/或 messageFormat,请使用构造函数重载 DiagnosticDescriptor(String, LocalizableString, LocalizableString, String, DiagnosticSeverity, Boolean, LocalizableString, String, String[])

DiagnosticDescriptor(String, LocalizableString, LocalizableString, String, DiagnosticSeverity, Boolean, LocalizableString, String, String[])

Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs

创建 DiagnosticDescriptor,用于提供有关 的说明 Diagnostic

public DiagnosticDescriptor (string id, Microsoft.CodeAnalysis.LocalizableString title, Microsoft.CodeAnalysis.LocalizableString messageFormat, string category, Microsoft.CodeAnalysis.DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, Microsoft.CodeAnalysis.LocalizableString description = default, string helpLinkUri = default, params string[] customTags);
public DiagnosticDescriptor (string id, Microsoft.CodeAnalysis.LocalizableString title, Microsoft.CodeAnalysis.LocalizableString messageFormat, string category, Microsoft.CodeAnalysis.DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, Microsoft.CodeAnalysis.LocalizableString? description = default, string? helpLinkUri = default, params string[] customTags);
new Microsoft.CodeAnalysis.DiagnosticDescriptor : string * Microsoft.CodeAnalysis.LocalizableString * Microsoft.CodeAnalysis.LocalizableString * string * Microsoft.CodeAnalysis.DiagnosticSeverity * bool * Microsoft.CodeAnalysis.LocalizableString * string * string[] -> Microsoft.CodeAnalysis.DiagnosticDescriptor
Public Sub New (id As String, title As LocalizableString, messageFormat As LocalizableString, category As String, defaultSeverity As DiagnosticSeverity, isEnabledByDefault As Boolean, Optional description As LocalizableString = Nothing, Optional helpLinkUri As String = Nothing, ParamArray customTags As String())

参数

id
String

诊断的唯一标识符。 例如,代码分析诊断 ID“CA1001”。

title
LocalizableString

描述诊断的简短可本地化标题。 例如,对于 CA1001:“拥有可释放字段的类型应是可释放的”。

messageFormat
LocalizableString

可本地化的格式消息字符串,在使用此描述符创建诊断消息时,可将其作为第一个参数 Format(String, Object[]) 传递给 。 例如,对于 CA1001:“在''{0}上实现 IDisposable,因为它创建以下 IDisposable 类型的成员:'{1}'。”

category
String

诊断 ((如设计、命名等)的类别 ) 。 例如,对于 CA1001:“Microsoft.Design”。

defaultSeverity
DiagnosticSeverity

诊断的默认严重性。

isEnabledByDefault
Boolean

如果默认启用诊断,则为 True。

description
LocalizableString

诊断的可选较长可本地化说明。

helpLinkUri
String

一个可选超链接,提供有关诊断的更详细说明。

customTags
String[]

诊断的可选自定义标记。 有关一些已知标记,请参阅 WellKnownDiagnosticTags

注解

规则 CA1001 的示例描述符:

internal static DiagnosticDescriptor Rule = new DiagnosticDescriptor(RuleId,
    new LocalizableResourceString(nameof(FxCopRulesResources.TypesThatOwnDisposableFieldsShouldBeDisposable), FxCopRulesResources.ResourceManager, typeof(FxCopRulesResources)),
    new LocalizableResourceString(nameof(FxCopRulesResources.TypeOwnsDisposableFieldButIsNotDisposable), FxCopRulesResources.ResourceManager, typeof(FxCopRulesResources)),
    FxCopDiagnosticCategory.Design,
    DiagnosticSeverity.Warning,
    isEnabledByDefault: true,
    helpLinkUri: "http://msdn.microsoft.com/library/ms182172.aspx",
    customTags: DiagnosticCustomTags.Microsoft);

选择适当的诊断 ID ,使其唯一。

适用于

DiagnosticDescriptor(String, String, String, String, DiagnosticSeverity, Boolean, String, String, String[])

Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs
Source:
DiagnosticDescriptor.cs

创建 DiagnosticDescriptor,用于提供有关 的说明 Diagnostic。 注意:对于可本地化的 titledescription 和/或 messageFormat,请使用构造函数重载 DiagnosticDescriptor(String, LocalizableString, LocalizableString, String, DiagnosticSeverity, Boolean, LocalizableString, String, String[])

public DiagnosticDescriptor (string id, string title, string messageFormat, string category, Microsoft.CodeAnalysis.DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, string description = default, string helpLinkUri = default, params string[] customTags);
public DiagnosticDescriptor (string id, string title, string messageFormat, string category, Microsoft.CodeAnalysis.DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, string? description = default, string? helpLinkUri = default, params string[] customTags);
new Microsoft.CodeAnalysis.DiagnosticDescriptor : string * string * string * string * Microsoft.CodeAnalysis.DiagnosticSeverity * bool * string * string * string[] -> Microsoft.CodeAnalysis.DiagnosticDescriptor
Public Sub New (id As String, title As String, messageFormat As String, category As String, defaultSeverity As DiagnosticSeverity, isEnabledByDefault As Boolean, Optional description As String = Nothing, Optional helpLinkUri As String = Nothing, ParamArray customTags As String())

参数

id
String

诊断的唯一标识符。 例如,代码分析诊断 ID“CA1001”。

title
String

描述诊断的简短标题。 例如,对于 CA1001:“拥有可释放字段的类型应是可释放的”。

messageFormat
String

格式消息字符串,在使用此描述符创建诊断消息时,可以将其作为第一个参数 Format(String, Object[]) 传递给 。 例如,对于 CA1001:“在''{0}上实现 IDisposable,因为它创建以下 IDisposable 类型的成员:'{1}'。”

category
String

诊断 ((如设计、命名等)的类别 ) 。 例如,对于 CA1001:“Microsoft.Design”。

defaultSeverity
DiagnosticSeverity

诊断的默认严重性。

isEnabledByDefault
Boolean

如果默认启用诊断,则为 True。

description
String

诊断的可选较长说明。

helpLinkUri
String

一个可选超链接,提供有关诊断的更详细说明。

customTags
String[]

诊断的可选自定义标记。 有关一些已知标记,请参阅 WellKnownDiagnosticTags

注解

选择适当的诊断 ID ,使其唯一。

适用于