{"record":{"id":"93ae28a4919240a8","repo":"dotnet/wpf","slug":"sr-invalidparameter-windowsupdown","errorCode":null,"errorMessage":"SR.InvalidParameter","messagePattern":"SR\\.InvalidParameter","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs","lineNumber":210,"sourceCode":"            return this;\n        }\n\n        #endregion\n\n        #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","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs#L192-L228","documentation":"IRangeValueProvider.SetValue on the Windows Up/Down proxy throws ArgumentException(SR.InvalidParameter) when the requested value is double.NaN. NaN is not a representable position for the native UDM_SETPOS control, so the provider rejects it as an invalid parameter.","triggerScenarios":"Calling RangeValuePattern.SetValue(double.NaN) on a Spinner element. Any automation caller passing an unset/uninitialized double (default comparisons or computed NaN) reaches this check after the enabled check passes.","commonSituations":"Test data binding bugs where a NaN leaks from a computation; callers using double fields never initialized; frameworks that pass through RangeValue.CurrentValue-like NaN sentinels.","solutions":["Validate the value is a real number (double.IsNaN / IsFinite) before calling SetValue","Fix the upstream calculation producing NaN","Clamp/default NaN inputs to Min or a configured default before invoking the pattern","Catch ArgumentException around SetValue and log the offending value"],"exampleFix":"// before\nrangeValuePattern.SetValue(value); // value may be NaN\n// after\nif (double.IsNaN(value)) value = rangeValuePattern.Current.Minimum;\nrangeValuePattern.SetValue(value);","handlingStrategy":"validation","validationCode":"if (double.IsNaN(value) || double.IsInfinity(value)) value = rangeValuePattern.Current.Minimum;","typeGuard":"bool IsValidSpinnerValue(double v) => !double.IsNaN(v) && !double.IsInfinity(v);","tryCatchPattern":"try { rangeValuePattern.SetValue(value); }\ncatch (ArgumentException) { log($\"Invalid spinner value: {value}\"); }","preventionTips":["Sanitize computed doubles (NaN/Infinity) before pattern calls","Initialize all double variables used as automation inputs","Validate test data at the source"],"tags":["uiautomation","wpf","argument","nan","spinnervalue"],"backgroundTag":"invalid-argument-value","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"}