Table of Contents

Class ShaderError

Namespace
ShadowDusk.Core
Assembly
ShadowDusk.Core.dll

A single diagnostic produced during compilation, carrying the source location and the underlying compiler's message verbatim. Errors are returned (never swallowed or reformatted) so callers can surface the exact file, line, column, and message.

public sealed record ShaderError : IEquatable<ShaderError>
Inheritance
ShaderError
Implements
Inherited Members

Constructors

ShaderError(string, int, int, string, string, ShaderErrorSeverity, ShaderErrorKind, string?, int, string?, IReadOnlyList<string>?, string?)

A single diagnostic produced during compilation, carrying the source location and the underlying compiler's message verbatim. Errors are returned (never swallowed or reformatted) so callers can surface the exact file, line, column, and message.

public ShaderError(string File, int Line, int Column, string Code, string Message, ShaderErrorSeverity Severity = ShaderErrorSeverity.Error, ShaderErrorKind Kind = ShaderErrorKind.Compile, string? IncludingFilePath = null, int IncludingLineNumber = 0, string? RequestedPath = null, IReadOnlyList<string>? SearchedPaths = null, string? RawDiagnostics = null)

Parameters

File string

The source file the diagnostic refers to.

Line int

The 1-based line number, or 0 when not applicable.

Column int

The 1-based column number, or 0 when not applicable.

Code string

The diagnostic code (e.g. SD0001 or an underlying compiler code).

Message string

The human-readable diagnostic message.

Severity ShaderErrorSeverity

The severity; defaults to Error.

Kind ShaderErrorKind

The kind of failure; defaults to Compile.

IncludingFilePath string

For include errors, the file that issued the #include.

IncludingLineNumber int

For include errors, the line of the #include directive.

RequestedPath string

For include errors, the path that was requested.

SearchedPaths IReadOnlyList<string>

For IncludeNotFound, the directories searched.

RawDiagnostics string

The raw, unparsed diagnostic text from the underlying compiler, when available.

Do not forward this verbatim to an untrusted caller. It is the compiler's own output, so it can contain host absolute paths and echoed source lines — including lines from any file the shader pulled in with #include, which (matching mgfxc/fxc) resolves relative paths without restricting them to the source directory. That is harmless when you compile your own shaders; if you compile shaders you did not write, and publish the diagnostics (a CI log, a hosted compile service), treat this field as untrusted output and log Message alone.

Properties

Code

The diagnostic code (e.g. SD0001 or an underlying compiler code).

public string Code { get; init; }

Property Value

string

Column

The 1-based column number, or 0 when not applicable.

public int Column { get; init; }

Property Value

int

File

The source file the diagnostic refers to.

public string File { get; init; }

Property Value

string

FxcFormattedMessage

The diagnostic rendered in the fxc/mgfxc message format (file(line,col-col): severity code: message), so MGCB and IDEs can parse it.

public string FxcFormattedMessage { get; }

Property Value

string

HasAdditionalRawDiagnostics

Whether RawDiagnostics says something beyond Message and is therefore worth printing a second time under the one-line summary. False for the two cases where it would be pure duplication: no raw text at all, or a single located diagnostic line whose tail already IS Message (the common single-error compile failure — the underlying compiler's one line was already fully absorbed into Message/FxcFormattedMessage). True for everything else, notably a multi-line raw blob (other diagnostics, e.g. a leading warning before the error that failed the compile, or source-echo/caret context) and the "no location parsed" verbatim path once Message stops matching it exactly.

public bool HasAdditionalRawDiagnostics { get; }

Property Value

bool

IncludingFilePath

For include errors, the file that issued the #include.

public string? IncludingFilePath { get; init; }

Property Value

string

IncludingLineNumber

For include errors, the line of the #include directive.

public int IncludingLineNumber { get; init; }

Property Value

int

Kind

The kind of failure; defaults to Compile.

public ShaderErrorKind Kind { get; init; }

Property Value

ShaderErrorKind

Line

The 1-based line number, or 0 when not applicable.

public int Line { get; init; }

Property Value

int

Message

The human-readable diagnostic message.

public string Message { get; init; }

Property Value

string

RawDiagnostics

The raw, unparsed diagnostic text from the underlying compiler, when available.

Do not forward this verbatim to an untrusted caller. It is the compiler's own output, so it can contain host absolute paths and echoed source lines — including lines from any file the shader pulled in with #include, which (matching mgfxc/fxc) resolves relative paths without restricting them to the source directory. That is harmless when you compile your own shaders; if you compile shaders you did not write, and publish the diagnostics (a CI log, a hosted compile service), treat this field as untrusted output and log Message alone.

public string? RawDiagnostics { get; init; }

Property Value

string

RequestedPath

For include errors, the path that was requested.

public string? RequestedPath { get; init; }

Property Value

string

SearchedPaths

For IncludeNotFound, the directories searched.

public IReadOnlyList<string>? SearchedPaths { get; init; }

Property Value

IReadOnlyList<string>

Severity

The severity; defaults to Error.

public ShaderErrorSeverity Severity { get; init; }

Property Value

ShaderErrorSeverity

Methods

CircularInclude(string, int, string)

Creates a CircularInclude error (code SD0002) for a detected #include cycle.

public static ShaderError CircularInclude(string includingFile, int line, string requested)

Parameters

includingFile string

The file that issued the cyclic #include.

line int

The line of the #include directive.

requested string

The include path that re-entered the cycle.

Returns

ShaderError

IncludeNotFound(string, int, string, IReadOnlyList<string>)

Creates an IncludeNotFound error (code SD0001) for an #include that could not be resolved on any search path.

public static ShaderError IncludeNotFound(string includingFile, int line, string requested, IReadOnlyList<string> searched)

Parameters

includingFile string

The file that issued the #include.

line int

The line of the #include directive.

requested string

The include path that was requested.

searched IReadOnlyList<string>

The directories that were searched.

Returns

ShaderError