stride3d/stride · error · ArgumentNullException
paramKey
Error message
paramKey
What it means
GetParam<T> throws ArgumentNullException("paramKey") when the PermutationParameterKey<T> used to look up a shader permutation parameter is null. The key is required to compute the global, composition, and selected keys for the lookup. Fail-fast guard before any parameter resolution happens.
Solutions
- Pass a valid PermutationParameterKey<T> instance (e.g. MyShader.Permutation.PositionInput)
- Verify the key exists in the shader's permutation keys after version changes
- Add a null check before calling GetParam
Example fix
// before
var value = context.GetParam(FindKey(name)); // FindKey may return null
// after
var key = FindKey(name);
if (key != null) { var value = context.GetParam(key); } Defensive patterns
Strategy: validation
Validate before calling
if (paramKey is null) throw new InvalidOperationException("Permutation key not found");
var value = context.GetParam(paramKey); Type guard
static bool IsValidKey<T>(PermutationParameterKey<T> k) => k != null;
Try / catch
try { var value = context.GetParam(key); }
catch (ArgumentNullException) { throw new InvalidOperationException($"Unknown permutation key '{name}'"); } Prevention
- Reference permutation keys directly from the generated shader class (e.g. MyShader.Permutation.X)
- Re-check key names after upgrading shaders
- Wrap dynamic key resolution with null checks
When it happens
Trigger: Calling ctx.GetParam<T>(null) — usually when the key was retrieved from a dictionary/registry that lacked the entry and the null result was passed directly.
Common situations: Referencing a permutation key by string name that doesn't exist; keys defined in a different shader version no longer present after an upgrade.
Related errors
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/f73f6044c3968e82.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs:100
}
}
public void Discard()
{
throw new ShaderMixinDiscardException();
}
/// <summary>
/// Gets a parameter value for the specified key.
/// </summary>
/// <typeparam name="T">Type of the parameter value</typeparam>
/// <param name="paramKey">The parameter key.</param>
/// <returns>The value or default value associated to this parameter key.</returns>
/// <exception cref="System.ArgumentNullException">key</exception>
public T GetParam<T>(PermutationParameterKey<T> paramKey)
{
if (paramKey == null)
throw new ArgumentNullException("paramKey");
var globalKey = paramKey;
var composeKey = GetComposeKey(paramKey);
var selectedKey = globalKey;
ParameterCollection sourceParameters = null;
// Try first if a composite key with a value is available for the key
if (composeKey != globalKey)
{
sourceParameters = FindKeyValue(composeKey, out selectedKey);
}
// Else try using global key
if (sourceParameters == null)
{
sourceParameters = FindKeyValue(globalKey, out selectedKey);
}
View on GitHub (pinned to 96fad776d2)