Search Results for

    Show / Hide Table of Contents

    Class Diagnostic

    Represents a diagnostic, such as a compiler error or a warning, along with the location where it occurred.

    Inheritance
    System.Object
    Diagnostic
    Implements
    IFormattable
    Namespace: Loretta.CodeAnalysis
    Assembly: Loretta.CodeAnalysis.dll
    Syntax
    public abstract class Diagnostic : IEquatable<Diagnostic>

    Properties

    | Improve this Doc View Source

    AdditionalLocations

    Gets an array of additional locations related to the diagnostic. Typically these are the locations of other items referenced in the message.

    Declaration
    public abstract IReadOnlyList<Location> AdditionalLocations { get; }
    Property Value
    Type Description
    IReadOnlyList<Location>
    | Improve this Doc View Source

    DefaultSeverity

    Gets the default DiagnosticSeverity of the diagnostic's DiagnosticDescriptor.

    Declaration
    public virtual DiagnosticSeverity DefaultSeverity { get; }
    Property Value
    Type Description
    DiagnosticSeverity
    Remarks

    To get the effective severity of the diagnostic, use Severity.

    | Improve this Doc View Source

    Descriptor

    Gets the diagnostic descriptor, which provides a description about a Diagnostic.

    Declaration
    public abstract DiagnosticDescriptor Descriptor { get; }
    Property Value
    Type Description
    DiagnosticDescriptor
    | Improve this Doc View Source

    Id

    Gets the diagnostic identifier. For diagnostics generated by the compiler, this will be a numeric code with a prefix such as "CS1001".

    Declaration
    public abstract string Id { get; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    IsSuppressed

    Returns true if the diagnostic has a source suppression, i.e. an attribute or a pragma suppression.

    Declaration
    public abstract bool IsSuppressed { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsWarningAsError

    Returns true if this is a warning treated as an error; otherwise false.

    Declaration
    public bool IsWarningAsError { get; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    True implies DefaultSeverity = Warning and Severity = Error.

    | Improve this Doc View Source

    Location

    Gets the primary location of the diagnostic, or None if no primary location.

    Declaration
    public abstract Location Location { get; }
    Property Value
    Type Description
    Location
    | Improve this Doc View Source

    Properties

    Gets property bag for the diagnostic. it will return if there is no entry. This can be used to put diagnostic specific information you want to pass around. for example, to corresponding fixer.

    Declaration
    public virtual ImmutableDictionary<string, string> Properties { get; }
    Property Value
    Type Description
    ImmutableDictionary<System.String, System.String>
    | Improve this Doc View Source

    Severity

    Gets the effective DiagnosticSeverity of the diagnostic.

    Declaration
    public abstract DiagnosticSeverity Severity { get; }
    Property Value
    Type Description
    DiagnosticSeverity
    Remarks

    To get the default severity of diagnostic's DiagnosticDescriptor, use DefaultSeverity. To determine if this is a warning treated as an error, use IsWarningAsError.

    | Improve this Doc View Source

    WarningLevel

    Gets the warning level. This is 0 for diagnostics with severity Error, otherwise an integer greater than zero.

    Declaration
    public abstract int WarningLevel { get; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    Create(DiagnosticDescriptor, Location, DiagnosticSeverity, Nullable<IEnumerable<Location>>, Nullable<ImmutableDictionary<String, String>>, Object[])

    Creates a Diagnostic instance.

    Declaration
    public static Diagnostic Create(DiagnosticDescriptor descriptor, Location location, DiagnosticSeverity effectiveSeverity, IEnumerable<Location>? additionalLocations, ImmutableDictionary<string, string>? properties, params object[] messageArgs)
    Parameters
    Type Name Description
    DiagnosticDescriptor descriptor

    A DiagnosticDescriptor describing the diagnostic.

    Location location

    An optional primary location of the diagnostic. If null, Location will return None.

    DiagnosticSeverity effectiveSeverity

    Effective severity of the diagnostic.

    System.Nullable<IEnumerable<Location>> additionalLocations

    An optional set of additional locations related to the diagnostic. Typically, these are locations of other items referenced in the message. If null, AdditionalLocations will return an empty list.

    System.Nullable<ImmutableDictionary<System.String, System.String>> properties

    An optional set of name-value pairs by means of which the analyzer that creates the diagnostic can convey more detailed information to the fixer. If null, Properties will return .

    System.Object[] messageArgs

    Arguments to the message of the diagnostic.

    Returns
    Type Description
    Diagnostic

    The Diagnostic instance.

    | Improve this Doc View Source

    Create(DiagnosticDescriptor, Location, Nullable<IEnumerable<Location>>, Nullable<ImmutableDictionary<String, String>>, Object[])

    Creates a Diagnostic instance.

    Declaration
    public static Diagnostic Create(DiagnosticDescriptor descriptor, Location location, IEnumerable<Location>? additionalLocations, ImmutableDictionary<string, string>? properties, params object[] messageArgs)
    Parameters
    Type Name Description
    DiagnosticDescriptor descriptor

    A DiagnosticDescriptor describing the diagnostic.

    Location location

    An optional primary location of the diagnostic. If null, Location will return None.

    System.Nullable<IEnumerable<Location>> additionalLocations

    An optional set of additional locations related to the diagnostic. Typically, these are locations of other items referenced in the message. If null, AdditionalLocations will return an empty list.

    System.Nullable<ImmutableDictionary<System.String, System.String>> properties

    An optional set of name-value pairs by means of which the analyzer that creates the diagnostic can convey more detailed information to the fixer. If null, Properties will return .

    System.Object[] messageArgs

    Arguments to the message of the diagnostic.

    Returns
    Type Description
    Diagnostic

    The Diagnostic instance.

    | Improve this Doc View Source

    Create(DiagnosticDescriptor, Location, Nullable<IEnumerable<Location>>, Object[])

    Creates a Diagnostic instance.

    Declaration
    public static Diagnostic Create(DiagnosticDescriptor descriptor, Location location, IEnumerable<Location>? additionalLocations, params object[] messageArgs)
    Parameters
    Type Name Description
    DiagnosticDescriptor descriptor

    A DiagnosticDescriptor describing the diagnostic.

    Location location

    An optional primary location of the diagnostic. If null, Location will return None.

    System.Nullable<IEnumerable<Location>> additionalLocations

    An optional set of additional locations related to the diagnostic. Typically, these are locations of other items referenced in the message. If null, AdditionalLocations will return an empty list.

    System.Object[] messageArgs

    Arguments to the message of the diagnostic.

    Returns
    Type Description
    Diagnostic

    The Diagnostic instance.

    | Improve this Doc View Source

    Create(DiagnosticDescriptor, Location, Nullable<ImmutableDictionary<String, String>>, Object[])

    Creates a Diagnostic instance.

    Declaration
    public static Diagnostic Create(DiagnosticDescriptor descriptor, Location location, ImmutableDictionary<string, string>? properties, params object[] messageArgs)
    Parameters
    Type Name Description
    DiagnosticDescriptor descriptor

    A DiagnosticDescriptor describing the diagnostic.

    Location location

    An optional primary location of the diagnostic. If null, Location will return None.

    System.Nullable<ImmutableDictionary<System.String, System.String>> properties

    An optional set of name-value pairs by means of which the analyzer that creates the diagnostic can convey more detailed information to the fixer. If null, Properties will return .

    System.Object[] messageArgs

    Arguments to the message of the diagnostic.

    Returns
    Type Description
    Diagnostic

    The Diagnostic instance.

    | Improve this Doc View Source

    Create(DiagnosticDescriptor, Location, Object[])

    Creates a Diagnostic instance.

    Declaration
    public static Diagnostic Create(DiagnosticDescriptor descriptor, Location location, params object[] messageArgs)
    Parameters
    Type Name Description
    DiagnosticDescriptor descriptor

    A DiagnosticDescriptor describing the diagnostic

    Location location

    An optional primary location of the diagnostic. If null, Location will return None.

    System.Object[] messageArgs

    Arguments to the message of the diagnostic

    Returns
    Type Description
    Diagnostic

    The Diagnostic instance.

    | Improve this Doc View Source

    Create(String, String, LocalizableString, DiagnosticSeverity, DiagnosticSeverity, Boolean, Int32, LocalizableString, LocalizableString, String, Location, Nullable<IEnumerable<Location>>, Nullable<IEnumerable<String>>, Nullable<ImmutableDictionary<String, String>>)

    Creates a Diagnostic instance which is localizable.

    Declaration
    public static Diagnostic Create(string id, string category, LocalizableString message, DiagnosticSeverity severity, DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, int warningLevel, LocalizableString title = null, LocalizableString description = null, string helpLink = null, Location location = null, IEnumerable<Location>? additionalLocations = null, IEnumerable<string>? customTags = null, ImmutableDictionary<string, string>? properties = null)
    Parameters
    Type Name Description
    System.String id

    An identifier for the diagnostic. For diagnostics generated by the compiler, this will be a numeric code with a prefix such as "CS1001".

    System.String category

    The category of the diagnostic. For diagnostics generated by the compiler, the category will be "Compiler".

    LocalizableString message

    The diagnostic message text.

    DiagnosticSeverity severity

    The diagnostic's effective severity.

    DiagnosticSeverity defaultSeverity

    The diagnostic's default severity.

    System.Boolean isEnabledByDefault

    True if the diagnostic is enabled by default

    System.Int32 warningLevel

    The warning level, between 1 and 4 if severity is Warning; otherwise 0.

    LocalizableString title

    An optional short localizable title describing the diagnostic.

    LocalizableString description

    An optional longer localizable description for the diagnostic.

    System.String helpLink

    An optional hyperlink that provides more detailed information regarding the diagnostic.

    Location location

    An optional primary location of the diagnostic. If null, Location will return None.

    System.Nullable<IEnumerable<Location>> additionalLocations

    An optional set of additional locations related to the diagnostic. Typically, these are locations of other items referenced in the message. If null, AdditionalLocations will return an empty list.

    System.Nullable<IEnumerable<System.String>> customTags

    An optional set of custom tags for the diagnostic. See WellKnownDiagnosticTags for some well known tags. If null, Loretta.CodeAnalysis.Diagnostic.CustomTags will return an empty list.

    System.Nullable<ImmutableDictionary<System.String, System.String>> properties

    An optional set of name-value pairs by means of which the analyzer that creates the diagnostic can convey more detailed information to the fixer. If null, Properties will return .

    Returns
    Type Description
    Diagnostic

    The Diagnostic instance.

    | Improve this Doc View Source

    Create(String, String, LocalizableString, DiagnosticSeverity, DiagnosticSeverity, Boolean, Int32, Boolean, LocalizableString, LocalizableString, String, Location, Nullable<IEnumerable<Location>>, Nullable<IEnumerable<String>>, Nullable<ImmutableDictionary<String, String>>)

    Creates a Diagnostic instance which is localizable.

    Declaration
    public static Diagnostic Create(string id, string category, LocalizableString message, DiagnosticSeverity severity, DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, int warningLevel, bool isSuppressed, LocalizableString title = null, LocalizableString description = null, string helpLink = null, Location location = null, IEnumerable<Location>? additionalLocations = null, IEnumerable<string>? customTags = null, ImmutableDictionary<string, string>? properties = null)
    Parameters
    Type Name Description
    System.String id

    An identifier for the diagnostic. For diagnostics generated by the compiler, this will be a numeric code with a prefix such as "CS1001".

    System.String category

    The category of the diagnostic. For diagnostics generated by the compiler, the category will be "Compiler".

    LocalizableString message

    The diagnostic message text.

    DiagnosticSeverity severity

    The diagnostic's effective severity.

    DiagnosticSeverity defaultSeverity

    The diagnostic's default severity.

    System.Boolean isEnabledByDefault

    True if the diagnostic is enabled by default

    System.Int32 warningLevel

    The warning level, between 1 and 4 if severity is Warning; otherwise 0.

    System.Boolean isSuppressed

    Flag indicating whether the diagnostic is suppressed by a source suppression.

    LocalizableString title

    An optional short localizable title describing the diagnostic.

    LocalizableString description

    An optional longer localizable description for the diagnostic.

    System.String helpLink

    An optional hyperlink that provides more detailed information regarding the diagnostic.

    Location location

    An optional primary location of the diagnostic. If null, Location will return None.

    System.Nullable<IEnumerable<Location>> additionalLocations

    An optional set of additional locations related to the diagnostic. Typically, these are locations of other items referenced in the message. If null, AdditionalLocations will return an empty list.

    System.Nullable<IEnumerable<System.String>> customTags

    An optional set of custom tags for the diagnostic. See WellKnownDiagnosticTags for some well known tags. If null, Loretta.CodeAnalysis.Diagnostic.CustomTags will return an empty list.

    System.Nullable<ImmutableDictionary<System.String, System.String>> properties

    An optional set of name-value pairs by means of which the analyzer that creates the diagnostic can convey more detailed information to the fixer. If null, Properties will return .

    Returns
    Type Description
    Diagnostic

    The Diagnostic instance.

    | Improve this Doc View Source

    Equals(Diagnostic)

    Declaration
    public abstract bool Equals(Diagnostic obj)
    Parameters
    Type Name Description
    Diagnostic obj
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Equals(Object)

    Declaration
    public abstract override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    GetHashCode()

    Declaration
    public abstract override int GetHashCode()
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    GetMessage(Nullable<IFormatProvider>)

    Get the culture specific text of the message.

    Declaration
    public abstract string GetMessage(IFormatProvider? formatProvider = null)
    Parameters
    Type Name Description
    System.Nullable<IFormatProvider> formatProvider
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    Implements

    IFormattable
    • Improve this Doc
    • View Source
    ☀
    ☾
    In This Article
    Back to top

    Copyright (c) LorettaDevs

    Generated by DocFX

    ☀
    ☾