{"record":{"id":"29e36f1f956465e3","repo":"stride3d/stride","slug":"the-minimum-should-be-lesser-or-equal-to-the-maximum","errorCode":null,"errorMessage":"The minimum should be lesser or equal to the maximum.","messagePattern":"The minimum should be lesser or equal to the maximum\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core/Annotations/DataMemberRangeAttribute.cs","lineNumber":38,"sourceCode":"        if (double.IsNaN(minimum)) throw new ArgumentOutOfRangeException(nameof(minimum));\n        if (decimalPlaces < 0) throw new ArgumentException(\"The decimalPlaces should be greater or equal to zero.\", nameof(decimalPlaces));\n        Minimum = minimum;\n        DecimalPlaces = decimalPlaces;\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"DataMemberRangeAttribute\" /> class.\n    /// </summary>\n    /// <param name=\"minimum\">The minimum.</param>\n    /// <param name=\"maximum\">The maximum.</param>\n    /// <param name=\"smallStep\">The minimum step used to go from minimum to maximum.</param>\n    /// <param name=\"largeStep\">The maximum step used to go from minimum to maximum.</param>\n    /// <param name=\"decimalPlaces\">The decimal places.</param>\n    public DataMemberRangeAttribute(double minimum, double maximum, double smallStep, double largeStep, int decimalPlaces)\n        : this(minimum, decimalPlaces)\n    {\n        if (double.IsNaN(maximum)) throw new ArgumentOutOfRangeException(nameof(maximum));\n        if (minimum > maximum) throw new ArgumentException(\"The minimum should be lesser or equal to the maximum.\", nameof(minimum));\n        if (double.IsNaN(smallStep)) throw new ArgumentOutOfRangeException(nameof(smallStep));\n        if (double.IsNaN(largeStep)) throw new ArgumentOutOfRangeException(nameof(largeStep));\n        if (smallStep > largeStep) throw new ArgumentException(\"The smallStep should be lesser or equal to the largeStep.\", nameof(smallStep));\n        if (decimalPlaces < 0) throw new ArgumentException(\"The decimalPlaces should be greater or equal to zero.\", nameof(decimalPlaces));\n        Maximum = maximum;\n        SmallStep = smallStep;\n        LargeStep = largeStep;\n    }\n\n    /// <summary>\n    /// Gets the minimum inclusive.\n    /// </summary>\n    /// <value>The minimum.</value>\n    public double? Minimum { get; }\n\n    /// <summary>\n    /// Gets the maximum inclusive.\n    /// </summary>","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core/Annotations/DataMemberRangeAttribute.cs#L20-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\n[DataMemberRange(100.0, 0.0, 0.1, 1.0, 2)]\npublic float Speed { get; set; }\n// after\n[DataMemberRange(0.0, 100.0, 0.1, 1.0, 2)]\npublic float Speed { get; set; }","handlingStrategy":"validation","validationCode":"if (min > max)\n    throw new ArgumentException($\"Range is inverted: minimum {min} > maximum {max}.\");\n// then apply: [DataMemberRange(min, max, smallStep, largeStep, decimals)]","typeGuard":"static bool IsValidRange(double min, double max) => min <= max && !double.IsNaN(min) && !double.IsNaN(max);","tryCatchPattern":"try\n{\n    var attr = new DataMemberRangeAttribute(min, max, smallStep, largeStep, decimals);\n}\ncatch (ArgumentException ex)\n{\n    log.Error(\"Invalid DataMemberRange range: \" + ex.Message);\n}","preventionTips":["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."],"tags":["invalid-argument-value","csharp","attributes"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}