Defines a diagnostic that does not accept any parameters. For diagnostics with parameters, use DiagnosticDefinition<T>.
Namespace: Metalama.Framework.Diagnostics
Assembly: Metalama.Framework.dll
Syntax
public sealed class DiagnosticDefinition : DiagnosticDefinition<None>, IDiagnosticDefinition, IDiagnosticRemarks
Diagnostic definitions must be declared as static fields in compile-time classes (such as aspect classes, fabric classes, or other compile-time helper classes) and include a unique ID, severity level, and message format string. The aspect framework requires diagnostics to be defined this way to ensure they can be properly detected by static analysis of the code.
This class implements both IDiagnosticDefinition and IDiagnostic, which means
instances can be used directly with Report(IDiagnostic) without needing
to call WithArguments.
Examples
private static readonly DiagnosticDefinition _missingFieldError = new(
"MY001",
Severity.Error,
"The type must have a field named '_logger'.");
// In BuildAspect:
builder.Diagnostics.Report(_missingFieldError);
Constructors
| Name | Description |
|---|---|
| DiagnosticDefinition(string, Severity, string, string?, string?) |
Methods
| Name | Description |
|---|---|
| WithExtensions(ImmutableArray<IDiagnosticExtension>) |