stride3d/stride · error · ArgumentNullException

value

Error message

value

What it means

The Shader property setter in ColorTransformBase throws ArgumentNullException when assigning null. The shader source is stored in the transform's ParameterCollection and is required to build the effect; the setter also notifies the parent ColorTransformGroup of a permutation change, which requires a valid shader. The message reads 'Shader can not be null'.

Solutions

  1. Assign a valid ShaderMixinGeneratorSource (or equivalent shader source) instead of null.
  2. To disable a transform, set its Enabled property to false rather than nulling the shader.
  3. Remove the transform from the ColorTransformGroup if it is no longer needed.

Example fix

// before
transform.Shader = null;
// after
transform.Enabled = false;
Defensive patterns

Strategy: validation

Validate before calling

if (shaderSource == null) throw new ArgumentException("Shader source required");
transform.Shader = shaderSource;

Type guard

if (transform.Shader is null) { /* assign before use */ }

Try / catch

try { transform.Shader = source; }
catch (ArgumentNullException ex) { Log.Error(ex, "Null shader source assignment"); }

Prevention

When it happens

Trigger: Assigning transform.Shader = null, e.g. while trying to 'reset' a transform or clearing cached state on a ColorTransform that belongs to a ColorTransformGroup.

Common situations: Generic reset code that nulls properties; serialization round-trips that assign null when the shader source was not persisted; mistaking the property for an optional override.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Images/ColorTransforms/ColorTransformBase.cs:58

        /// </summary>
        [DataMemberIgnore]
        public ColorTransformGroup Group { get; internal set; }

        /// <summary>
        /// Gets or sets the shader source for this color transform.
        /// </summary>
        [DataMemberIgnore]
        public ShaderSource Shader
        {
            get
            {
                return Parameters.Get(ColorTransformKeys.Shader);
            }
            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value", $"{nameof(Shader)} can not be null");
                }

                Parameters.Set(ColorTransformKeys.Shader, value);
                Group?.NotifyPermutationChange();
            }
        }

        /// <summary>
        /// Gets the parameters.
        /// </summary>
        /// <value>The parameters.</value>
        [DataMemberIgnore]
        public ParameterCollection Parameters { get; private set; }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="ColorTransformBase"/> is enabled.
        /// </summary>
        /// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>

View on GitHub (pinned to 96fad776d2)