stride3d/stride · error · ArgumentException
Unknown base type: {baseType}
Error message
Unknown base type: {baseType} What it means
The ParameterType(string baseType, ...) convenience constructor maps intrinsic-declaration type strings (bool, int, sampler2d, Texture2D, ...) to the BaseType enum via an exhaustive switch. Any string not in the whitelist — including typos, casing differences, and types added to the enum but not to the switch — throws ArgumentException('Unknown base type: ...'). It is a fail-fast guard over the intrinsic-definition tables.
Solutions
- Check the exact accepted strings in the switch at IntrinsicsParameters.cs:16-73 and use one of them verbatim (case-sensitive: 'sampler2d', 'Texture2D', 'any_float', ...).
- If your type maps to the generic BaseType.Other, use one of the recognized alias strings (e.g. 'udt', 'resource') or extend the switch with your string.
- If you added a new BaseType member, add a corresponding string arm to the switch (e.g. "Texture2DArray" => BaseType.Texture2DArray).
- For flexible cases, construct the record directly with a BaseType value (new ParameterType(BaseType.Texture2DArray)) instead of the string overload.
Example fix
// before
var t = new ParameterType("Texture3D"); // ArgumentException
// after
var t = new ParameterType(BaseType.Texture2D); // or add "Texture3D" => ... to the switch Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> ValidBaseTypes = new(StringComparer.Ordinal)
{ "bool","int","int16_t","int32_only","int64_t","int64_only","sint16or32_only","any_int","any_int32","any_int64","any_int16or32","uint","uint16_t","u64","float","float16","half","float16_t","any_float","double","double_only","sampler1d","sampler2d","sampler3d","sampler_cube","sampler_cmp","sampler","any_sampler","wave","void","uint_only","numeric","numeric16_only","numeric32_only","float32_only","any","float_like","match","ByteAddressBuffer","RWByteAddressBuffer","VkBufferPointer","Texture2D","Texture2DArray","acceleration_struct","ray_desc","udt","triangle_positions","p32i8","p32u8","resource","NodeRecordOrUAV","LinAlg","DxHitObject","RayQuery","ThreadNodeOutputRecords","GroupNodeOutputRecords" };
if (!ValidBaseTypes.Contains(baseType))
throw new ArgumentException($"{baseType} is not a whitelisted intrinsic base type"); Type guard
bool IsValidBaseTypeString(string s) =>
s is "bool" or "int" or "uint" or "float" or "double" or "half" or
"Texture2D" or "Texture2DArray" or "sampler2d" or "void" or "any"; // check against the full switch list Try / catch
try { var t = new ParameterType(baseTypeString); }
catch (ArgumentException ex) when (ex.Message.StartsWith("Unknown base type:"))
{
logger.LogError("Intrinsic table entry has unrecognized base type: {0}", ex.Message);
throw; // or fix/skip the offending table entry
} Prevention
- Copy type strings from existing intrinsic table entries rather than typing them by hand.
- Remember the mapping is case-sensitive: 'sampler2d' (lowercase) but 'Texture2D' (PascalCase).
- When adding a BaseType enum member, always extend the string switch in the same change.
- Validate intrinsics definition files at build/startup time so bad names fail fast.
When it happens
Trigger: Constructing ParameterType with a string base type not present in the switch in IntrinsicsParameters.cs:16-73, e.g. new ParameterType("Texture3D") or new ParameterType("Float"). Also triggered internally when displayTestResults or intrinsic-table entries (_Wrapper) pass an unrecognized type name, and when a BaseType variant is added without a corresponding string mapping (e.g. Texture2DArray has no string arm).
Common situations: Hand-editing or extending the intrinsics definition tables with a new type name; casing/typo mistakes ('texture2D' vs 'Texture2D'); adding a BaseType enum member (like Texture2DArray) without extending the string switch; porting HLSL type names verbatim instead of the parser's lowercase identifiers.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Unknown qualifier: {str}
- Unknown optional qualifier: {str}
- Could not find dependency {0} when processing bundle {1}
- Unexpected arguments [{0}]
- A part Id cannot be empty.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/0fb61185ca267161.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Core/IntrinsicsParameters.cs:73
"RWByteAddressBuffer" => BaseType.RWByteAddressBuffer,
"VkBufferPointer" => BaseType.VkBufferPointer,
"Texture2D" => BaseType.Texture2D,
"Texture2DArray" => BaseType.Texture2DArray,
"acceleration_struct"
or "ray_desc"
or "udt"
or "triangle_positions"
or "p32i8"
or "p32u8"
or "resource"
or "NodeRecordOrUAV"
or "LinAlg"
or "DxHitObject"
or "RayQuery"
or "ThreadNodeOutputRecords"
or "GroupNodeOutputRecords"
=> BaseType.Other,
_ => throw new ArgumentException($"Unknown base type: {baseType}"),
},
VectorSize,
matching
)
{ }
}
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())
{ }
}
View on GitHub (pinned to 96fad776d2)