stride3d/stride · error · ArgumentNullException

key

Error message

key

What it means

The ParameterCompositeKey struct constructor in ColorTransformGroup throws ArgumentNullException when the ParameterKey is null. This composite key pairs a parameter key with a transform index to uniquely identify parameters inside a color-transform group; a null key would produce an unusable dictionary key.

Solutions

  1. Pass a valid, non-null ParameterKey instance when constructing the composite key.
  2. Verify that the ParameterKey field/property being used was initialized (e.g. via ParameterKeys static definitions).
  3. Guard the construction site with a null check and log which key failed to resolve.

Example fix

// before
var key = new ParameterCompositeKey(myKey, 0); // myKey null
// after
if (myKey == null) throw new InvalidOperationException("Parameter key not initialized");
var key = new ParameterCompositeKey(myKey, 0);
Defensive patterns

Strategy: validation

Validate before calling

if (parameterKey == null) throw new InvalidOperationException("ParameterKey not resolved");
var compositeKey = new ParameterCompositeKey(parameterKey, index);

Type guard

bool KeyResolved(ParameterKey k) => k != null;

Try / catch

try { var key = new ParameterCompositeKey(k, i); }
catch (ArgumentNullException ex) { Log.Error(ex, "Null parameter key"); }

Prevention

When it happens

Trigger: new ParameterCompositeKey(null, index) — constructing the key with a null ParameterKey, typically when the key comes from a lookup or reflection that returned null.

Common situations: Custom color transforms registering parameters with keys that failed to resolve; refactorings where a ParameterKey field was not initialized.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/3b05e43a840456f7. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Images/ColorTransforms/ColorTransformGroup.cs:266

        }

        /// <summary>
        /// An internal key to cache {Key,TransformIndex} => CompositeKey
        /// </summary>
        private struct ParameterCompositeKey : IEquatable<ParameterCompositeKey>
        {
            private readonly ParameterKey key;

            private readonly int index;

            /// <summary>
            /// Initializes a new instance of the <see cref="ParameterCompositeKey"/> struct.
            /// </summary>
            /// <param name="key">The key.</param>
            /// <param name="transformIndex">Index of the transform.</param>
            public ParameterCompositeKey(ParameterKey key, int transformIndex)
            {
                if (key == null) throw new ArgumentNullException("key");
                this.key = key;
                index = transformIndex;
            }

            public bool Equals(ParameterCompositeKey other)
            {
                return key.Equals(other.key) && index == other.index;
            }

            public override bool Equals(object obj)
            {
                if (ReferenceEquals(null, obj)) return false;
                return obj is ParameterCompositeKey && Equals((ParameterCompositeKey)obj);
            }

            public override int GetHashCode()
            {
                unchecked

View on GitHub (pinned to 96fad776d2)