{"record":{"id":"81721ededaf95836","repo":"dotnet/wpf","slug":"sr-invalidpoint","errorCode":null,"errorMessage":"SR.InvalidPoint","messagePattern":"SR\\.InvalidPoint","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/InkCanvas.cs","lineNumber":1842,"sourceCode":"            // No need to call VerifyAccess since this call is forwarded.\n\n            // We always paste the data to the default location which is (0,0).\n            Paste(new Point(c_pasteDefaultLocation, c_pasteDefaultLocation));\n        }\n\n        /// <summary>\n        /// Paste the contents of the clipboard to the specified location in the InkCanvas\n        /// </summary>\n        public void Paste(Point point)\n        {\n            VerifyAccess();\n\n            if (double.IsNaN(point.X) ||\n                double.IsNaN(point.Y) ||\n                Double.IsInfinity(point.X)||\n                Double.IsInfinity(point.Y) )\n            {\n                    throw new ArgumentException(SR.InvalidPoint, nameof(point));\n            }\n\n\n            //\n            // only do this if the user is not editing (input active)\n            // or we will violate a dispatcher lock\n            //\n            if (!_editingCoordinator.UserIsEditing)\n            {\n                IDataObject dataObj = null;\n                try\n                {\n                    dataObj = Clipboard.GetDataObject();\n                }\n                catch (ExternalException)\n                {\n                    //harden against ExternalException\n                    return;","sourceCodeStart":1824,"sourceCodeEnd":1860,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/InkCanvas.cs#L1824-L1860","documentation":"An InkCanvas public API (point-taking method) validates that the supplied Point contains only finite values. A Point with NaN or Infinity in X or Y is rejected with an ArgumentException (SR.InvalidPoint). Such coordinates cannot participate in ink geometry or layout math.","triggerScenarios":"Calling InkCanvas APIs that take a Point (e.g. stroke positioning/editing methods) with a Point whose X or Y is NaN, +Infinity, or -Infinity — often from uninitialized doubles, division by zero, or failed hit-test results.","commonSituations":"Computing points from transforms with zero determinant; deserializing coordinates where NaN slips in; default/uninitialized struct fields producing NaN.","solutions":["Validate the Point for NaN/Infinity before passing it (double.IsFinite on X and Y)","Fix the upstream computation producing non-finite coordinates (guard divisions, initialize fields)","Clamp or substitute a default finite point when a computation fails"],"exampleFix":"// before\ninkCanvas.SomePointMethod(new Point(x, y)); // x/y may be NaN\n// after\nif (double.IsFinite(x) && double.IsFinite(y)) { inkCanvas.SomePointMethod(new Point(x, y)); }","handlingStrategy":"validation","validationCode":"bool IsValid(Point p) => double.IsFinite(p.X) && double.IsFinite(p.Y);","typeGuard":"bool IsFinitePoint(Point p) => !double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsInfinity(p.X) && !double.IsInfinity(p.Y);","tryCatchPattern":"try { inkCanvas.PointMethod(point); } catch (ArgumentException ex) when (ex.ParamName == \"point\") { /* reject or sanitize the point */ }","preventionTips":["Validate all computed Points before passing to InkCanvas APIs","Guard divisions and transforms that can yield NaN/Infinity","Initialize coordinate fields to finite defaults"],"tags":["wpf","inkcanvas","point","validation"],"backgroundTag":"invalid-argument-value","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"}