{"record":{"id":"27f98d069852eef2","repo":"dotnet/wpf","slug":"sr-automation-invalidsynchronizedinputtype","errorCode":null,"errorMessage":"SR.Automation_InvalidSynchronizedInputType","messagePattern":"SR\\.Automation_InvalidSynchronizedInputType","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/SynchronizedInputAdaptor.cs","lineNumber":38,"sourceCode":"        internal SynchronizedInputAdaptor(DependencyObject owner)\n        {\n            Invariant.Assert(owner != null);\n            _owner = owner;\n        }\n        /// <summary>\n        /// This method is called by automation framework to trigger synchronized input processing.  \n        /// </summary>\n        /// <param name=\"inputType\"> Synchronized input type</param>\n        void ISynchronizedInputProvider.StartListening(SynchronizedInputType inputType)\n        {\n            if (inputType != SynchronizedInputType.KeyDown &&\n                inputType != SynchronizedInputType.KeyUp &&\n                inputType != SynchronizedInputType.MouseLeftButtonDown &&\n                inputType != SynchronizedInputType.MouseLeftButtonUp &&\n                inputType != SynchronizedInputType.MouseRightButtonDown &&\n                inputType != SynchronizedInputType.MouseRightButtonUp)\n            {\n                throw new ArgumentException(SR.Format(SR.Automation_InvalidSynchronizedInputType, inputType));\n            }\n            \n            UIElement e = _owner as UIElement;\n            if (e != null)\n            {\n                if (!e.StartListeningSynchronizedInput(inputType))\n                {\n                    throw new InvalidOperationException(SR.Automation_RecursivePublicCall);\n                }\n            }\n            else\n            {\n                ContentElement ce = _owner as ContentElement;\n                if (ce != null)\n                {\n                    if (!ce.StartListeningSynchronizedInput(inputType))\n                    {\n                        throw new InvalidOperationException(SR.Automation_RecursivePublicCall);","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/SynchronizedInputAdaptor.cs#L20-L56","documentation":"SynchronizedInputAdaptor.StartListening validates that the SynchronizedInputType requested is one of the five supported values (KeyUp, MouseLeftButtonDown/Up, MouseRightButtonDown/Up). Any other value throws ArgumentException with SR.Automation_InvalidSynchronizedInputType naming the bad inputType.","triggerScenarios":"Calling ISynchronizedInputProvider.StartListening with a SynchronizedInputType value outside the supported set — e.g. default(SynchronizedInputType), an out-of-range cast, or an enum member added in a different framework version.","commonSituations":"UIA clients (or test code) passing a raw int cast to SynchronizedInputType; custom providers forwarding client-supplied enum values without validation; version mismatch between client pattern definition and WPF implementation.","solutions":["Pass only SynchronizedInputType.KeyUp/KeyDown/MouseLeftButtonDown/MouseLeftButtonUp/MouseRightButtonDown/MouseRightButtonUp values supported by the API.","Validate with Enum.IsDefined(typeof(SynchronizedInputType), value) before calling StartListening.","Fix casts of raw integers to SynchronizedInputType in client or wrapper code.","Rebuild/re-reference matching UIAutomationClient and PresentationCore versions."],"exampleFix":"// before\nprovider.StartListening((SynchronizedInputType)42);\n// after\nvar type = SynchronizedInputType.MouseLeftButtonUp;\nif (Enum.IsDefined(typeof(SynchronizedInputType), type))\n{\n    provider.StartListening(type);\n}","handlingStrategy":"validation","validationCode":"SynchronizedInputType[] valid =\n{\n    SynchronizedInputType.KeyUp, SynchronizedInputType.MouseLeftButtonDown,\n    SynchronizedInputType.MouseLeftButtonUp, SynchronizedInputType.MouseRightButtonDown,\n    SynchronizedInputType.MouseRightButtonUp\n};\nif (!valid.Contains(inputType)) return;","typeGuard":"bool IsValidSynchronizedInputType(SynchronizedInputType t) =>\n    t is SynchronizedInputType.KeyUp or SynchronizedInputType.MouseLeftButtonDown\n       or SynchronizedInputType.MouseLeftButtonUp or SynchronizedInputType.MouseRightButtonDown\n       or SynchronizedInputType.MouseRightButtonUp;","tryCatchPattern":"try\n{\n    provider.StartListening(inputType);\n}\ncatch (ArgumentException ex)\n{\n    // invalid SynchronizedInputType; correct the enum value\n}","preventionTips":["Use only the documented SynchronizedInputType members","Never cast raw integers to SynchronizedInputType","Validate client-supplied enum values before forwarding to the provider","Keep UIAutomationClient and WPF assembly versions in sync"],"tags":["wpf","ui-automation","argumentexception","invalid-enum","synchronized-input"],"backgroundTag":"invalid-enum-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}