{"record":{"id":"1ebf310e358b4743","repo":"dotnet/wpf","slug":"sr-invalidstyluspointdescriptionsubset","errorCode":null,"errorMessage":"SR.InvalidStylusPointDescriptionSubset","messagePattern":"SR\\.InvalidStylusPointDescriptionSubset","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointCollection.cs","lineNumber":448,"sourceCode":"        }\n\n        /// <summary>\n        /// Reformat\n        /// </summary>\n        /// <param name=\"subsetToReformatTo\">subsetToReformatTo</param>\n        public StylusPointCollection Reformat(StylusPointDescription subsetToReformatTo)\n        {\n            return Reformat(subsetToReformatTo, System.Windows.Media.Transform.Identity);\n        }\n\n        /// <summary>\n        /// Helper that transforms and scales in one go\n        /// </summary>\n        internal StylusPointCollection Reformat(StylusPointDescription subsetToReformatTo, GeneralTransform transform)\n        {\n            if (!subsetToReformatTo.IsSubsetOf(this.Description))\n            {\n                throw new ArgumentException(SR.InvalidStylusPointDescriptionSubset, nameof(subsetToReformatTo));\n            }\n\n            StylusPointDescription subsetToReformatToWithCurrentMetrics =\n                StylusPointDescription.GetCommonDescription(subsetToReformatTo, \n                                                            this.Description); //preserve metrics from this spd\n\n            if (StylusPointDescription.AreCompatible(this.Description, subsetToReformatToWithCurrentMetrics) && \n                (transform is Transform) && ((Transform)transform).IsIdentity)\n            {\n                //subsetToReformatTo might have different x, y, p metrics\n                return this.Clone(transform, subsetToReformatToWithCurrentMetrics);\n            }\n\n            //\n            // we really need to reformat this...\n            //\n            StylusPointCollection newCollection = new StylusPointCollection(subsetToReformatToWithCurrentMetrics, this.Count);\n            int additionalDataCount = subsetToReformatToWithCurrentMetrics.GetExpectedAdditionalDataCount();","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointCollection.cs#L430-L466","documentation":"StylusPointCollection.Reformat(StylusPointDescription, GeneralTransform) throws ArgumentException when subsetToReformatTo is not a subset of the collection's current Description. Reformat can only drop or keep properties; it cannot invent packet properties the source points don't already carry.","triggerScenarios":"Calling spc.Reformat(targetDescription, transform) where targetDescription contains StylusPointProperties absent from spc.Description — e.g. requesting pressure/button properties the device never captured.","commonSituations":"Converting strokes to a richer description expected by a downstream API; reformatting to a hardcoded description that doesn't match the actual tablet hardware's packet properties.","solutions":["Build the target description as a subset of spc.Description (e.g. via StylusPointDescription.GetCommonDescription)","Check subsetToReformatTo.IsSubsetOf(spc.Description) before calling Reformat","Re-capture stylus data with the needed packet properties instead of reformating existing points"],"exampleFix":"// before\nvar converted = spc.Reformat(richDescription, null);\n// after\nvar common = StylusPointDescription.GetCommonDescription(richDescription, spc.Description);\nvar converted = spc.Reformat(common, null);","handlingStrategy":"validation","validationCode":"if (!subsetToReformatTo.IsSubsetOf(spc.Description))\n    subsetToReformatTo = StylusPointDescription.GetCommonDescription(subsetToReformatTo, spc.Description);","typeGuard":"bool CanReformat(StylusPointCollection spc, StylusPointDescription to) => to.IsSubsetOf(spc.Description);","tryCatchPattern":"try { var r = spc.Reformat(to, transform); } catch (ArgumentException ex) when (ex.ParamName == \"subsetToReformatTo\") { var r = spc.Reformat(StylusPointDescription.GetCommonDescription(to, spc.Description), transform); }","preventionTips":["Derive target descriptions from the source description, never hardcode them","Use GetCommonDescription to intersect property sets","Request only packet properties the capturing device actually provided"],"tags":["wpf","stylus","incompatible-description"],"backgroundTag":"schema-validation-failed","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"}