stride3d/stride · error · ArgumentNullException
sdfxEffectName
Error message
sdfxEffectName
What it means
ShaderMixinManager.Register throws ArgumentNullException("sdfxEffectName") when the effect name used to register a mixin builder is null. The name is the lookup key in the global RegisteredBuilders dictionary. Fail-fast guard so unregistered/unnamed effects fail at registration rather than at mixin time.
Solutions
- Pass a valid non-null effect name string
- Ensure the constant/attribute providing the name is defined
- Add a check that the derived name is non-null before calling Register
Example fix
// before
ShaderMixinManager.Register(GetEffectName(type), builder); // may return null
// after
var name = GetEffectName(type);
if (name != null) { ShaderMixinManager.Register(name, builder); } Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(sdfxEffectName)) throw new InvalidOperationException("Effect name required for builder registration");
ShaderMixinManager.Register(sdfxEffectName, builder); Type guard
static bool IsValidEffectName(string n) => !string.IsNullOrEmpty(n);
Try / catch
try { ShaderMixinManager.Register(name, builder); }
catch (ArgumentNullException ex) when (ex.ParamName == "sdfxEffectName") { logger.LogError(ex, "Cannot register builder without a name"); throw; } Prevention
- Define effect names as compile-time constants
- Check reflection-derived names for null before registering
- Register builders in explicit startup code rather than dynamic name derivation
When it happens
Trigger: Calling ShaderMixinManager.Register(null, builder) — typically when the effect name comes from a type-derived name or constant that is null.
Common situations: Reflection-based registration where the name attribute is missing; refactors that removed the effect name constant.
Related errors
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/2e9232974d3d0056.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Effects/ShaderMixinManager.cs:30
/// </summary>
public class ShaderMixinManager
{
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)
{View on GitHub (pinned to 96fad776d2)