{"record":{"id":"ce656443bc1ac689","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"minimum-value-must-be-lower-than-or-equal-to-the-m","errorCode":null,"errorMessage":"Minimum value must be lower than or equal to the maximum value","messagePattern":"Minimum value must be lower than or equal to the maximum value","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"source/KlocTools/Limited.cs","lineNumber":60,"sourceCode":"            else if (value.CompareTo(min) < 0)\n            {\n                if (throwOutOfRange) throw new ArgumentOutOfRangeException(nameof(value), @\"New value must be equal to or in between the minimum and maximum values\");\n                return min;\n            }\n            return value;\n        }\n\n        /// <summary>\n        /// Minimal value of this variable. If set higher than the current value, the current value is trimmed up.\n        /// Must be lower than or equal to the maximal value.\n        /// </summary>\n        public T Minimum\n        {\n            get { return _minimum; }\n            set\n            {\n                if (value.CompareTo(_maximum) > 0)\n                    throw new ArgumentOutOfRangeException(nameof(value), @\"Minimum value must be lower than or equal to the maximum value\");\n                _minimum = value;\n\n                if (value.CompareTo(_value) > 0)\n                    _value = value;\n            }\n        }\n\n        /// <summary>\n        /// Maximal value of this variable. If set lower than the current value, the current value is trimmed down.\n        /// Must be higher than or equal to the minimal value.\n        /// </summary>\n        public T Maximum\n        {\n            get { return _maximum; }\n            set\n            {\n                if (value.CompareTo(_minimum) < 0)\n                    throw new ArgumentOutOfRangeException(nameof(value), @\"Minimum value must be lower than or equal to the maximum value\");","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/KlocTools/Limited.cs#L42-L78","documentation":"Thrown by the Minimum setter of the Limited<T> range-clamping struct. The setter compares the incoming value against the current _maximum field; if the new minimum is strictly greater than the existing maximum, the invariant min<=max is broken and it raises ArgumentOutOfRangeException. The check uses CompareTo, so it honours the T-specific ordering (numeric, DateTime, etc.). It is thrown eagerly on assignment, before _minimum is updated.","triggerScenarios":"Assigning a value to the Minimum property of an existing Limited<T> instance where the new value.CompareTo(_maximum) > 0. For example, a Limited<int> with Maximum=10 and you set Minimum=20.","commonSituations":"Loading saved application settings where the max bound was lowered but the persisted min was not, UI sliders whose bounds are recomputed independently, and refactors that swap the order of bound initialisation so Maximum is shrunk before Minimum.","solutions":["Set Maximum to the larger value first, or set Minimum to a value <= the current Maximum, before assigning.","Recalculate both bounds from one source of truth and apply them largest-first (Maximum then Minimum).","Wrap the assignment in a try/catch(ArgumentOutOfRangeException) and clamp the input to Maximum before retrying."],"exampleFix":"// before\nvar lim = new Limited<int>(5, 0, 10);\nlim.Minimum = 20; // throws\n\n// after\nlim.Maximum = 20;\nlim.Minimum = 20;","handlingStrategy":"validation","validationCode":"// Before setting Minimum, ensure it does not exceed Maximum\nif (newMin.CompareTo(lim.Maximum) > 0)\n    newMin = lim.Maximum;\nlim.Minimum = newMin;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat Minimum and Maximum as a pair; update the larger bound first when raising, the smaller first when lowering.","Centralise bound updates behind a SetBounds(min,max) helper that normalises order.","Unit-test bound transitions at the extremes (min==max, swap order)."],"tags":["validation","range","csharp","kloctools"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}