Table of Contents

ConfigurationDiagnostic Class

Definition

Namespace
Bodu.Text.Configuration
Assembly
Bodu.Text.Configuration.dll
Package
Bodu.Text.Configuration 1.0.0
Source
ConfigurationDiagnostic.cs

Represents a single diagnostic - informational message, warning, or recoverable error - produced while reading or resolving a configuration document.

public sealed class ConfigurationDiagnostic
Inheritance
ConfigurationDiagnostic
Inherited Members
Extension Methods

Examples

// Surface every diagnostic the reader produced and tag any errors for caller attention.
foreach (ConfigurationDiagnostic d in result.Diagnostics)
{
    Console.WriteLine(d); // "Warning DuplicateKey at line 12, column 3: ..."
    if (d.Severity == ConfigurationDiagnosticSeverity.Error)
        hasErrors = true;
}

// Build one directly - useful when a host integrates Bodu diagnostics into its own pipeline.
var diag = new ConfigurationDiagnostic(
    ConfigurationDiagnosticSeverity.Warning,
    ConfigurationDiagnosticCode.UnknownKey,
    "Key 'format:legacy' is no longer recognized.",
    new ConfigurationSourceLocation(lineNumber: 7, linePosition: 1, length: 14));

Remarks

Diagnostics are immutable. When Collect is in effect, the reader gathers diagnostics on the parse result's diagnostics list rather than throwing at the first issue; the document is still produced and its valid portions remain usable.

Each diagnostic carries a stable Code from ConfigurationDiagnosticCode so that callers can suppress or escalate categories programmatically, a Severity for filtering, a human-readable Message for display, and a Location pointing back into the source document for editor integration. ToString() renders the four fields in a single line suitable for log output.

Constructors

ConfigurationDiagnostic(ConfigurationDiagnosticSeverity, ConfigurationDiagnosticCode, string, ConfigurationSourceLocation)

Initializes a new instance of the ConfigurationDiagnostic class with the specified severity, code, message, and location.

public ConfigurationDiagnostic(ConfigurationDiagnosticSeverity severity, ConfigurationDiagnosticCode code, string message, ConfigurationSourceLocation location)

Parameters

severity ConfigurationDiagnosticSeverity

The severity classification.

code ConfigurationDiagnosticCode

The stable code identifying the diagnostic category.

message string

The human-readable message text.

location ConfigurationSourceLocation

The location in the source document that produced the diagnostic.

Exceptions

ArgumentNullException

message is null.

Properties

Code

Gets the stable code that identifies the diagnostic category.

public ConfigurationDiagnosticCode Code { get; }

Property Value

ConfigurationDiagnosticCode

A ConfigurationDiagnosticCode value.

Location

Gets the location in the source document that produced this diagnostic.

public ConfigurationSourceLocation Location { get; }

Property Value

ConfigurationSourceLocation

The associated ConfigurationSourceLocation.

Message

Gets the human-readable message that describes this diagnostic.

public string Message { get; }

Property Value

string

A non-null message string.

Severity

Gets the severity classification for this diagnostic.

public ConfigurationDiagnosticSeverity Severity { get; }

Property Value

ConfigurationDiagnosticSeverity

The severity value supplied at construction.

Methods

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Applies to

ProductVersions
.NET8, 10