stride3d/stride · error · ArgumentNullException
properties
Error message
properties
What it means
ShaderMixinManager.Generate throws ArgumentNullException when the properties (ParameterCollection) argument is null. The mixin generation reads compilation parameters (macros, permutations) from this collection, so it is mandatory.
Solutions
- Pass a valid, non-null ParameterCollection (an empty one is acceptable if no parameters are needed).
- Initialize the collection before the call: new ParameterCollection().
- Add a null check at the call site.
Example fix
// before
var mixin = ShaderMixinManager.Generate("MyEffect", parameters);
// after
parameters ??= new ParameterCollection();
var mixin = ShaderMixinManager.Generate("MyEffect", parameters); Defensive patterns
Strategy: validation
Validate before calling
parameters ??= new ParameterCollection(); var mixin = ShaderMixinManager.Generate(effectName, parameters);
Try / catch
try { mixin = ShaderMixinManager.Generate(name, parameters); }
catch (ArgumentNullException ex) when (ex.ParamName == "properties") { parameters = new ParameterCollection(); mixin = ShaderMixinManager.Generate(name, parameters); } Prevention
- Initialize ParameterCollection in constructors of compiler contexts
- Never leave parameter fields null after object construction
When it happens
Trigger: Calling Generate(effectName, null) — e.g. constructing parameters lazily and forgetting to instantiate ParameterCollection.
Common situations: Custom effect compilers passing a parameters field never initialized; refactoring that removed a parameter-collection constructor call.
Related errors
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/091b8d8d2b6fc329.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Effects/ShaderMixinManager.cs:95
/// <summary>
/// Generates a <see cref="ShaderMixinSource" /> for the specified names and parameters.
/// </summary>
/// <param name="sdfxEffectName">The name.</param>
/// <param name="properties">The properties.</param>
/// <returns>The result of the mixin.</returns>
/// <exception cref="System.ArgumentNullException">
/// sdfxEffectName
/// or
/// properties
/// </exception>
/// <exception cref="System.ArgumentException">sdfxEffectName</exception>
public static ShaderMixinSource Generate(string sdfxEffectName, ParameterCollection properties)
{
if (sdfxEffectName == null) throw new ArgumentNullException("sdfxEffectName");
if (properties == null)
throw new ArgumentNullException("properties");
// Get the effect name and child effect name "RootEffectName.ChildEffectName"
var effectName = GetEffectName(sdfxEffectName);
var rootEffectName = effectName.Key;
var childEffectName = effectName.Value;
IShaderMixinBuilder builder;
Dictionary<string, IShaderMixinBuilder> builders;
lock (RegisteredBuilders)
{
if (!TryGet(rootEffectName, out builder))
throw new ArgumentException(string.Format("Xkfx effect [{0}] not found", rootEffectName), "sdfxEffectName");
builders = new Dictionary<string, IShaderMixinBuilder>(RegisteredBuilders);
}
// TODO cache mixin context and avoid to recreate one (check if if thread concurrency could occur here)
var mixinTree = new ShaderMixinSource() { Name = sdfxEffectName };View on GitHub (pinned to 96fad776d2)