Class DiagnosticDescriptor
Provides a description about a Diagnostic
Inheritance
Namespace: Loretta.CodeAnalysis
Assembly: Loretta.CodeAnalysis.dll
Syntax
public sealed class DiagnosticDescriptor : IEquatable<DiagnosticDescriptor>
Constructors
| Improve this Doc View SourceDiagnosticDescriptor(String, LocalizableString, LocalizableString, String, DiagnosticSeverity, Boolean, LocalizableString, String, String[])
Create a DiagnosticDescriptor, which provides description about a Diagnostic.
Declaration
public DiagnosticDescriptor(string id, LocalizableString title, LocalizableString messageFormat, string category, DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, LocalizableString description = null, string helpLinkUri = null, params string[] customTags)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | A unique identifier for the diagnostic. For example, code analysis diagnostic ID "CA1001". |
LocalizableString | title | A short localizable title describing the diagnostic. For example, for CA1001: "Types that own disposable fields should be disposable". |
LocalizableString | messageFormat | A localizable format message string, which can be passed as the first argument to System.String.Format(System.String,System.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}'." |
System.String | category | The category of the diagnostic (like Design, Naming etc.). For example, for CA1001: "Microsoft.Design". |
DiagnosticSeverity | defaultSeverity | Default severity of the diagnostic. |
System.Boolean | isEnabledByDefault | True if the diagnostic is enabled by default. |
LocalizableString | description | An optional longer localizable description of the diagnostic. |
System.String | helpLinkUri | An optional hyperlink that provides a more detailed description regarding the diagnostic. |
System.String[] | customTags | 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);
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[]).
Declaration
public DiagnosticDescriptor(string id, string title, string messageFormat, string category, DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, string description = null, string helpLinkUri = null, params string[] customTags)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | A unique identifier for the diagnostic. For example, code analysis diagnostic ID "CA1001". |
System.String | title | A short title describing the diagnostic. For example, for CA1001: "Types that own disposable fields should be disposable". |
System.String | messageFormat | A format message string, which can be passed as the first argument to System.String.Format(System.String,System.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}'." |
System.String | category | The category of the diagnostic (like Design, Naming etc.). For example, for CA1001: "Microsoft.Design". |
DiagnosticSeverity | defaultSeverity | Default severity of the diagnostic. |
System.Boolean | isEnabledByDefault | True if the diagnostic is enabled by default. |
System.String | description | An optional longer description of the diagnostic. |
System.String | helpLinkUri | An optional hyperlink that provides a more detailed description regarding the diagnostic. |
System.String[] | customTags | Optional custom tags for the diagnostic. See WellKnownDiagnosticTags for some well known tags. |
Properties
| Improve this Doc View SourceCategory
The category of the diagnostic (like Design, Naming etc.)
Declaration
public string Category { get; }
Property Value
Type | Description |
---|---|
System.String |
CustomTags
Custom tags for the diagnostic.
Declaration
public IEnumerable<string> CustomTags { get; }
Property Value
Type | Description |
---|---|
IEnumerable<System.String> |
DefaultSeverity
The default severity of the diagnostic.
Declaration
public DiagnosticSeverity DefaultSeverity { get; }
Property Value
Type | Description |
---|---|
DiagnosticSeverity |
Description
An optional longer localizable description for the diagnostic.
Declaration
public LocalizableString Description { get; }
Property Value
Type | Description |
---|---|
LocalizableString |
HelpLinkUri
An optional hyperlink that provides more detailed information regarding the diagnostic.
Declaration
public string HelpLinkUri { get; }
Property Value
Type | Description |
---|---|
System.String |
Id
An unique identifier for the diagnostic.
Declaration
public string Id { get; }
Property Value
Type | Description |
---|---|
System.String |
IsEnabledByDefault
Returns true if the diagnostic is enabled by default.
Declaration
public bool IsEnabledByDefault { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MessageFormat
A localizable format message string, which can be passed as the first argument to System.String.Format(System.String,System.Object[]) when creating the diagnostic message with this descriptor.
Declaration
public LocalizableString MessageFormat { get; }
Property Value
Type | Description |
---|---|
LocalizableString |
Title
A short localizable title describing the diagnostic.
Declaration
public LocalizableString Title { get; }
Property Value
Type | Description |
---|---|
LocalizableString |
Methods
| Improve this Doc View SourceEquals(DiagnosticDescriptor)
Declaration
public bool Equals(DiagnosticDescriptor other)
Parameters
Type | Name | Description |
---|---|---|
DiagnosticDescriptor | other |
Returns
Type | Description |
---|---|
System.Boolean |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |