{"record":{"id":"a75e032cbaa789f4","repo":"stride3d/stride","slug":"unsupported-constant-composite-element-type-v-0-gettype","errorCode":null,"errorMessage":"Unsupported constant composite element type: {v[0]?.GetType()}","messagePattern":"Unsupported constant composite element type: (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Compilers/SDSL/ShaderMixer.CBuffers.cs","lineNumber":655,"sourceCode":"                {\n                    2 => new Vector2((float)v[0], (float)v[1]),\n                    3 => new Vector3((float)v[0], (float)v[1], (float)v[2]),\n                    4 => (object)new Vector4((float)v[0], (float)v[1], (float)v[2], (float)v[3]),\n                    _ => throw new NotSupportedException($\"Unsupported float vector size: {v.Length}\"),\n                },\n                int => v.Length switch\n                {\n                    2 => new Int2((int)v[0], (int)v[1]),\n                    3 => new Int3((int)v[0], (int)v[1], (int)v[2]),\n                    4 => (object)new Int4((int)v[0], (int)v[1], (int)v[2], (int)v[3]),\n                    _ => throw new NotSupportedException($\"Unsupported int vector size: {v.Length}\"),\n                },\n                uint => v.Length switch\n                {\n                    4 => (object)new UInt4((uint)v[0], (uint)v[1], (uint)v[2], (uint)v[3]),\n                    _ => throw new NotSupportedException($\"Unsupported uint vector size: {v.Length}\"),\n                },\n                _ => throw new NotSupportedException($\"Unsupported constant composite element type: {v[0]?.GetType()}\"),\n            };\n        }\n    }\n}\n","sourceCodeStart":637,"sourceCodeEnd":660,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Compilers/SDSL/ShaderMixer.CBuffers.cs#L637-L660","documentation":"ConvertDefaultValue switches on the element type of the constant composite (float, int, uint). A default value whose element type is none of these — e.g. bool, double, or a nested composite — has no conversion and throws NotSupportedException reporting the runtime element type.","triggerScenarios":"A cbuffer member default of type bool2/bool3/bool4, double vector, or a nested/struct composite passed to ConvertDefaultValue via ComputeCBufferReflection.","commonSituations":"bool vector flags (bvec from GLSL) used as defaults; double-precision literals in shader defaults; defaults assigned from struct-typed constants.","solutions":["Change the default to a float, int, or uint vector type","Encode bool flags as int vectors (0/1)","Remove the default value or express it via a supported type"],"exampleFix":"// before\nbool2 Enabled = bool2(true, false);\n// after\nint2 Enabled = int2(1, 0);","handlingStrategy":"validation","validationCode":"if (elemType is not (\"float\" or \"int\" or \"uint\"))\n    throw new ArgumentException($\"Unsupported default element type: {elemType}\");","typeGuard":"bool IsSupportedDefaultType(TypeDescription t) =>\n    t is ScalarType { Type: Scalar.Float or Scalar.Int or Scalar.UInt };","tryCatchPattern":"try { result = mixer.MergeSDSL(tree); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"Unsupported constant composite element type\")) {\n    convertBoolDefaultToInt(memberName);\n}","preventionTips":["Express bool defaults as 0/1 int vectors","Avoid double-precision shader defaults","Keep cbuffer defaults to float/int/uint vectors"],"tags":["shaders","sdsl","default-values","type-mismatch"],"backgroundTag":"unsupported-dtype","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"}