stride3d/stride · error · ArgumentException
The minimum should be lesser or equal to the maximum.
Error message
The minimum should be lesser or equal to the maximum.
What it means
The five-parameter DataMemberRangeAttribute constructor throws ArgumentException with 'The minimum should be lesser or equal to the maximum.' when minimum > maximum. The chain-chained base constructor validates minimum/decimalPlaces first; then this constructor verifies the range is ordered, since [min, max] with min > max is an invalid range.
Solutions
- Swap the arguments so minimum <= maximum.
- Add a unit test or source check asserting min <= max on all DataMemberRange usages.
- If a bound is unbounded/unknown, verify which argument is which (signature: minimum, maximum, smallStep, largeStep, decimalPlaces).
Example fix
// before
[DataMemberRange(100.0, 0.0, 0.1, 1.0, 2)]
public float Speed { get; set; }
// after
[DataMemberRange(0.0, 100.0, 0.1, 1.0, 2)]
public float Speed { get; set; } Defensive patterns
Strategy: validation
Validate before calling
if (min > max)
throw new ArgumentException($"Range is inverted: minimum {min} > maximum {max}.");
// then apply: [DataMemberRange(min, max, smallStep, largeStep, decimals)] Type guard
static bool IsValidRange(double min, double max) => min <= max && !double.IsNaN(min) && !double.IsNaN(max);
Try / catch
try
{
var attr = new DataMemberRangeAttribute(min, max, smallStep, largeStep, decimals);
}
catch (ArgumentException ex)
{
log.Error("Invalid DataMemberRange range: " + ex.Message);
} Prevention
- Keep the argument order memorized: minimum, maximum, smallStep, largeStep, decimalPlaces.
- Use named constants (e.g. MinSpeed, MaxSpeed) instead of bare literals to avoid swaps.
- Unit-test attribute declarations on serialized members to catch inverted ranges at build time.
When it happens
Trigger: Writing [DataMemberRange(10.0, 0.0, 0.1, 1.0, 2)] — minimum greater than maximum. Note smallStep/largeStep ordering and NaN checks run after this check, so a reversed min/max is what triggers this specific message.
Common situations: Stride asset property range definitions where min/max arguments were swapped; refactors that changed the meaning of a bound; copy-pasted attribute lines edited incompletely.
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
- The decimalPlaces should be greater or equal to zero.
- The smallStep should be lesser or equal to the largeStep.
- Cannot add a component of type
- [ ] cannot be null in
- [ . ] must be in
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/29e36f1f956465e3.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core/Annotations/DataMemberRangeAttribute.cs:38
if (double.IsNaN(minimum)) throw new ArgumentOutOfRangeException(nameof(minimum));
if (decimalPlaces < 0) throw new ArgumentException("The decimalPlaces should be greater or equal to zero.", nameof(decimalPlaces));
Minimum = minimum;
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>View on GitHub (pinned to 96fad776d2)