dotnet/wpf · error · ArgumentException
SR.Stylus_InvalidMax
Error message
SR.Stylus_InvalidMax
What it means
StylusPointPropertyInfo's constructor validates that the maximum value of a stylus point property is not less than its minimum. When maximum < minimum, the ArgumentException SR.Stylus_InvalidMax is thrown with the parameter name 'maximum'. This guards the invariant that a property's valid range is well-ordered.
Solutions
- Swap the minimum and maximum arguments so maximum >= minimum
- Compute min/max with Math.Min/Math.Max over the measured range before constructing
- Log or assert the input range at the call site to catch inverted axis data at the source
Example fix
// before new StylusPointPropertyInfo(prop, StylusPointPropertyUnit.Inches, 400f, 100, 0); // after new StylusPointPropertyInfo(prop, StylusPointPropertyUnit.Inches, 400f, 0, 100);
Defensive patterns
Strategy: validation
Validate before calling
if (maximum < minimum) throw new ArgumentException("maximum must be >= minimum", nameof(maximum));
var info = new StylusPointPropertyInfo(prop, unit, resolution, minimum, maximum); Try / catch
try { var info = new StylusPointPropertyInfo(prop, unit, res, min, max); }
catch (ArgumentException ex) when (ex.ParamName == "maximum") { /* fix ordering or log bad device data */ } Prevention
- Always construct ranges as (min, max) in that order
- Use Math.Min/Math.Max over measured axis data
- Add unit tests for device description parsing
When it happens
Trigger: Calling the public StylusPointPropertyInfo constructor (or GetStylusPointPropertyInfo-style overloads) passing a maximum smaller than the minimum, e.g. new StylusPointPropertyInfo(id, StylusPointPropertyUnit.Inches, resolution, 100, 0).
Common situations: Hand-transcribing digitizer description data from device specs where axis ranges are swapped or negative; computing min/max from runtime data where the axis is inverted; copy-paste typos in hard-coded property descriptions.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- captureMode
- SR.InvalidStylusPointConstructionZeroLengthCollection
- SR.InvalidStylusPointPropertyInfoResolution
- SR.Stylus_MatrixNotInvertable
- ' ' is not a valid value for ' '.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/7bd2caf4cfb18cd8.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointPropertyInfo.cs:56
/// </summary>
/// <param name="stylusPointProperty"></param>
/// <param name="minimum">minimum</param>
/// <param name="maximum">maximum</param>
/// <param name="unit">unit</param>
/// <param name="resolution">resolution</param>
public StylusPointPropertyInfo(StylusPointProperty stylusPointProperty, int minimum, int maximum, StylusPointPropertyUnit unit, float resolution)
: base(stylusPointProperty) //base checks for null
{
// validate unit
if (!StylusPointPropertyUnitHelper.IsDefined(unit))
{
throw new InvalidEnumArgumentException("unit", (int)unit, typeof(StylusPointPropertyUnit));
}
// validate min/max
if (maximum < minimum)
{
throw new ArgumentException(SR.Stylus_InvalidMax, nameof(maximum));
}
// validate resolution
if (resolution < 0.0f)
{
throw new ArgumentException(SR.InvalidStylusPointPropertyInfoResolution, nameof(resolution));
}
_min = minimum;
_max = maximum;
_resolution = resolution;
_unit = unit;
}
/// <summary>
/// Minimum
/// </summary>
public int MinimumView on GitHub (pinned to 81131a70a4)