{"record":{"id":"da9a0f1b24bc6d14","repo":"dotnet/wpf","slug":"if-allgestures-is-specified-it-must-be-the-only","errorCode":null,"errorMessage":"If AllGestures is specified, it must be the only ApplicationGesture in the ApplicationGesture array.","messagePattern":"If AllGestures is specified, it must be the only ApplicationGesture in the ApplicationGesture array\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs","lineNumber":240,"sourceCode":"                if (gesture == ApplicationGesture.AllGestures)\n                {\n                    foundAllGestures = true;\n                }\n\n                //check for dupes\n                if (gestures.Contains(gesture))\n                {\n                    throw new ArgumentException(SR.DuplicateApplicationGestureFound, nameof(applicationGestures));\n                }\n\n                gestures.Add(gesture);\n            }\n\n            // AllGesture cannot be specified with other gestures\n            if (foundAllGestures && gestures.Count != 1)\n            {\n                // no dupes allowed\n                throw new ArgumentException(SR.AllGesturesMustExistAlone, nameof(applicationGestures));\n            }\n\n            return gestures.ToArray();\n        }\n\n        #endregion Internal Methods\n\n        //-------------------------------------------------------------------------------\n        //\n        // IDisposable\n        //\n        //-------------------------------------------------------------------------------\n\n        #region IDisposable\n\n        /// <summary>\n        /// A simple pattern of the dispose implementation.\n        /// There is no finalizer since the SafeHandle will take care of releasing the context.","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs#L222-L258","documentation":"Because ApplicationGesture.AllGestures is a wildcard, it cannot be combined with specific gestures. GetApplicationGestureArrayAndVerify throws ArgumentException (SR.AllGesturesMustExistAlone) if AllGestures appears together with any other gesture in the array passed to EnabledGestures.","triggerScenarios":"Assigning EnabledGestures = new[]{ ApplicationGesture.AllGestures, ApplicationGesture.Down, ... } or appending AllGestures to a specific list.","commonSituations":"'Enable everything plus these extras' configurations; merging an AllGestures default with per-app gesture selections.","solutions":["Use AllGestures alone to enable all gestures","Drop AllGestures from combined lists and rely on the specific gestures only","Normalize: if AllGestures is present, assign new[]{ ApplicationGesture.AllGestures } and ignore the rest"],"exampleFix":"// before\nrecognizer.EnabledGestures = new[] { ApplicationGesture.AllGestures, ApplicationGesture.Down };\n// after\nrecognizer.EnabledGestures = new[] { ApplicationGesture.AllGestures }; // or omit AllGestures and list specific gestures","handlingStrategy":"validation","validationCode":"bool hasAll = gestures.Contains(ApplicationGesture.AllGestures);\nif (hasAll && gestures.Length > 1)\n    throw new ArgumentException(\"AllGestures must be the only entry\", nameof(gestures));","typeGuard":"static bool AllGesturesAlone(ApplicationGesture[] g) => !g.Contains(ApplicationGesture.AllGestures) || g.Length == 1;","tryCatchPattern":"try { recognizer.EnabledGestures = gestures; }\ncatch (ArgumentException) { recognizer.EnabledGestures = new[]{ ApplicationGesture.AllGestures }; }","preventionTips":["If AllGestures is present, assign it alone and skip the rest","Document AllGestures as a wildcard that excludes specific entries","Normalize merged gesture configs before applying"],"tags":["wpf","ink","argument-validation","mutually-exclusive"],"backgroundTag":"mutually-exclusive-options","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"}