stride3d/stride · error · InvalidOperationException
Generic Parameters are not supported with
Error message
Generic Parameters are not supported with [{0}] What it means
ShaderMixinContext.Mixin throws InvalidOperationException with message 'Generic Parameters are not supported with [{0}]' when generic parameters are supplied for a shader name that resolves to a registered IShaderMixinBuilder rather than a plain shader class. Generic arguments only apply to ShaderClassSource entries; builders cannot accept them.
Solutions
- Remove the genericParameters argument when mixing in a registered builder
- Register the shader as a ShaderClassSource instead of a builder if generics are needed
- Choose the correct name: use the class name for generic shaders, the effect name for builders
Example fix
// before
context.Mixin(tree, "TransformationGeneric", new[] { "Stride.Rendering.Transformation.TransformationWiggle" }); // name is a registered builder
// after
context.Mixin(tree, "TransformationWiggle"); // mix the class source directly with no builder indirection Defensive patterns
Strategy: try-catch
Validate before calling
if (genericParameters is { Length: > 0 } && registeredBuilders.ContainsKey(name))
throw new InvalidOperationException($"'{name}' is a builder; generic parameters are not supported"); Try / catch
try { context.Mixin(tree, name, genericParameters); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Generic Parameters are not supported")) { context.Mixin(tree, name); // retry without generics
} Prevention
- Only pass generic parameters for shader class names, not registered builder effects
- Know which names are builders vs ShaderClassSources
- Default to omitting genericParameters unless mixing a generic class
When it happens
Trigger: Calling ctx.Mixin(mixinTree, name, genericParameters) where name maps to a registered builder and genericParameters is non-empty (Length != 0).
Common situations: Passing a builder-registered effect name (like an sdfx effect) with generic type arguments copied from a class-based shader call; misunderstanding which names are builders vs classes.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- paramKey
- key
- Invalid null mixin name
- ShaderSource [ ] is not supported (Only ShaderMixinSource…
- Type ' ' is not supported as a SymbolType.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/2937748eb0d2c7ae.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs:233
/// Mixins a <see cref="ShaderClassSource" /> identified by its name/generic parameters into the specified mixin tree.
/// </summary>
/// <param name="mixinTree">The mixin tree.</param>
/// <param name="name">The name.</param>
/// <param name="genericParameters">The generic parameters.</param>
/// <exception cref="System.InvalidOperationException">If the class source doesn't support generic parameters</exception>
public void Mixin(ShaderMixinSource mixinTree, string name, params object[] genericParameters)
{
IShaderMixinBuilder builder;
if (!registeredBuilders.TryGetValue(name, out builder))
{
// Else simply add the name of the shader
mixinTree.Mixins.Add(new ShaderClassSource(name, genericParameters));
}
else if (builder != null)
{
if (genericParameters != null && genericParameters.Length != 0)
{
throw new InvalidOperationException(string.Format("Generic Parameters are not supported with [{0}]", builder.GetType().GetTypeInfo().Name));
}
builder.Generate(mixinTree, this);
}
}
public void PushComposition(ShaderMixinSource mixin, string compositionName, ShaderMixinSource composition)
{
mixin.AddComposition(compositionName, composition);
compositionIndices.Push(compositionStringBuilder.Length);
if (compositionString != null)
{
compositionStringBuilder.Insert(0, '.');
}
compositionStringBuilder.Insert(0, compositionName);
compositionString = compositionStringBuilder.ToString();View on GitHub (pinned to 96fad776d2)