{"record":{"id":"c803e98326cb3677","repo":"dotnet/wpf","slug":"sr-strokecollectioncounttoobig","errorCode":null,"errorMessage":"SR.StrokeCollectionCountTooBig","messagePattern":"SR\\.StrokeCollectionCountTooBig","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/GestureRecognizer.cs","lineNumber":164,"sourceCode":"        /// <returns></returns>\n        // Built into Core, also used by Framework.\n        internal ReadOnlyCollection<GestureRecognitionResult> CriticalRecognize(StrokeCollection strokes)\n        {\n            return RecognizeImpl(strokes);\n        }\n\n        /// <summary>\n        /// Performs gesture recognition on the StrokeCollection if a gesture recognizer\n        /// is present and installed on the system.\n        /// </summary>\n        /// <param name=\"strokes\">The StrokeCollection to perform gesture recognition on</param>\n        /// <returns></returns>\n        private ReadOnlyCollection<GestureRecognitionResult> RecognizeImpl(StrokeCollection strokes)\n        {\n            ArgumentNullException.ThrowIfNull(strokes);\n            if (strokes.Count > 2)\n            {\n                throw new ArgumentException(SR.StrokeCollectionCountTooBig, nameof(strokes));\n            }\n            VerifyAccess();\n            VerifyDisposed();\n            VerifyRecognizerAvailable();\n\n            return new ReadOnlyCollection<GestureRecognitionResult>(_nativeRecognizer.Recognize(strokes));\n        }\n\n        \n\n        #endregion Public Methods\n\n        //-------------------------------------------------------------------------------\n        //\n        // Public Properties\n        //\n        //-------------------------------------------------------------------------------\n","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/GestureRecognizer.cs#L146-L182","documentation":"GestureRecognizer.Recognize accepts at most 2 strokes per recognition call; larger StrokeCollections throw ArgumentException (SR.StrokeCollectionCountTooBig). Gesture recognition in WPF is defined for one- and two-stroke gestures only.","triggerScenarios":"Calling recognizer.Recognize(strokes) (or CriticalRecognize) with strokes.Count > 2.","commonSituations":"Passing an entire ink page's strokes instead of individual gestures; batching strokes for performance and exceeding the limit; misunderstanding that the API is per-gesture, not per-document.","solutions":["Split the StrokeCollection into groups of at most 2 strokes and call Recognize per group","Assert strokes.Count is 1 or 2 before calling","If multi-stroke analysis is needed, use InkAnalyzer instead of GestureRecognizer"],"exampleFix":"// before\nvar results = recognizer.Recognize(allStrokes);\n// after\nforeach (var chunk in Chunk(allStrokes, 2)) results.AddRange(recognizer.Recognize(chunk));","handlingStrategy":"validation","validationCode":"if (strokes == null || strokes.Count == 0 || strokes.Count > 2) return; // invalid input for Recognize","typeGuard":"static bool CanRecognize(StrokeCollection s) => s != null && s.Count is >= 1 and <= 2;","tryCatchPattern":"try { results = recognizer.Recognize(strokes); } catch (ArgumentException) { results = EmptyResults; }","preventionTips":["Chunk stroke collections into pairs before recognition","Remember GestureRecognizer is per-gesture (1–2 strokes), not per-document","Use InkAnalyzer for larger-scale ink analysis"],"tags":["wpf","ink","argumentexception","gesture-recognition","count-limit"],"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-21T21:30:21.729Z"}