{"record":{"id":"76376944b655befe","repo":"dotnet/wpf","slug":"argumentnullexception-hittestparameters","errorCode":null,"errorMessage":"ArgumentNullException: hitTestParameters","messagePattern":"ArgumentNullException: hitTestParameters","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextFlow.cs","lineNumber":943,"sourceCode":"        ///<param name=\"child\">Reference to a child UIElement that had AffectsParentMeasure/AffectsParentArrange property invalidated.</param>\n        protected internal sealed override void ParentLayoutInvalidated(UIElement child)\n        {\n            if (child == null)\n            {\n                throw new ArgumentNullException(\"child\");\n            }\n\n            OnChildUIElementChanged(child);\n        }\n\n        /// <summary>\n        /// HitTestCore implements precise hit testing against render contents\n        /// </summary>\n        protected sealed override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)\n        {\n            if (hitTestParameters == null)\n            {\n                throw new ArgumentNullException(\"hitTestParameters\");\n            }\n\n            Rect r = new Rect(new Point(), RenderSize);\n\n            if (r.Contains(hitTestParameters.HitPoint))\n            {\n                return new PointHitTestResult(this, hitTestParameters.HitPoint);\n            }\n\n            return null;\n        }\n\n        /// <summary>\n        ///     Hit tests to the correct ContentElement \n        ///     within the ContentHost that the mouse \n        ///     is over\n        /// </summary>\n        /// <param name=\"point\">","sourceCodeStart":925,"sourceCodeEnd":961,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextFlow.cs#L925-L961","documentation":"TextFlow.HitTestCore (the PointHitTestParameters overload) throws ArgumentNullException when hitTestParameters is null. Precise hit testing needs the hit point carried in the parameters to test against the rendered Rect.","triggerScenarios":"Calling HitTestCore(new PointHitTestParameters(...)) with null, or custom input/hit-test code invoking the protected method directly without constructing parameters.","commonSituations":"Custom hit-testing or input-simulation code paths; unit tests calling HitTestCore directly with null; interop layers that drop the parameters object.","solutions":["Always construct PointHitTestParameters with a valid Point before hit testing","Prefer public HitTest APIs (UIElement.HitTest/VisualTreeHelper.HitTest) which build parameters for you","Null-check parameters in test/interop harnesses before invoking HitTestCore"],"exampleFix":"// before\nvar result = flow.HitTestCore(null);\n\n// after\nvar result = flow.HitTestCore(new PointHitTestParameters(new Point(x, y)));","handlingStrategy":"validation","validationCode":"if (hitTestParameters != null) { var r = flow.HitTestCore(hitTestParameters); }","typeGuard":"bool hasHitPoint(PointHitTestParameters p) => p != null;","tryCatchPattern":"try { result = flow.HitTestCore(p); } catch (ArgumentNullException) { result = null; }","preventionTips":["Use public HitTest entry points which construct parameters automatically","Always build PointHitTestParameters from a real hit Point","Null-check parameters in custom hit-test harnesses and tests"],"tags":["wpf","argumentnull","hit-testing"],"backgroundTag":"null-argument","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"}