{"record":{"id":"4b41cf1d91cfee5a","repo":"dotnet/wpf","slug":"sr-emptyarray","errorCode":null,"errorMessage":"SR.EmptyArray","messagePattern":"SR\\.EmptyArray","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/Stroke2.cs","lineNumber":120,"sourceCode":"        public StrokeCollection GetClipResult(Rect bounds)\n        {\n            return this.GetClipResult(new Point[4] { bounds.TopLeft, bounds.TopRight, bounds.BottomRight, bounds.BottomLeft });\n        }\n\n\n        /// <summary>\n        /// Clip with lasso. Calculate the after-clipping Strokes. Only the \"in-segments\" are left after this operation.\n        /// </summary>\n        /// <param name=\"lassoPoints\">The lasso points to clip with</param>\n        /// <returns>The after-clipping strokes</returns>\n        public StrokeCollection GetClipResult(IEnumerable<Point> lassoPoints)\n        {\n            // Check the input parameters\n            ArgumentNullException.ThrowIfNull(lassoPoints);\n\n            if (IEnumerablePointHelper.GetCount(lassoPoints) == 0)\n            {\n                throw new ArgumentException(SR.EmptyArray);\n            }\n\n            Lasso lasso = new SingleLoopLasso();\n            lasso.AddPoints(lassoPoints);\n            return this.Clip(this.HitTest(lasso));\n        }\n\n\n        /// <summary>\n        /// Erase with a rect. Calculate the after-erasing Strokes. Only the \"out-segments\" are left after this operation.\n        /// </summary>\n        /// <param name=\"bounds\">A Rect to clip with</param>\n        /// <returns>The after-erasing strokes</returns>\n        public StrokeCollection GetEraseResult(Rect bounds)\n        {\n            return this.GetEraseResult(new Point[4] { bounds.TopLeft, bounds.TopRight, bounds.BottomRight, bounds.BottomLeft });\n        }\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/Stroke2.cs#L102-L138","documentation":"Stroke.GetClipResult(IEnumerable<Point> lassoPoints) builds a lasso to hit-test the stroke, and an empty point list cannot form a lasso. The library throws ArgumentException(SR.EmptyArray) when the collection has zero points. Callers must supply at least one Point.","triggerScenarios":"Calling GetClipResult with an empty Point[] or empty IEnumerable<Point>; collecting lasso points from user input that produced no points before calling the API.","commonSituations":"Mouse/stylus handlers that call GetClipResult on a drag that never moved; LINQ filtering that yielded an empty point sequence.","solutions":["Check lassoPoints.Count() > 0 before calling GetClipResult","Return early or skip clipping when the user's lasso gesture has fewer than 1 point","Fall back to GetClipResult with a default bounding region when no points exist"],"exampleFix":"// before\nStrokeCollection clipped = stroke.GetClipResult(lassoPoints);\n// after\nvar pts = lassoPoints.ToList();\nif (pts.Count == 0) return;\nStrokeCollection clipped = stroke.GetClipResult(pts);","handlingStrategy":"validation","validationCode":"bool canClip = lassoPoints is not null && lassoPoints.Any();","typeGuard":"static bool HasPoints(IEnumerable<Point>? pts) => pts is not null && pts.Any();","tryCatchPattern":"try { result = stroke.GetClipResult(pts); } catch (ArgumentException ex) when (ex.ParamName == \"lassoPoints\") { result = new StrokeCollection(); }","preventionTips":["Check point count before any lasso-based Stroke API","Require a minimum gesture length in ink input handlers","Centralize lasso validation in one helper"],"tags":["wpf","ink","empty-collection","lasso"],"backgroundTag":"empty-required-field","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"}