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
FilestringThe source file the diagnostic refers to.
LineintThe 1-based line number, or 0 when not applicable.
ColumnintThe 1-based column number, or 0 when not applicable.
CodestringThe diagnostic code (e.g.
SD0001or an underlying compiler code).MessagestringThe human-readable diagnostic message.
SeverityShaderErrorSeverityThe severity; defaults to Error.
KindShaderErrorKindThe kind of failure; defaults to Compile.
IncludingFilePathstringFor include errors, the file that issued the
#include.IncludingLineNumberintFor include errors, the line of the
#includedirective.RequestedPathstringFor include errors, the path that was requested.
SearchedPathsIReadOnlyList<string>For IncludeNotFound, the directories searched.
RawDiagnosticsstringThe 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 (matchingmgfxc/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
Column
The 1-based column number, or 0 when not applicable.
public int Column { get; init; }
Property Value
File
The source file the diagnostic refers to.
public string File { get; init; }
Property Value
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
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
IncludingFilePath
For include errors, the file that issued the #include.
public string? IncludingFilePath { get; init; }
Property Value
IncludingLineNumber
For include errors, the line of the #include directive.
public int IncludingLineNumber { get; init; }
Property Value
Kind
The kind of failure; defaults to Compile.
public ShaderErrorKind Kind { get; init; }
Property Value
Line
The 1-based line number, or 0 when not applicable.
public int Line { get; init; }
Property Value
Message
The human-readable diagnostic message.
public string Message { get; init; }
Property Value
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
RequestedPath
For include errors, the path that was requested.
public string? RequestedPath { get; init; }
Property Value
SearchedPaths
For IncludeNotFound, the directories searched.
public IReadOnlyList<string>? SearchedPaths { get; init; }
Property Value
Severity
The severity; defaults to Error.
public ShaderErrorSeverity Severity { get; init; }
Property Value
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
includingFilestringThe file that issued the cyclic
#include.lineintThe line of the
#includedirective.requestedstringThe include path that re-entered the cycle.
Returns
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
includingFilestringThe file that issued the
#include.lineintThe line of the
#includedirective.requestedstringThe include path that was requested.
searchedIReadOnlyList<string>The directories that were searched.