stride3d/stride · error · ArgumentNullException
builder
Error message
builder
What it means
ShaderMixinManager.Register throws ArgumentNullException("builder") when the IShaderMixinBuilder instance to register is null. The builder is what will generate the shader mixin for the registered effect name. Fail-fast guard preventing null entries in the global builder registry.
Solutions
- Instantiate the builder before registering (e.g. new MyBuilder()) or fix the factory returning null
- Verify the builder's assembly is loaded and the type is constructible
- Check DI/activation logs for silent construction failures
Example fix
// before
ShaderMixinManager.Register("MyEffect", CreateBuilder(type)); // may return null
// after
var builder = CreateBuilder(type) ?? new MyEffect.Builder();
ShaderMixinManager.Register("MyEffect", builder); Defensive patterns
Strategy: validation
Validate before calling
if (builder is null) throw new InvalidOperationException($"Builder for '{sdfxEffectName}' failed to instantiate");
ShaderMixinManager.Register(sdfxEffectName, builder); Type guard
static bool IsValidBuilder(IShaderMixinBuilder b) => b != null;
Try / catch
try { ShaderMixinManager.Register(name, builder); }
catch (ArgumentNullException ex) when (ex.ParamName == "builder") { logger.LogError(ex, "Builder for {Effect} is null; check instantiation", name); throw; } Prevention
- Instantiate builders directly or verify factory results are non-null
- Ensure builder assemblies are loaded before registration
- Log DI/activation failures so silent nulls are caught early
When it happens
Trigger: Calling ShaderMixinManager.Register(name, null) — commonly when the builder is created via reflection/Activator and instantiation failed silently, or a DI container returned null.
Common situations: Plugin builder types that fail to instantiate; assemblies not loaded so type resolution returns null; factory methods returning null on unsupported platforms.
Related errors
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/359c23900b6aa745.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Effects/ShaderMixinManager.cs:33
private static readonly Dictionary<string, IShaderMixinBuilder> RegisteredBuilders = new Dictionary<string, IShaderMixinBuilder>();
/// <summary>
/// Registers a <see cref="IShaderMixinBuilder"/> with the specified sdfx effect name.
/// </summary>
/// <param name="sdfxEffectName">Name of the mixin.</param>
/// <param name="builder">The builder.</param>
/// <exception cref="System.ArgumentNullException">
/// sdfxEffectName
/// or
/// builder
/// </exception>
public static void Register(string sdfxEffectName, IShaderMixinBuilder builder)
{
if (sdfxEffectName == null)
throw new ArgumentNullException("sdfxEffectName");
if (builder == null)
throw new ArgumentNullException("builder");
lock (RegisteredBuilders)
{
RegisteredBuilders[sdfxEffectName] = builder;
}
}
/// <summary>
/// Determines whether the specified PDXFX effect is registered.
/// </summary>
/// <param name="sdfxEffectName">Name of the PDXFX effect.</param>
/// <returns><c>true</c> if the specified PDXFX effect is registered; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException">sdfxEffectName</exception>
public static bool Contains(string sdfxEffectName)
{
if (sdfxEffectName == null) throw new ArgumentNullException("sdfxEffectName");
var effectName = GetEffectName(sdfxEffectName);View on GitHub (pinned to 96fad776d2)