This is namespace allows you to report or suppress diagnostics from your aspect code.
To report a diagnostic, you must first define a static field of type DiagnosticDefinition or DiagnosticDefinition<T> in your aspect class. The type DiagnosticDefinition must be used for parameterless diagnostics, and DiagnosticDefinition<T> for parametric diagnostics.
To report a parametric diagnostics, you must first call the WithArguments method. This step is not necessary with parameterless diagnostics.
To report a diagnostic, call the Report method. This object is exposed on the Diagnostics property of the argument of the IAspectBuilder.BuildAspect method of your aspect. You can also report a diagnostic from a validator.
When you are reporting a diagnostic, you can specify the location of the diagnostic, i.e. the element of code to which it will be reported (which determines the file and line of the error message). If you do not specify the location, the default location for the current context will be used.
You can add code fixes to diagnostics. For details, see the Metalama.Framework.CodeFixes namespace.
To suppress of diagnostic, you must first define it as a static field of type SuppressionDefinition in your aspect class. You can then suppress a diagnostic from any declaration from an aspect using the Suppress method.
For more information, see Reporting and Suppressing Diagnostics.
Suggesting code actions
Defines a diagnostic that does not accept any parameters. For a diagnostic that accepts parameters, use DiagnosticDefinition<T>.
Defines a diagnostic with a strongly-typed set of parameters that are typically specified by using a named tuple for generic parameter
T. For diagnostics that accept a single parameter,
T must be set to the type of this parameter.
To accept several parameters, use a tuple.
For a diagnostic that does not accept parameters, use DiagnosticDefinition.
A type to be used as generic argument of DiagnosticDefinition<T> when there is no parameter in the message.
Encapsulates an IDiagnosticSink and the default target of diagnostics, suppressions, and code fixes.
Severity of diagnostics.
Defines the suppression of a kind of diagnostics. Suppressions must be defined as static fields or properties of an aspect classes. Suppressions are instantiated with Suppress(SuppressionDefinition, IDeclaration).
Represents an instance of a diagnostic, including its parameters and its optional code fixes.
A non-generic base interface for DiagnosticDefinition<T>.
A base interface for objects to which a diagnostic can be reported.
A sink that reports diagnostics reported from user code.