stride3d/stride · error · ArgumentException

The smallStep should be lesser or equal to the largeStep.

Error message

The smallStep should be lesser or equal to the largeStep.

What it means

The five-parameter DataMemberRangeAttribute constructor throws ArgumentException with 'The smallStep should be lesser or equal to the largeStep.' when smallStep > largeStep. smallStep/largeStep control fine/coarse increments from minimum to maximum (e.g. slider ticks); having the fine step exceed the coarse step is inconsistent and rejected.

Solutions

  1. Order the steps: make smallStep <= largeStep (e.g. smallStep 0.1, largeStep 1.0).
  2. Verify argument positions in the constructor signature (minimum, maximum, smallStep, largeStep, decimalPlaces).
  3. Compute steps from the range programmatically and clamp: smallStep = Math.Min(smallStep, largeStep).

Example fix

// before
[DataMemberRange(0.0, 1.0, 0.5, 0.1, 2)]
public float Volume { get; set; }
// after
[DataMemberRange(0.0, 1.0, 0.1, 0.5, 2)]
public float Volume { get; set; }
Defensive patterns

Strategy: validation

Validate before calling

if (smallStep > largeStep)
    throw new ArgumentException($"smallStep {smallStep} must be <= largeStep {largeStep}.");
// then apply: [DataMemberRange(min, max, smallStep, largeStep, decimals)]

Type guard

static bool AreValidSteps(double smallStep, double largeStep) => !double.IsNaN(smallStep) && !double.IsNaN(largeStep) && smallStep <= largeStep;

Try / catch

try
{
    var attr = new DataMemberRangeAttribute(min, max, smallStep, largeStep, decimals);
}
catch (ArgumentException ex)
{
    log.Error("Invalid DataMemberRange steps: " + ex.Message);
}

Prevention

When it happens

Trigger: Writing [DataMemberRange(0.0, 1.0, 0.5, 0.1, 2)] where the small step (0.5) exceeds the large step (0.1). Only reached after minimum/maximum/NaN checks pass.

Common situations: Configuring editor sliders for Stride asset properties; argument-order confusion after refactoring; copied attribute lines where steps were edited to cross.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at sources/core/Stride.Core/Annotations/DataMemberRangeAttribute.cs:41

        DecimalPlaces = decimalPlaces;
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="DataMemberRangeAttribute" /> class.
    /// </summary>
    /// <param name="minimum">The minimum.</param>
    /// <param name="maximum">The maximum.</param>
    /// <param name="smallStep">The minimum step used to go from minimum to maximum.</param>
    /// <param name="largeStep">The maximum step used to go from minimum to maximum.</param>
    /// <param name="decimalPlaces">The decimal places.</param>
    public DataMemberRangeAttribute(double minimum, double maximum, double smallStep, double largeStep, int decimalPlaces)
        : this(minimum, decimalPlaces)
    {
        if (double.IsNaN(maximum)) throw new ArgumentOutOfRangeException(nameof(maximum));
        if (minimum > maximum) throw new ArgumentException("The minimum should be lesser or equal to the maximum.", nameof(minimum));
        if (double.IsNaN(smallStep)) throw new ArgumentOutOfRangeException(nameof(smallStep));
        if (double.IsNaN(largeStep)) throw new ArgumentOutOfRangeException(nameof(largeStep));
        if (smallStep > largeStep) throw new ArgumentException("The smallStep should be lesser or equal to the largeStep.", nameof(smallStep));
        if (decimalPlaces < 0) throw new ArgumentException("The decimalPlaces should be greater or equal to zero.", nameof(decimalPlaces));
        Maximum = maximum;
        SmallStep = smallStep;
        LargeStep = largeStep;
    }

    /// <summary>
    /// Gets the minimum inclusive.
    /// </summary>
    /// <value>The minimum.</value>
    public double? Minimum { get; }

    /// <summary>
    /// Gets the maximum inclusive.
    /// </summary>
    /// <value>The maximum.</value>
    public double? Maximum { get; }

View on GitHub (pinned to 96fad776d2)