Struct Diagnostic
Represents a diagnostic message produced during code generation.
public readonly record struct Diagnostic : IEquatable<Diagnostic>
- Implements
- Inherited Members
Properties
IsError
Returns whether this diagnostic represents an error.
public bool IsError { get; }
Property Value
Methods
AddNote(string, string?)
Adds the provided message to this diagnostic as a note.
public void AddNote(string message, string? source = null)
Parameters
messagestringThe message to add as a note.
sourcestringThe source location associated with this note, if any.
Error(string, string?)
Creates a new diagnostic to describe a general error.
public static Diagnostic Error(string message, string? source = null)
Parameters
messagestringA message describing the error.
sourcestringThe source location associated with this diagnostic, if any.
Returns
- Diagnostic
A new diagnostic.
IncorrectAttributeArgumentCount(string, int, int, string)
Creates a new diagnostic to describe an attribute with an incorrect number of arguments.
public static Diagnostic IncorrectAttributeArgumentCount(string directive, int expected, int actual, string source)
Parameters
directivestringThe directive of the attribute that had an incorrect number of arguments.
expectedintThe correct number of arguments that should have been supplied to this attribute.
actualintThe actual number of arguments that were supplied to this attribute.
sourcestringThe source location of the attribute with an incorrect number of arguments.
Returns
- Diagnostic
A new diagnostic.
InvalidAttribute(string, string)
Creates a new diagnostic to describe an attribute which was invalidly applied to an element.
public static Diagnostic InvalidAttribute(string directive, string source)
Parameters
directivestringThe directive of the attribute that was invalid.
sourcestringThe source location of the invalid attribute.
Returns
- Diagnostic
A new diagnostic.
MissingRequiredAttribute(string, string)
Creates a new diagnostic to describe a required attribute which was not present.
public static Diagnostic MissingRequiredAttribute(string expectedAttribute, string source)
Parameters
expectedAttributestringAn example of the attribute that was required but missing.
sourcestringThe source location of the Slice construct that was missing the required attribute.
Returns
- Diagnostic
A new diagnostic.
UnknownAttribute(string, string)
Creates a new diagnostic to describe an unknown attribute.
public static Diagnostic UnknownAttribute(string directive, string source)
Parameters
directivestringThe directive of the attribute that was unknown.
sourcestringThe source location of the unknown attribute.
Returns
- Diagnostic
A new diagnostic.