{"record":{"id":"8b7dc07753965d59","repo":"dotnet/wpf","slug":"sr-emptyarraynotallowedasargument","errorCode":null,"errorMessage":"SR.EmptyArrayNotAllowedAsArgument","messagePattern":"SR\\.EmptyArrayNotAllowedAsArgument","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/IncrementalHitTester.cs","lineNumber":41,"sourceCode":"        /// Adds a point representing an incremental move of the hit-testing tool\n        /// </summary>\n        /// <param name=\"point\">a point that represents an incremental move of the hitting tool</param>\n        public void AddPoint(Point point)\n        {\n            AddPoints(new Point[1] { point });\n        }\n\n        /// <summary>\n        /// Adds an array of points representing an incremental move of the hit-testing tool\n        /// </summary>\n        /// <param name=\"points\">points representing an incremental move of the hitting tool</param>\n        public void AddPoints(IEnumerable<Point> points)\n        {\n            ArgumentNullException.ThrowIfNull(points);\n\n            if (IEnumerablePointHelper.GetCount(points) == 0)\n            {\n                throw new System.ArgumentException(SR.EmptyArrayNotAllowedAsArgument, nameof(points));\n            }\n\n            if (!_fValid)\n            {\n                throw new System.InvalidOperationException(SR.EndHitTestingCalled);\n            }\n\n            System.Diagnostics.Debug.Assert(_strokes != null);\n\n            AddPointsCore(points);\n        }\n\n        /// <summary>\n        /// Adds a StylusPacket representing an incremental move of the hit-testing tool\n        /// </summary>\n        /// <param name=\"stylusPoints\">stylusPoints</param>\n        public void AddPoints(StylusPointCollection stylusPoints)\n        {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/IncrementalHitTester.cs#L23-L59","documentation":"IncrementalHitTester.AddPoints(IEnumerable<Point>) rejects empty enumerations with ArgumentException (SR.EmptyArrayNotAllowedAsArgument) because hit-testing requires at least one point. It also throws InvalidOperationException if EndHitTesting was already called (error 508).","triggerScenarios":"Calling AddPoints with an empty Point collection/array; calling via AddPoint delegation with an empty source.","commonSituations":"Hit-testing against a stroke whose collected point list is empty (stroke captured with no samples); passing a filtered point set where the filter removed everything.","solutions":["Check points has at least 1 point before calling AddPoints","Skip hit-testing entirely for empty point sets"],"exampleFix":"// before\nhitTester.AddPoints(points);\n// after\nif (points != null && points.Any()) hitTester.AddPoints(points);","handlingStrategy":"validation","validationCode":"if (points == null || !points.Any()) return;","typeGuard":"static bool HasPoints(IEnumerable<Point> p) => p != null && p.Any();","tryCatchPattern":"try { tester.AddPoints(points); } catch (ArgumentException) { /* empty point set — nothing to hit-test */ } catch (InvalidOperationException) { /* EndHitTesting already called */ }","preventionTips":["Guard all point sources against empty collections","Early-return from stylus handlers when no packets arrived","Never feed filtered point lists without a count check"],"tags":["wpf","ink","argumentexception","empty-collection","hit-testing"],"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-21T21:30:21.729Z"}