{"record":{"id":"f8225353494fa02b","repo":"stride3d/stride","slug":"shadersource-0-is-not-supported-only-shadermixinsource-and","errorCode":null,"errorMessage":"ShaderSource [{0}] is not supported (Only ShaderMixinSource and ShaderClassSource)","messagePattern":"ShaderSource \\[(.+?)\\] is not supported \\(Only ShaderMixinSource and ShaderClassSource\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs","lineNumber":305,"sourceCode":"            {\n                return;\n            }\n\n            if (shaderSource is ShaderMixinSource shaderMixinSource)\n            {\n                mixinTree.CloneFrom(shaderMixinSource);\n            }\n            else if (shaderSource is ShaderClassCode shaderClassCode)\n            {\n                mixinTree.Mixins.Add(shaderClassCode);\n            }\n            else if (shaderSource is ShaderMixinGeneratorSource mixinGeneratorSource)\n            {\n                Mixin(mixinTree, mixinGeneratorSource.Name);\n            }\n            else\n            {\n                throw new InvalidOperationException(\"ShaderSource [{0}] is not supported (Only ShaderMixinSource and ShaderClassSource)\".ToFormat(shaderSource.GetType()));\n            }\n\n            // If we are mixin a shader source that has an attached discard, don't proceed further\n            if (shaderSource.Discard)\n            {\n                Discard();\n            }\n        }\n\n        // Helpers, until we get rid of ParameterCollection\n        private void Set<T>(ParameterCollection parameterCollection, PermutationParameterKey<T> key, T value)\n        {\n            parameterCollection.Set(key, value);\n        }\n\n        private T Get<T>(ParameterCollection parameterCollection, PermutationParameterKey<T> key)\n        {\n            return parameterCollection.Get(key);","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs#L287-L323","documentation":"ShaderMixinContext.Mixin throws InvalidOperationException with message 'ShaderSource [{0}] is not supported (Only ShaderMixinSource and ShaderClassSource)' when a ShaderSource type other than ShaderMixinSource, ShaderClassSource, or ShaderMixinGeneratorSource is passed. The mixin pipeline only knows how to expand these three kinds of shader sources.","triggerScenarios":"Calling ctx.Mixin(mixinTree, someShaderSource) with e.g. a raw ShaderSource, ShaderArraySource, or a custom ShaderSource subclass the mixin system does not handle.","commonSituations":"Custom shader source types from extensions; passing output of another compilation stage unchanged; upgrades where a new ShaderSource subtype isn't yet handled by the mixin pipeline.","solutions":["Convert the source to a ShaderClassSource or ShaderMixinSource before mixing","Handle ShaderArraySource by iterating its entries and mixing each one","Extend/patch the mixin handling if a new source type must be supported"],"exampleFix":"// before\ncontext.Mixin(tree, shaderArraySource); // unsupported type\n// after\nforeach (var source in shaderArraySource.Values)\n    context.Mixin(tree, source); // mix each supported source individually","handlingStrategy":"validation","validationCode":"if (source is not (ShaderMixinSource or ShaderClassSource or ShaderMixinGeneratorSource))\n    throw new InvalidOperationException($\"Unsupported shader source type {source.GetType().Name}\");","typeGuard":"static bool IsMixable(ShaderSource s) => s is ShaderMixinSource or ShaderClassSource or ShaderMixinGeneratorSource;","tryCatchPattern":"try { context.Mixin(tree, source); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"is not supported\")) { logger.LogError(ex, \"Unsupported ShaderSource type\"); throw; }","preventionTips":["Convert exotic ShaderSource types to ShaderClassSource/ShaderMixinSource before mixing","Expand ShaderArraySource manually into individual mixins","Re-check mixin support when introducing custom ShaderSource subclasses"],"tags":["csharp","type-mismatch","mixin","shaders"],"backgroundTag":"unsupported-operation","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"}