{"record":{"id":"60a646566daaa628","repo":"dotnet/wpf","slug":"sr-scerasepath","errorCode":null,"errorMessage":"SR.SCErasePath","messagePattern":"SR\\.SCErasePath","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/StrokeCollection2.cs","lineNumber":322,"sourceCode":"            }\n        }\n\n\n        /// <summary>\n        /// Erases all ink hit by the contour of an erasing stroke\n        /// </summary>\n        /// <param name=\"eraserShape\">Shape of the eraser</param>\n        /// <param name=\"eraserPath\">a path making the spine of the erasing stroke </param>\n        public void Erase(IEnumerable<Point> eraserPath, StylusShape eraserShape)\n        {\n            // Check the input parameters\n            if (eraserShape == null)\n            {\n                throw new System.ArgumentNullException(SR.SCEraseShape);\n            }\n            if (eraserPath == null)\n            {\n                throw new System.ArgumentNullException(SR.SCErasePath);\n            }\n            if (IEnumerablePointHelper.GetCount(eraserPath) == 0)\n            {\n                return;\n            }\n\n            ErasingStroke erasingStroke = new ErasingStroke(eraserShape, eraserPath);\n            for (int i = 0; i < this.Count; i++)\n            {\n                Stroke stroke = this[i];\n\n                List<StrokeIntersection> intersections = new List<StrokeIntersection>();\n                erasingStroke.EraseTest(StrokeNodeIterator.GetIterator(stroke, stroke.DrawingAttributes), intersections);\n                StrokeCollection eraseResult = stroke.Erase(intersections.ToArray());\n\n                UpdateStrokeCollection(stroke, eraseResult, ref i);\n            }\n        }","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/StrokeCollection2.cs#L304-L340","documentation":"StrokeCollection.Erase(IEnumerable<Point> eraserPath, StylusShape eraserShape) requires a non-null eraser path; a null path throws ArgumentNullException whose message is SR.SCErasePath. The path is the spine along which the eraser shape is swept to remove strokes. An empty path is a no-op, but null is rejected.","triggerScenarios":"Calling the shaped Erase overload with eraserPath == null, e.g. stylus points were never collected, or a nullable point collection variable was passed without a check.","commonSituations":"Erase triggered before any input points were captured; async processing where the path is produced later; porting code from an overload that accepted null silently.","solutions":["Guard: if (eraserPath == null) return; before calling Erase","Ensure the stylus input handler always materializes a point collection, even if empty","Pass an empty collection (which is a no-op) instead of null"],"exampleFix":"// before\nstrokes.Erase(path, shape); // path may be null\n// after\nif (path != null)\n{\n    strokes.Erase(path, shape);\n}","handlingStrategy":"type-guard","validationCode":"if (eraserPath == null) return;","typeGuard":"bool HasPath(IEnumerable<Point> p) => p != null;","tryCatchPattern":"try { strokes.Erase(path, shape); } catch (ArgumentNullException) { /* no path captured: skip */ }","preventionTips":["Materialize point collections in the input handler before dispatching erase","Pass empty collections (no-op) instead of null","Audit nullability of point-collection parameters after refactors"],"tags":["wpf","ink","argument-null","erase"],"backgroundTag":"null-argument","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"}