{"record":{"id":"5f112bcc5a1739bb","repo":"stride3d/stride","slug":"exception-of-type-system-notimplementedexception-was-thrown-5f112b","errorCode":null,"errorMessage":"Exception of type 'System.NotImplementedException' was thrown.","messagePattern":"Exception of type 'System\\.NotImplementedException' was thrown\\.","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Builder.Class.cs","lineNumber":285,"sourceCode":"        public override bool TryResolveGenericValue(SymbolType genericParameterType, string genericParameterName, int index, out object value)\n        {\n            var genericValue = genericValues![index];\n            switch (genericParameterType)\n            {\n                case ScalarType { Type: Scalar.Int }:\n                    value = int.Parse(genericValue, CultureInfo.InvariantCulture);\n                    return true;\n                case ScalarType { Type: Scalar.Float }:\n                    value = float.Parse(genericValue, NumberStyles.Float, CultureInfo.InvariantCulture);\n                    return true;\n                case ScalarType { Type: Scalar.Boolean }:\n                    value = bool.Parse(genericValue);\n                    return true;\n                case GenericParameterType g:\n                    value = genericValue;\n                    return true;\n                default:\n                    throw new NotImplementedException();\n            }\n        }\n\n        public override bool ResolveGenericValueInBuffer(SymbolType genericParameterType, string genericParameterName, int genericIndex, SpirvContext context, ref int instructionIndex, out string textValue)\n        {\n            var genericParameter = (OpGenericParameterSDSL)context[instructionIndex];\n            var genericValue = genericValues![genericIndex];\n            textValue = genericValue;\n            switch (genericParameterType)\n            {\n                case ScalarType or VectorType:\n                    var scanner = new Scanner(textValue);\n                    ParseResult pr = new ParseResult();\n                    if (!ExpressionParser.Expression(ref scanner, pr, out var expression))\n                        throw new InvalidOperationException(\"Can't parse generic value\");\n                    var localContext = new SpirvContext();\n                    var result = expression.CompileConstantValue(new SymbolTable(localContext, null!), localContext, genericParameterType);\n                    context.RemoveAt(instructionIndex);","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Builder.Class.cs#L267-L303","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ndefault:\n    throw new NotImplementedException();\n// after\ncase MatrixType m:\n    value = new ConstantVector(genericValue.Split(',').Select(float.Parse).Cast<object>().ToArray());\n    return true;\ndefault:\n    throw new NotSupportedException($\"Cannot resolve generic value of type {genericParameterType}\");","handlingStrategy":"type-guard","validationCode":"bool supported = genericParameterType is ScalarType or VectorType or GenericParameterType;\nif (!supported) throw new ArgumentException($\"Unsupported generic parameter type: {genericParameterType.GetType()}\");","typeGuard":"bool IsResolvableGenericKind(SymbolType t) => t is ScalarType or VectorType or GenericParameterType;","tryCatchPattern":"try { ok = TryResolveGenericValue(...); }\ncatch (NotImplementedException) { /* unsupported kind: handle manually or skip this parameter */ }","preventionTips":["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"],"tags":["spirv","generics","not-implemented"],"backgroundTag":"method-not-implemented","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}