Table of Contents

Class ShaderFormatDetector

Namespace
ShadowDusk.Core
Assembly
ShadowDusk.Core.dll

Identifies a shader's source language from its text alone, so callers that receive a shader from a stream, a byte buffer, or a package whose files lost their extensions can still route it. It is a cheap structural check on comment- and string-stripped text, never a parse or a compile: the frontend that receives the shader does the real validation and fails loudly if the guess was wrong.

public static class ShaderFormatDetector
Inheritance
ShaderFormatDetector
Inherited Members

Remarks

Rules, in order:

  1. A technique block AND a GLSL entry (mainImage, or a parameterless void main()): ambiguous, unless the name hint's extension picks one side.
  2. A technique block: FxEffect. This wins over Slang markers, because HLSL-compatible Slang with a technique block compiles as an effect.
  3. A [shader("...")] attribute, or a line-leading import x; / module x;: Slang.
  4. A GLSL entry: Glsl.
  5. No signal: the name hint's extension if it names a format, else Unknown.

The name hint never overrides a content signal; it only settles rules 1 and 5. Recognized hint extensions: .fx; .slang; .glsl, .frag, .fs, .glslf.

Methods

Detect(string, string?)

Detects the source language of source. Never throws for any input text; a null source throws ArgumentNullException.

public static ShaderFormatDetection Detect(string source, string? nameHint = null)

Parameters

source string

The shader source text.

nameHint string

Optional file name or path. Only its extension is read, and only to settle ambiguous content or content with no signal at all.

Returns

ShaderFormatDetection