DiagnosticDescriptor Constructors

Definition

Overloads

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

Create a DiagnosticDescriptor, which provides description about a Diagnostic.

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

Create a DiagnosticDescriptor, which provides description about a Diagnostic. NOTE: For localizable title, description and/or messageFormat, use constructor overload 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

Create a DiagnosticDescriptor, which provides description about a 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())

Parameters

id
String

A unique identifier for the diagnostic. For example, code analysis diagnostic ID "CA1001".

title
LocalizableString

A short localizable title describing the diagnostic. For example, for CA1001: "Types that own disposable fields should be disposable".

messageFormat
LocalizableString

A localizable format message string, which can be passed as the first argument to Format(String, Object[]) when creating the diagnostic message with this descriptor. For example, for CA1001: "Implement IDisposable on '{0}' because it creates members of the following IDisposable types: '{1}'."

category
String

The category of the diagnostic (like Design, Naming etc.). For example, for CA1001: "Microsoft.Design".

defaultSeverity
DiagnosticSeverity

Default severity of the diagnostic.

isEnabledByDefault
Boolean

True if the diagnostic is enabled by default.

description
LocalizableString

An optional longer localizable description of the diagnostic.

helpLinkUri
String

An optional hyperlink that provides a more detailed description regarding the diagnostic.

customTags
String[]

Optional custom tags for the diagnostic. See WellKnownDiagnosticTags for some well known tags.

Remarks

Example descriptor for rule 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);

Choose an appropriate diagnostic ID such that it is unique.

Applies to

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

Create a DiagnosticDescriptor, which provides description about a Diagnostic. NOTE: For localizable title, description and/or messageFormat, use constructor overload 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())

Parameters

id
String

A unique identifier for the diagnostic. For example, code analysis diagnostic ID "CA1001".

title
String

A short title describing the diagnostic. For example, for CA1001: "Types that own disposable fields should be disposable".

messageFormat
String

A format message string, which can be passed as the first argument to Format(String, Object[]) when creating the diagnostic message with this descriptor. For example, for CA1001: "Implement IDisposable on '{0}' because it creates members of the following IDisposable types: '{1}'."

category
String

The category of the diagnostic (like Design, Naming etc.). For example, for CA1001: "Microsoft.Design".

defaultSeverity
DiagnosticSeverity

Default severity of the diagnostic.

isEnabledByDefault
Boolean

True if the diagnostic is enabled by default.

description
String

An optional longer description of the diagnostic.

helpLinkUri
String

An optional hyperlink that provides a more detailed description regarding the diagnostic.

customTags
String[]

Optional custom tags for the diagnostic. See WellKnownDiagnosticTags for some well known tags.

Remarks

Choose an appropriate diagnostic ID such that it is unique.

Applies to