共用方式為


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。 注意:針對可 title本地化的、 description 和/或 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

診斷的唯一標識碼。 例如,程式代碼分析診斷標識碼 「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);

選擇適當的診斷標識碼 ,使其是唯一的。

適用於

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。 注意:針對可 title本地化的、 description 和/或 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

診斷的唯一標識碼。 例如,程式代碼分析診斷標識碼 「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

備註

選擇適當的診斷標識碼 ,使其是唯一的。

適用於