{"record":{"id":"5d19e222842050a6","repo":"dotnet/wpf","slug":"sr-rangevaluemin-windowsupdown","errorCode":null,"errorMessage":"SR.RangeValueMin","messagePattern":"SR\\.RangeValueMin","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs","lineNumber":219,"sourceCode":"        {\n            // Make sure that the control is enabled\n            if (!SafeNativeMethods.IsWindowEnabled (_hwnd))\n            {\n                throw new ElementNotEnabledException();\n            }\n\n            if (double.IsNaN(val))\n            {\n                throw new ArgumentException(SR.InvalidParameter);\n            }\n\n            if (val > Max)\n            {\n                throw new ArgumentOutOfRangeException(\"value\", val, SR.RangeValueMax);\n            }\n            else if (val < Min)\n            {\n                throw new ArgumentOutOfRangeException(\"value\", val, SR.RangeValueMin);\n            }\n\n            short newPos = Convert.ToInt16(val);\n            Misc.ProxySendMessage(_hwnd, NativeMethods.UDM_SETPOS, IntPtr.Zero, NativeMethods.Util.MAKELPARAM(newPos, 0));\n\n            // Scroll the buddy\n            Misc.ProxySendMessage(HwndBuddy(_hwnd), NativeMethods.WM_HSCROLL, NativeMethods.Util.MAKELPARAM(NativeMethods.SB_THUMBPOSITION, newPos), IntPtr.Zero);\n        }\n\n        // Request to get the value that this UI element is representing in a native format\n        double IRangeValueProvider.Value\n        {\n            get\n            {\n                return Pos;\n            }\n        }\n","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs#L201-L237","documentation":"SetValue on the Windows Up/Down RangeValue provider throws ArgumentOutOfRangeException with SR.RangeValueMin when the requested value is below the control's Minimum. Positions below Min cannot be represented by the native updown control, so the value is rejected before UDM_SETPOS is sent.","triggerScenarios":"Calling RangeValuePattern.SetValue(val) where val < Min (from the control's UDM_GETRANGE). E.g. setting 0 on a spinner whose minimum is 1, or passing a negative value into an all-positive range.","commonSituations":"Tests assuming spinners start at 0; app changed the spinner's Min; callers clamping against cached bounds; signed/unsigned mismatch with the native range.","solutions":["Clamp the value to the pattern's Minimum before calling SetValue","Re-read RangeValuePattern.Minimum at call time instead of caching","Adjust the application's updown range (UDM_SETRANGE32) if the minimum is wrong","Catch ArgumentOutOfRangeException and include Min/Max in the failure message"],"exampleFix":"// before\nrangeValuePattern.SetValue(value);\n// after\nvar rv = rangeValuePattern.Current;\nrangeValuePattern.SetValue(Math.Min(Math.Max(value, rv.Minimum), rv.Maximum));","handlingStrategy":"validation","validationCode":"var rv = rangeValuePattern.Current;\nvalue = Math.Clamp(value, rv.Minimum, rv.Maximum);","typeGuard":"bool InRange(double v, double min, double max) => v >= min && v <= max;","tryCatchPattern":"try { rangeValuePattern.SetValue(value); }\ncatch (ArgumentOutOfRangeException ex) { log($\"{value} below spinner Minimum {rv.Minimum}\"); }","preventionTips":["Clamp to the pattern's live Minimum/Maximum before SetValue","Re-read Minimum at call time instead of hard-coding 0","Account for signed/unsigned native range semantics"],"tags":["uiautomation","wpf","argumentoutofrange","spinnervalue"],"backgroundTag":"value-out-of-range","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}