Open sandboxFocus

Struct ScopedDiagnosticSink

A diagnostic sink that combines an IDiagnosticSink with default target location and declaration, simplifying diagnostic reporting and suppression.

Namespace: Metalama.Framework.Diagnostics
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public readonly struct ScopedDiagnosticSink : IScopedDiagnosticSink
Remarks

This struct maintains a default target location and declaration, allowing diagnostics and suppressions to be reported without explicitly specifying where they apply. This is the primary way aspect code interacts with the diagnostic system, accessed via Diagnostics.

The Report(IDiagnostic) method reports a diagnostic to the default location, while the Suppress(ISuppression) method suppresses diagnostics within the default declaration scope. Overloads allow specifying different locations or scopes when needed.

Constructors

Name Description
ScopedDiagnosticSink(IDiagnosticSink, IDiagnosticSource, IDiagnosticLocation?, IDeclaration?)

Initializes a new instance of the ScopedDiagnosticSink struct.

Properties

Name Description
DefaultTargetDeclaration

Gets the declaration on which diagnostics or code fixes will be reported or suppressed.

DefaultTargetLocation

Gets the location on which diagnostics or code fixes will be reported or suppressed.

Sink

Gets the underlying diagnostic sink.

Source

Gets the source of diagnostics, suppressions, or code fixes.

Methods

Name Description
Report(IDiagnostic)

Reports a diagnostic to the default location of this scoped sink.

Report(IDiagnostic, IDiagnosticLocation?)

Reports a diagnostic to a specific location instead of the default location.

Suppress(ISuppression)

Suppresses a diagnostic within the default declaration scope of this scoped sink.

Suppress(ISuppression, IDeclaration)

Suppresses a diagnostic within a specific declaration scope instead of the default scope.

See Also