Table of Contents

Class DiagnosticBag

Namespace
Utils.Parser.Diagnostics
Assembly
Utils.Parser.Diagnostics.dll

Mutable collection of parser diagnostics.

public sealed class DiagnosticBag : IReadOnlyCollection<ParserDiagnostic>, IEnumerable<ParserDiagnostic>, IEnumerable
Inheritance
DiagnosticBag
Implements
Inherited Members
Extension Methods

Properties

Count

Gets the total diagnostic count.

public int Count { get; }

Property Value

int

HasErrors

Gets a value indicating whether at least one error diagnostic is present.

public bool HasErrors { get; }

Property Value

bool

Methods

Add(ParserDiagnostic)

Adds a diagnostic instance to the bag.

public void Add(ParserDiagnostic diagnostic)

Parameters

diagnostic ParserDiagnostic

Diagnostic to add.

Add(ParserDiagnosticDescriptor, params object?[])

Creates and adds a diagnostic from a descriptor.

public ParserDiagnostic Add(ParserDiagnosticDescriptor descriptor, params object?[] arguments)

Parameters

descriptor ParserDiagnosticDescriptor

Diagnostic descriptor.

arguments object[]

Message format arguments.

Returns

ParserDiagnostic

The added diagnostic.

AddRange(IEnumerable<ParserDiagnostic>)

Adds all diagnostics from another sequence.

public void AddRange(IEnumerable<ParserDiagnostic> diagnostics)

Parameters

diagnostics IEnumerable<ParserDiagnostic>

Diagnostics to append.

AddWithContext(ParserDiagnosticDescriptor, int?, int?, string?, Exception?, params object?[])

Creates and adds a diagnostic from a descriptor with contextual information.

public ParserDiagnostic AddWithContext(ParserDiagnosticDescriptor descriptor, int? spanStart, int? spanLength, string? ruleName, Exception? exception, params object?[] arguments)

Parameters

descriptor ParserDiagnosticDescriptor

Diagnostic descriptor.

spanStart int?

Optional source span start.

spanLength int?

Optional source span length.

ruleName string

Optional rule context.

exception Exception

Optional related exception.

arguments object[]

Message format arguments.

Returns

ParserDiagnostic

The added diagnostic.

AddWithStructuredContext(ParserDiagnosticDescriptor, DiagnosticSpan?, SourceCodeLocation?, string?, Exception?, params object?[])

Creates and adds a diagnostic from a descriptor with composed context objects.

public ParserDiagnostic AddWithStructuredContext(ParserDiagnosticDescriptor descriptor, DiagnosticSpan? span, SourceCodeLocation? location, string? ruleName, Exception? exception, params object?[] arguments)

Parameters

descriptor ParserDiagnosticDescriptor

Diagnostic descriptor.

span DiagnosticSpan

Optional source span.

location SourceCodeLocation

Optional source location.

ruleName string

Optional rule context.

exception Exception

Optional related exception.

arguments object[]

Message format arguments.

Returns

ParserDiagnostic

The added diagnostic.

GetAtLeast(DiagnosticSeverity)

Gets all diagnostics whose severity is at least as important as severity.

public IReadOnlyList<ParserDiagnostic> GetAtLeast(DiagnosticSeverity severity)

Parameters

severity DiagnosticSeverity

Minimum severity threshold.

Returns

IReadOnlyList<ParserDiagnostic>

Filtered diagnostics.

GetEnumerator()

public IEnumerator<ParserDiagnostic> GetEnumerator()

Returns

IEnumerator<ParserDiagnostic>

ToList()

Returns a read-only snapshot of the diagnostics.

public IReadOnlyList<ParserDiagnostic> ToList()

Returns

IReadOnlyList<ParserDiagnostic>

Snapshot list.