{"record":{"id":"015665076a1b4410","repo":"dotnet/wpf","slug":"sr-incompatiblestyluspointdescriptions","errorCode":null,"errorMessage":"SR.IncompatibleStylusPointDescriptions","messagePattern":"SR\\.IncompatibleStylusPointDescriptions","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInput.cs","lineNumber":103,"sourceCode":"                return _stylusPoints.Clone(transform, _stylusPoints.Description);\n            }\n        }\n\n        /// <summary>\n        /// Replaces the StylusPoints.\n        /// </summary>\n        /// <remarks>\n        ///     Callers must have Unmanaged code permission to call this API.\n        /// </remarks>\n        /// <param name=\"stylusPoints\">stylusPoints</param>\n        public void SetStylusPoints(StylusPointCollection stylusPoints)\n        {\n            ArgumentNullException.ThrowIfNull(stylusPoints);\n\n            if (!StylusPointDescription.AreCompatible(  stylusPoints.Description,\n                                                        _report.StylusPointDescription))\n            {\n                throw new ArgumentException(SR.IncompatibleStylusPointDescriptions, nameof(stylusPoints));\n            }\n            if (stylusPoints.Count == 0)\n            {\n                throw new ArgumentException(SR.Stylus_StylusPointsCantBeEmpty, nameof(stylusPoints));\n            }\n\n            _stylusPoints = stylusPoints.Clone();\n        }\n\n        /// <summary>\n        /// Returns the RawStylusInputCustomDataList used to notify plugins before  \n        /// PreviewStylus event has been processed by application.\n        /// </summary>\n        public void NotifyWhenProcessed(object callbackData)\n        {\n            if (_currentNotifyPlugIn == null)\n            {\n                throw new InvalidOperationException(SR.Stylus_CanOnlyCallForDownMoveOrUp);","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInput.cs#L85-L121","documentation":"RawStylusInput.SetStylusPoints replaces the stylus point collection carried by a raw stylus input packet. The new collection's StylusPointDescription must be compatible (same required point properties) with the description of the underlying RawStylusInputReport; WPF throws this ArgumentException otherwise because mixing descriptions would corrupt downstream StylusPlugIn processing.","triggerScenarios":"Calling SetStylusPoints with a StylusPoints collection whose Description was built with a different set of optional properties (e.g. added/removed StylusPointPropertyInfo like Pressure, TangentPressure, tilt) than the description captured in the report that raised the event.","commonSituations":"A StylusPlugIn.OnStylusDown/OnStylusMove handler creates new StylusPoints from scratch (default description) instead of reusing stylusPoints.Description from the incoming event, so on tablet hardware with extra packet properties the descriptions do not match.","solutions":["Base replacement points on the existing description: clone or copy the incoming StylusPoints and modify values rather than constructing a new StylusPointCollection with a default/new description","Pass stylusPoints.Description (the incoming collection's description) when creating the new StylusPointCollection","Call StylusPointDescription.AreCompatible(newDesc, oldDesc) in debug code to verify compatibility before calling SetStylusPoints"],"exampleFix":"// before\nvar newPts = new StylusPointCollection();\nnewPts.Add(new StylusPoint(x, y));\nrawStylusInput.SetStylusPoints(newPts);\n// after\nStylusPointCollection newPts = new StylusPointCollection(stylusPoints.Description);\nnewPts.Add(new StylusPoint(x, y));\nrawStylusInput.SetStylusPoints(newPts);","handlingStrategy":"validation","validationCode":"if (!StylusPointDescription.AreCompatible(newPoints.Description, incoming.Description)) throw new InvalidOperationException(\"Incompatible StylusPointDescription\");","typeGuard":null,"tryCatchPattern":"try { rawStylusInput.SetStylusPoints(newPoints); } catch (ArgumentException ex) when (ex.ParamName == \"stylusPoints\") { /* fall back to original points */ }","preventionTips":["Always construct replacement StylusPointCollections from the incoming collection's Description","Never build points with the default description inside StylusPlugIn handlers","Assert AreCompatible in debug builds"],"tags":["wpf","stylus","argument-exception"],"backgroundTag":"incompatible-source-type","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"}