{"record":{"id":"1da0fead82803050","repo":"stride3d/stride","slug":"unsupported-shadersource-type-0-supporting-only","errorCode":null,"errorMessage":"Unsupported ShaderSource type [{0}]. Supporting only ShaderMixinSource/sdfx, ShaderClassSource","messagePattern":"Unsupported ShaderSource type \\[(.+?)\\]\\. Supporting only ShaderMixinSource/sdfx, ShaderClassSource","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Effects/Compiler/EffectCompilerBase.cs","lineNumber":60,"sourceCode":"\n            if (shaderMixinGeneratorSource != null)\n            {\n                mixinToCompile = ShaderMixinManager.Generate(shaderMixinGeneratorSource.Name, compilerParameters);\n            }\n            else\n            {\n                mixinToCompile = shaderSource as ShaderMixinSource;\n                var shaderClassSource = shaderSource as ShaderClassCode;\n\n                if (shaderClassSource != null)\n                {\n                    mixinToCompile = new ShaderMixinSource { Name = shaderClassSource.ClassName };\n                    mixinToCompile.Mixins.Add(shaderClassSource);\n                }\n\n                if (mixinToCompile == null)\n                {\n                    throw new ArgumentException(\"Unsupported ShaderSource type [{0}]. Supporting only ShaderMixinSource/sdfx, ShaderClassSource\", \"shaderSource\");\n                }\n                if (string.IsNullOrEmpty(mixinToCompile.Name))\n                {\n                    throw new ArgumentException(\"ShaderMixinSource must have a name\", \"shaderSource\");\n                }\n            }\n\n            // Compile the whole mixin tree\n            var compilerResults = new CompilerResults { Module = $\"EffectCompile [{mixinToCompile.Name}]\" };\n            var effectInputHash = ShaderMixinObjectId.Compute(mixinToCompile, compilerParameters.EffectParameters);\n            var bytecode = Compile(mixinToCompile, effectParameters: compilerParameters.EffectParameters, compilerParameters, effectInputHash);\n\n            // Since bytecode.Result is a struct, we check if any of its member has been set to know if it's valid\n            if (bytecode.Result.CompilationLog is not null || bytecode.Task is not null)\n            {\n                bytecode.Result.CompilationLog?.CopyTo(compilerResults);\n                compilerResults.Bytecode = bytecode;\n                compilerResults.SourceParameters = new CompilerParameters(compilerParameters);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Effects/Compiler/EffectCompilerBase.cs#L42-L78","documentation":"EffectCompilerBase.Compile validates that the incoming ShaderSource is a ShaderMixinSource or ShaderClassSource (which it can convert into a mixin). Any other ShaderSource implementation leaves mixinToCompile null and this ArgumentException is thrown. The library only supports those two shader source representations for effect compilation.","triggerScenarios":"Calling EffectCompilerBase.Compile with a ShaderSource that is neither ShaderMixinSource nor ShaderClassSource — e.g. a custom IShaderSource implementation, a ShaderSourceStoryboard/parse-tree source, or a deserialized object of the wrong concrete type.","commonSituations":"Custom shader-source subclasses written against an older Stride API; passing an effect 'description' object instead of a compiled source; versions where additional ShaderSource types were accepted being replaced by mixin-only compilation.","solutions":["Convert the source into a ShaderMixinSource (set Name and add the mixin parts) before calling Compile.","If you have a ShaderClassSource, pass it directly — it is wrapped into a ShaderMixinSource automatically.","Check the concrete type of the object you pass with GetType() and fix the construction site.","If you need a custom ShaderSource type, pre-flatten it into mixin/class sources instead of subclassing ShaderSource."],"exampleFix":"// before\nshaderCompiler.Compile(myCustomShaderSource, parameters);\n// after\nvar mixin = new ShaderMixinSource { Name = \"MyShader\" };\nmixin.Mixins.Add(new ShaderClassSource(\"MyShader\"));\nshaderCompiler.Compile(mixin, parameters);","handlingStrategy":"type-guard","validationCode":"if (source is not (ShaderMixinSource or ShaderClassSource)) throw new ArgumentException($\"Cannot compile {source?.GetType().Name}; use ShaderMixinSource or ShaderClassSource\");","typeGuard":"bool IsCompilableShaderSource(ShaderSource s) => s is ShaderMixinSource || s is ShaderClassSource;","tryCatchPattern":"try { compiler.Compile(source, parameters); } catch (ArgumentException ex) when (ex.Message.Contains(\"Unsupported ShaderSource type\")) { /* convert to ShaderMixinSource and retry */ }","preventionTips":["Always build effects from ShaderClassSource via ShaderMixinSource","Never subclass ShaderSource for new compile inputs","Assert source type in effect-building helpers"],"tags":["shaders","argument-validation","unsupported-type"],"backgroundTag":"incompatible-source-type","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}