stride3d/stride · error · ArgumentNullException

transform

Error message

transform

What it means

AddTemporaryTransform in ColorTransformGroup throws ArgumentNullException when a ColorTransform with a null reference is added. This method is invoked from CollectPreTransforms, CollectPostTransforms, and CollectTransforms while assembling the transform list for the group, so a null entry would corrupt the collected pipeline.

Solutions

  1. Remove null entries from your transform collections before the group collects them.
  2. Check each ColorTransform instance for null before adding it to PreTransforms/PostTransforms/Transforms.
  3. Fix the construction code that is producing null transforms.

Example fix

// before
transforms.Add(null);
// after
if (transform != null) transforms.Add(transform);
Defensive patterns

Strategy: validation

Validate before calling

transforms.RemoveAll(t => t == null);
group.PostTransforms.AddRange(transforms);

Type guard

bool AddIfPresent(List<ColorTransform> list, ColorTransform t) { if (t == null) return false; list.Add(t); return true; }

Try / catch

try { group.PostTransforms.AddRange(collected); }
catch (ArgumentNullException ex) { Log.Error(ex, "Null transform in collection"); }

Prevention

When it happens

Trigger: A collection of transforms (pre/post/main) contains a null element, e.g. a List<ColorTransform> with a null added, which is then passed through the Collect* methods that call AddTemporaryTransform per element.

Common situations: Building transform lists from config where some entries fail to construct; adding null to a transform list as a placeholder; deserialization producing null entries for missing transforms.

Related errors


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

Appendix: source

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

        protected virtual void CollectPreTransforms()
        {
            foreach (var transform in preTransforms)
            {
                AddTemporaryTransform(transform);
            }
        }

        protected virtual void CollectPostTransforms()
        {
            foreach (var transform in postTransforms)
            {
                AddTemporaryTransform(transform);
            }
        }

        protected void AddTemporaryTransform(ColorTransform transform)
        {
            if (transform == null) throw new ArgumentNullException("transform");
            if (transform.Shader == null) throw new ArgumentOutOfRangeException("transform", "Transform parameter must have a Shader not null");
            if (transform.Enabled)
                collectTransforms.Add(transform);
        }

        private bool CollectTransforms()
        {
            collectTransforms.Clear();
            CollectPreTransforms();
            foreach (var transform in transforms)
            {
                AddTemporaryTransform(transform);
            }
            CollectPostTransforms();

            // Copy all parameters from ColorTransform to effect parameters
            if (collectTransforms.Count != enabledTransforms.Count)
            {

View on GitHub (pinned to 96fad776d2)