{"record":{"id":"79410b79ad17a1e2","repo":"dotnet/wpf","slug":"sr-eventargisnull","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/DrawingAttributes.cs","lineNumber":590,"sourceCode":"        }\n        #endregion\n\n        #region Events\n\n        /// <summary>\n        /// Event fired whenever a DrawingAttribute is modified\n        /// </summary>\n        public event PropertyDataChangedEventHandler AttributeChanged;\n\n        /// <summary>\n        /// Method called when a change occurs to any DrawingAttribute\n        /// </summary>\n        /// <param name=\"e\">The change information for the DrawingAttribute that was modified</param>\n        protected virtual void OnAttributeChanged(PropertyDataChangedEventArgs e)\n        {\n            if (null == e)\n            {\n                throw new ArgumentNullException(nameof(e), SR.EventArgIsNull);\n            }\n\n            try\n            {\n                PrivateNotifyPropertyChanged(e);\n            }\n            finally\n            {\n                if ( this.AttributeChanged != null )\n                {\n                    this.AttributeChanged(this, e);\n                }\n            }\n        }\n\n         /// <summary>\n        /// Event fired whenever a DrawingAttribute is modified\n        /// </summary>","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/DrawingAttributes.cs#L572-L608","documentation":"DrawingAttributes.OnAttributeChanged throws ArgumentNullException with SR.EventArgIsNull when the PropertyDataChangedEventArgs passed in is null. This protected virtual method is the raise-point for the AttributeChanged event, and a null event-args instance would make downstream handlers fail obscurely, so it is rejected at the entry. It is normally invoked via the ExtendedPropertiesChanged_EventForwarder when an attribute in the underlying collection changes.","triggerScenarios":"Calling OnAttributeChanged(null) — usually from a subclass override forwarding events, or from test/infrastructure code that constructs the change notification manually with a null args.","commonSituations":"Custom DrawingAttributes subclasses forwarding ExtendedPropertiesChanged notifications without checking the args; refactors where the event-args construction was moved but a null path remained.","solutions":["Never invoke OnAttributeChanged with null; construct a valid PropertyDataChangedEventArgs describing the change.","If the change carries no data, do not raise the event at all rather than raising with null args.","In subclass overrides calling base.OnAttributeChanged, guard the args or let the ArgumentNullException surface as a bug signal."],"exampleFix":"// before\nprotected override void OnAttributeChanged(PropertyDataChangedEventArgs e)\n{\n    base.OnAttributeChanged(null); // ArgumentNullException\n}\n// after\nprotected override void OnAttributeChanged(PropertyDataChangedEventArgs e)\n{\n    if (e != null) base.OnAttributeChanged(e);\n}","handlingStrategy":"try-catch","validationCode":"if (e == null) throw new ArgumentNullException(nameof(e)); // or skip raising\nbase.OnAttributeChanged(e);","typeGuard":"static bool IsValidArgs(PropertyDataChangedEventArgs e) => e != null;","tryCatchPattern":"try { OnAttributeChanged(args); }\ncatch (ArgumentNullException) { /* args was null; construct a valid PropertyDataChangedEventArgs or skip the raise */ }","preventionTips":["Never raise change events with null args; skip the raise instead","In subclass overrides, null-check before calling base","Construct PropertyDataChangedEventArgs with valid old/new PropertyData values"],"tags":["wpf","ink","argumentnull","events"],"backgroundTag":"null-argument","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"}