{"record":{"id":"cecc2723388998c1","repo":"dotnet/wpf","slug":"sr-rangevaluemax-windowsupdown","errorCode":null,"errorMessage":"SR.RangeValueMax","messagePattern":"SR\\.RangeValueMax","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs","lineNumber":215,"sourceCode":"        #region RangeValue Pattern\n\n        // Change the position of the Up/Down\n        void IRangeValueProvider.SetValue (double val)\n        {\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            {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs#L197-L233","documentation":"SetValue on the Windows Up/Down RangeValue provider throws ArgumentOutOfRangeException with SR.RangeValueMax when the requested value exceeds the control's Maximum. The native updown control has finite bounds and positions above Max are rejected before sending UDM_SETPOS.","triggerScenarios":"Calling RangeValuePattern.SetValue(val) where val > Max (the provider's Maximum property, derived from the control's UDM_GETRANGE). E.g. setting 200 on a spinner whose range tops out at 100.","commonSituations":"Hard-coded test values exceeding the control's configured range; app changed the spinner's Max without updating tests; callers clamping against a stale cached Maximum.","solutions":["Clamp the value to the pattern's Maximum before calling SetValue","Re-read RangeValuePattern.Maximum instead of caching it","Fix the application's UDM_SETRANGE32 configuration if the range is wrong","Catch ArgumentOutOfRangeException and report value/min/max in the test failure"],"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} outside spinner range\"); }","preventionTips":["Clamp to the pattern's live Minimum/Maximum before SetValue","Do not cache Maximum across app reconfigurations","Keep test values in sync with the app's UDM_SETRANGE32 configuration"],"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"}