{"record":{"id":"7bd2caf4cfb18cd8","repo":"dotnet/wpf","slug":"sr-stylus-invalidmax","errorCode":null,"errorMessage":"SR.Stylus_InvalidMax","messagePattern":"SR\\.Stylus_InvalidMax","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointPropertyInfo.cs","lineNumber":56,"sourceCode":"        /// </summary>\n        /// <param name=\"stylusPointProperty\"></param>\n        /// <param name=\"minimum\">minimum</param>\n        /// <param name=\"maximum\">maximum</param>\n        /// <param name=\"unit\">unit</param>\n        /// <param name=\"resolution\">resolution</param>\n        public StylusPointPropertyInfo(StylusPointProperty stylusPointProperty, int minimum, int maximum, StylusPointPropertyUnit unit, float resolution)\n            : base(stylusPointProperty) //base checks for null\n        {\n            // validate unit\n            if (!StylusPointPropertyUnitHelper.IsDefined(unit))\n            {\n                throw new InvalidEnumArgumentException(\"unit\", (int)unit, typeof(StylusPointPropertyUnit));\n            }\n\n            // validate min/max\n            if (maximum < minimum)\n            {\n                throw new ArgumentException(SR.Stylus_InvalidMax, nameof(maximum));\n            }\n\n            // validate resolution\n            if (resolution < 0.0f)\n            {\n                throw new ArgumentException(SR.InvalidStylusPointPropertyInfoResolution, nameof(resolution));\n            }\n\n            _min = minimum;\n            _max = maximum;\n            _resolution = resolution;\n            _unit = unit;\n        }\n\n        /// <summary>\n        /// Minimum\n        /// </summary>\n        public int Minimum","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointPropertyInfo.cs#L38-L74","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nnew StylusPointPropertyInfo(prop, StylusPointPropertyUnit.Inches, 400f, 100, 0);\n// after\nnew StylusPointPropertyInfo(prop, StylusPointPropertyUnit.Inches, 400f, 0, 100);","handlingStrategy":"validation","validationCode":"if (maximum < minimum) throw new ArgumentException(\"maximum must be >= minimum\", nameof(maximum));\nvar info = new StylusPointPropertyInfo(prop, unit, resolution, minimum, maximum);","typeGuard":null,"tryCatchPattern":"try { var info = new StylusPointPropertyInfo(prop, unit, res, min, max); }\ncatch (ArgumentException ex) when (ex.ParamName == \"maximum\") { /* fix ordering or log bad device data */ }","preventionTips":["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"],"tags":["wpf","stylus","argument-validation"],"backgroundTag":"value-out-of-range","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"}