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
HasErrors
Gets a value indicating whether at least one error diagnostic is present.
public bool HasErrors { get; }
Property Value
Methods
Add(ParserDiagnostic)
Adds a diagnostic instance to the bag.
public void Add(ParserDiagnostic diagnostic)
Parameters
diagnosticParserDiagnosticDiagnostic to add.
Add(ParserDiagnosticDescriptor, params object?[])
Creates and adds a diagnostic from a descriptor.
public ParserDiagnostic Add(ParserDiagnosticDescriptor descriptor, params object?[] arguments)
Parameters
descriptorParserDiagnosticDescriptorDiagnostic descriptor.
argumentsobject[]Message format arguments.
Returns
- ParserDiagnostic
The added diagnostic.
AddRange(IEnumerable<ParserDiagnostic>)
Adds all diagnostics from another sequence.
public void AddRange(IEnumerable<ParserDiagnostic> diagnostics)
Parameters
diagnosticsIEnumerable<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
descriptorParserDiagnosticDescriptorDiagnostic descriptor.
spanStartint?Optional source span start.
spanLengthint?Optional source span length.
ruleNamestringOptional rule context.
exceptionExceptionOptional related exception.
argumentsobject[]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
descriptorParserDiagnosticDescriptorDiagnostic descriptor.
spanDiagnosticSpanOptional source span.
locationSourceCodeLocationOptional source location.
ruleNamestringOptional rule context.
exceptionExceptionOptional related exception.
argumentsobject[]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
severityDiagnosticSeverityMinimum severity threshold.
Returns
- IReadOnlyList<ParserDiagnostic>
Filtered diagnostics.
GetEnumerator()
public IEnumerator<ParserDiagnostic> GetEnumerator()
Returns
ToList()
Returns a read-only snapshot of the diagnostics.
public IReadOnlyList<ParserDiagnostic> ToList()
Returns
- IReadOnlyList<ParserDiagnostic>
Snapshot list.