dotnet/wpf · error · ArgumentException
SR.InvalidStylusPointDescriptionSubset
Error message
SR.InvalidStylusPointDescriptionSubset
What it means
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.
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
Example fix
// before var converted = spc.Reformat(richDescription, null); // after var common = StylusPointDescription.GetCommonDescription(richDescription, spc.Description); var converted = spc.Reformat(common, null);
Defensive patterns
Strategy: validation
Validate before calling
if (!subsetToReformatTo.IsSubsetOf(spc.Description))
subsetToReformatTo = StylusPointDescription.GetCommonDescription(subsetToReformatTo, spc.Description); Type guard
bool CanReformat(StylusPointCollection spc, StylusPointDescription to) => to.IsSubsetOf(spc.Description);
Try / catch
try { var r = spc.Reformat(to, transform); } catch (ArgumentException ex) when (ex.ParamName == "subsetToReformatTo") { var r = spc.Reformat(StylusPointDescription.GetCommonDescription(to, spc.Description), transform); } Prevention
- 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
When it happens
Trigger: Calling spc.Reformat(targetDescription, transform) where targetDescription contains StylusPointProperties absent from spc.Description — e.g. requesting pressure/button properties the device never captured.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- SR.IncompatibleStylusPointDescriptions
- captureMode
- captureMode
- InvalidOperationException
- SR.Format(SR.Enum_Invalid, nameof(actions))
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/1ebf310e358b4743.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointCollection.cs:448
}
/// <summary>
/// Reformat
/// </summary>
/// <param name="subsetToReformatTo">subsetToReformatTo</param>
public StylusPointCollection Reformat(StylusPointDescription subsetToReformatTo)
{
return Reformat(subsetToReformatTo, System.Windows.Media.Transform.Identity);
}
/// <summary>
/// Helper that transforms and scales in one go
/// </summary>
internal StylusPointCollection Reformat(StylusPointDescription subsetToReformatTo, GeneralTransform transform)
{
if (!subsetToReformatTo.IsSubsetOf(this.Description))
{
throw new ArgumentException(SR.InvalidStylusPointDescriptionSubset, nameof(subsetToReformatTo));
}
StylusPointDescription subsetToReformatToWithCurrentMetrics =
StylusPointDescription.GetCommonDescription(subsetToReformatTo,
this.Description); //preserve metrics from this spd
if (StylusPointDescription.AreCompatible(this.Description, subsetToReformatToWithCurrentMetrics) &&
(transform is Transform) && ((Transform)transform).IsIdentity)
{
//subsetToReformatTo might have different x, y, p metrics
return this.Clone(transform, subsetToReformatToWithCurrentMetrics);
}
//
// we really need to reformat this...
//
StylusPointCollection newCollection = new StylusPointCollection(subsetToReformatToWithCurrentMetrics, this.Count);
int additionalDataCount = subsetToReformatToWithCurrentMetrics.GetExpectedAdditionalDataCount();View on GitHub (pinned to 81131a70a4)