{"record":{"id":"81783f0956267f2d","repo":"dotnet/wpf","slug":"sr-stylus-styluspointscantbeempty","errorCode":null,"errorMessage":"SR.Stylus_StylusPointsCantBeEmpty","messagePattern":"SR\\.Stylus_StylusPointsCantBeEmpty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInput.cs","lineNumber":107,"sourceCode":"        /// <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);\n            }\n            if (_customData == null)\n            {\n                _customData = new RawStylusInputCustomDataList();","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInput.cs#L89-L125","documentation":"ArgumentException from RawStylusInput.SetStylusPoints when the replacement StylusPointCollection is empty (after passing the null and description-compatibility checks) — a stylus input report must contain at least one point.","triggerScenarios":"Calling SetStylusPoints with a StylusPointCollection whose Count is 0 — e.g. after filtering all points out or passing a freshly created empty collection.","commonSituations":"A StylusPlugIn filters points by some criterion (range, pressure) and every point is filtered out, then the now-empty collection is passed back via SetStylusPoints.","solutions":["Guard before calling: if stylusPoints.Count > 0 then call SetStylusPoints, otherwise skip the call (leave original points intact)","Ensure your filtering logic always retains at least one point or falls back to the original collection"],"exampleFix":"// before\nrawStylusInput.SetStylusPoints(filtered);\n// after\nif (filtered.Count > 0)\n{\n    rawStylusInput.SetStylusPoints(filtered);\n}","handlingStrategy":"validation","validationCode":"if (points == null || points.Count == 0) return; // skip SetStylusPoints","typeGuard":null,"tryCatchPattern":"try { rawStylusInput.SetStylusPoints(points); } catch (ArgumentException ex) when (ex.ParamName == \"stylusPoints\") { /* keep original points */ }","preventionTips":["Check Count > 0 before calling SetStylusPoints","Make point filters guarantee at least one retained point or skip the update"],"tags":["wpf","stylus","empty-collection"],"backgroundTag":"empty-required-field","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"}