stride3d/stride · error · NotImplementedException
Exception of type 'System.NotImplementedException' was…
Error message
Exception of type 'System.NotImplementedException' was thrown.
What it means
TryResolveGenericValue parses a generic argument string into a constant. It handles scalar parse cases plus GenericParameterType; any other GenericParameterType operand falls into the default arm, which throws a bare NotImplementedException — the parameter's kind is not supported for resolution.
Solutions
- Constrain the generic parameter to supported scalar types (int/uint/float/bool/string) in the shader source.
- Add a case for the missing type in TryResolveGenericValue's switch and parse it appropriately.
- Resolve the value earlier so it arrives as a GenericParameterType (the supported path) instead of the raw kind.
Example fix
// before
default:
throw new NotImplementedException();
// after
case MatrixType m:
value = new ConstantVector(genericValue.Split(',').Select(float.Parse).Cast<object>().ToArray());
return true;
default:
throw new NotSupportedException($"Cannot resolve generic value of type {genericParameterType}"); Defensive patterns
Strategy: type-guard
Validate before calling
bool supported = genericParameterType is ScalarType or VectorType or GenericParameterType;
if (!supported) throw new ArgumentException($"Unsupported generic parameter type: {genericParameterType.GetType()}"); Type guard
bool IsResolvableGenericKind(SymbolType t) => t is ScalarType or VectorType or GenericParameterType;
Try / catch
try { ok = TryResolveGenericValue(...); }
catch (NotImplementedException) { /* unsupported kind: handle manually or skip this parameter */ } Prevention
- Declare shader generics only as scalar, vector, or plain generic parameters
- Extend TryResolveGenericValue when adding new SDSL type kinds
- Test generic instantiation for each parameter kind you support
When it happens
Trigger: Calling TryResolveGenericValue (directly or via generic instantiation during build) with a generic parameter type that is neither a parsable scalar type nor GenericParameterType — e.g. a composite/array/vector generic parameter kind.
Common situations: Instantiating a shader with a generic argument whose declared parameter type is a matrix, struct, or array; a new GenericParameterType kind added to the SPIR-V SDSL extension but not yet wired into this resolver.
Related errors
- Unsupported float width
- Unsupported constant type
- Unsupported OpSpecConstantOp inner op
- Cannot parse constant expression from
- unknown accessor on type in expression
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/5f112bcc5a1739bb.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Builder.Class.cs:285
public override bool TryResolveGenericValue(SymbolType genericParameterType, string genericParameterName, int index, out object value)
{
var genericValue = genericValues![index];
switch (genericParameterType)
{
case ScalarType { Type: Scalar.Int }:
value = int.Parse(genericValue, CultureInfo.InvariantCulture);
return true;
case ScalarType { Type: Scalar.Float }:
value = float.Parse(genericValue, NumberStyles.Float, CultureInfo.InvariantCulture);
return true;
case ScalarType { Type: Scalar.Boolean }:
value = bool.Parse(genericValue);
return true;
case GenericParameterType g:
value = genericValue;
return true;
default:
throw new NotImplementedException();
}
}
public override bool ResolveGenericValueInBuffer(SymbolType genericParameterType, string genericParameterName, int genericIndex, SpirvContext context, ref int instructionIndex, out string textValue)
{
var genericParameter = (OpGenericParameterSDSL)context[instructionIndex];
var genericValue = genericValues![genericIndex];
textValue = genericValue;
switch (genericParameterType)
{
case ScalarType or VectorType:
var scanner = new Scanner(textValue);
ParseResult pr = new ParseResult();
if (!ExpressionParser.Expression(ref scanner, pr, out var expression))
throw new InvalidOperationException("Can't parse generic value");
var localContext = new SpirvContext();
var result = expression.CompileConstantValue(new SymbolTable(localContext, null!), localContext, genericParameterType);
context.RemoveAt(instructionIndex);View on GitHub (pinned to 96fad776d2)