Table of Contents

Class Preprocessor

Namespace
ShadowDusk.Core.Preprocessor
Assembly
ShadowDusk.Core.dll

Flattens an HLSL source tree by expanding all #include directives (honoring #pragma once and detecting circular includes) and prepending the platform macros, producing a single self-contained PreprocessedSource for the compiler.

public sealed class Preprocessor
Inheritance
Preprocessor
Inherited Members

Constructors

Preprocessor()

Creates a preprocessor that asks the real file system how it spells resolved include paths.

public Preprocessor()

Preprocessor(IIncludePathCanonicalizer)

Creates a preprocessor with an explicit IIncludePathCanonicalizer.

public Preprocessor(IIncludePathCanonicalizer pathCanonicalizer)

Parameters

pathCanonicalizer IIncludePathCanonicalizer

Decides whether two case-only path variants name the same file, and supplies the on-disk spelling the SD0008 portability warning reports. Injectable so both file-system behaviours (case-sensitive, as on Android and Linux and case-sensitive APFS; and case-insensitive, as on a default Windows or macOS volume) can be driven from a pure unit test on any host.

Methods

Flatten(string, string, MacroSet, IIncludeResolver, IReadOnlyList<string>)

Expands all includes in the source and prepends the platform macros.

public Result<PreprocessedSource, ShaderError> Flatten(string cleanedHlsl, string originalFilePath, MacroSet macros, IIncludeResolver includeResolver, IReadOnlyList<string> additionalPaths)

Parameters

cleanedHlsl string

The HLSL entry source (comments may still be present; the include scanner is comment-aware and ignores directives inside them).

originalFilePath string

The entry source's path, used for diagnostics and relative includes.

macros MacroSet

The platform macros to prepend.

includeResolver IIncludeResolver

The resolver used to fetch #include targets.

additionalPaths IReadOnlyList<string>

Extra include search directories.

Returns

Result<PreprocessedSource, ShaderError>

The flattened source on success (carrying any non-fatal Warnings), or a ShaderError on a missing or circular include.