{"record":{"id":"4657e5c2a88099a3","repo":"dotnet/wpf","slug":"sr-eventargisnull-stroke","errorCode":null,"errorMessage":"SR.EventArgIsNull","messagePattern":"SR\\.EventArgIsNull","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/Stroke.cs","lineNumber":586,"sourceCode":"        /// </summary>\n        event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged\n        {\n            add { _propertyChanged += value; }\n            remove { _propertyChanged -= value; }\n        }\n\n        /// <summary>\n        /// Method called on derived classes whenever a drawing attribute\n        /// is changed and event listeners must be notified.\n        /// </summary>\n        /// <param name=\"e\">Information on the drawing attributes that changed</param>\n        /// <remarks>Derived classes should call this method (their base class)\n        /// to ensure that event listeners are notified</remarks>\n        protected virtual void OnDrawingAttributesChanged(PropertyDataChangedEventArgs e)\n        {\n            if (null == e)\n            {\n                throw new ArgumentNullException(nameof(e), SR.EventArgIsNull);\n            }\n\n            if (DrawingAttributesChanged != null)\n            {\n                DrawingAttributesChanged(this, e);\n            }\n        }\n\n        /// <summary>\n        /// Protected virtual version for developers deriving from InkCanvas.\n        /// This method is what actually throws the event.\n        /// </summary>\n        /// <param name=\"e\">DrawingAttributesReplacedEventArgs to raise the event with</param>\n        protected virtual void OnDrawingAttributesReplaced(DrawingAttributesReplacedEventArgs e)\n        {\n            ArgumentNullException.ThrowIfNull(e);\n            if (null != this.DrawingAttributesReplaced)\n            {","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/Stroke.cs#L568-L604","documentation":"The protected virtual OnDrawingAttributesChanged method requires a non-null PropertyDataChangedEventArgs; it throws ArgumentNullException with SR.EventArgIsNull if null is passed. Derived classes that raise the DrawingAttributesChanged event must supply a valid event-args instance.","triggerScenarios":"A Stroke subclass calling base.OnDrawingAttributesChanged(null), or overriding DrawingAttributes change plumbing and forwarding a null args from DrawingAttributes_Changed.","commonSituations":"Custom ink classes derived from Stroke raising events conditionally where the args variable was never assigned; refactoring that dropped args construction.","solutions":["Pass a constructed PropertyDataChangedEventArgs (oldValue, newValue, propertyGuid) to OnDrawingAttributesChanged","Null-check event args in the derived raiser before calling the base method","If there is nothing to report, do not call the On* method instead of passing null"],"exampleFix":"// before\nOnDrawingAttributesChanged(null);\n// after\nOnDrawingAttributesChanged(new PropertyDataChangedEventArgs(DrawingAttributes.ColorPropertyGuid, newColor, oldColor));","handlingStrategy":"validation","validationCode":"if (e != null) OnDrawingAttributesChanged(e); else return;","typeGuard":"bool CanRaise(PropertyDataChangedEventArgs e) => e != null;","tryCatchPattern":"try { OnDrawingAttributesChanged(e); } catch (ArgumentNullException ex) when (ex.ParamName == \"e\") { log(\"null event args\"); }","preventionTips":["Never call On* raise methods with null args — skip the call instead","Construct event args at the point of change, not conditionally later","In derived classes, assert args non-null at the top of the override"],"tags":["wpf","ink","argument-null","event-args"],"backgroundTag":"null-argument","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"}