stride3d/stride · error · ArgumentException
Unknown qualifier
Error message
Unknown qualifier: {str} What it means
IntrinsicsDefinitions.FromString parses qualifier strings from intrinsic definitions into the Qualifier enum. Only 'in', 'out', 'inout' and 'ref' are accepted; anything else throws ArgumentException('Unknown qualifier: ...'). This is a fail-fast parser for the intrinsic table DSL.
Solutions
- Fix the input string to be exactly one of 'in', 'out', 'inout', 'ref' (lowercase, no whitespace) — e.g. Trim() tokens before calling FromString.
- If a new qualifier is genuinely needed, add an arm to the FromString switch in IntrinsicsParameters.cs.
- Intercept malformed lines in the intrinsics definition source and log/fix them before parsing.
Example fix
// before var q = IntrinsicsDefinitions.FromString(rawToken); // "InOut " -> ArgumentException // after var q = IntrinsicsDefinitions.FromString(rawToken.Trim().ToLowerInvariant());
Defensive patterns
Strategy: validation
Validate before calling
if (!str.Trim().EqualsInvariant("in") && !str.Trim().EqualsInvariant("out") &&
!str.Trim().EqualsInvariant("inout") && !str.Trim().EqualsInvariant("ref"))
throw new FormatException($"Qualifier must be in|out|inout|ref, got '{str}'"); Type guard
bool IsValidQualifier(string s) => s is "in" or "out" or "inout" or "ref";
Try / catch
try { qualifier = IntrinsicsDefinitions.FromString(token); }
catch (ArgumentException ex) when (ex.Message.StartsWith("Unknown qualifier:"))
{
logger.LogError("Bad qualifier token '{Token}' in intrinsics definition at line {Line}", token, lineNo);
throw;
} Prevention
- Trim and lowercase qualifier tokens parsed from definition files before dispatching.
- Keep a single normalization helper for qualifier strings instead of passing raw table text.
- Add a startup pass that parses all intrinsic definitions and reports every bad token with its source line.
When it happens
Trigger: Calling IntrinsicsDefinitions.FromString (directly or via intrinsic-table deserialization) with a string other than 'in'/'out'/'inout'/'ref' — e.g. 'inout ' with trailing whitespace, 'IN', 'InOut', 'const', or a malformed line in an intrinsics definition source that was split into a qualifier column.
Common situations: Hand-written intrinsic signature files containing a typo or uppercase qualifier; locale/language extensions ('inout' vs HLSL 'inout' is fine, but 'uniform' or 'static' are not qualifiers here); trimming bugs where whitespace survives into the token; new qualifier added to the enum but not to FromString.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown optional qualifier
- Unknown base type
- Could not find dependency
- Unexpected arguments
- Unable to load the given stream
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/c07b06be4a1e3580.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Core/IntrinsicsParameters.cs:100
public record struct Parameter(Qualifier? Qualifier, OptionalQualifier? OptionalQualifier, ParameterType Type, string Name);
public record class IntrinsicDefinition(ParameterType Return, Parameter[] Parameters)
{
public IntrinsicDefinition(ParameterType @return, params ReadOnlySpan<Parameter> parameters)
: this(@return, parameters.ToArray())
{ }
}
public static partial class IntrinsicsDefinitions
{
static Qualifier FromString(string str) => str switch
{
"in" => Qualifier.In,
"out" => Qualifier.Out,
"inout" => Qualifier.InOut,
"ref" => Qualifier.Ref,
_ => throw new ArgumentException($"Unknown qualifier: {str}"),
};
static OptionalQualifier FromStringOptional(string str) => str switch
{
"row_major" => OptionalQualifier.RowMajor,
"col_major" => OptionalQualifier.ColumnMajor,
_ => throw new ArgumentException($"Unknown optional qualifier: {str}"),
};
}
public enum BaseType
{
Bool,
Int,
Int32Only,
Int16,
Int64,
SInt16Or32,
AnyInt,View on GitHub (pinned to 96fad776d2)