{"record":{"id":"4584da7fa716b287","repo":"dotnet/wpf","slug":"argumentoutofrangeexception-nameof-oldproperty","errorCode":null,"errorMessage":"ArgumentOutOfRangeException(nameof(oldProperty))","messagePattern":"ArgumentOutOfRangeException\\(nameof\\(oldProperty\\)\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/Events.cs","lineNumber":158,"sourceCode":"    /// delegate used for event handlers that are called when the Custom attributes associated with an object have changed.\n    /// </summary>\n    internal delegate void ExtendedPropertiesChangedEventHandler(object sender, ExtendedPropertiesChangedEventArgs e);\n\n    /// <summary>\n    /// Event Arg used when the Custom attributes associated with an object have changed.\n    /// </summary>\n    internal class ExtendedPropertiesChangedEventArgs : EventArgs\n    {\n        private ExtendedProperty _oldProperty;\n        private ExtendedProperty _newProperty;\n\n        /// <summary>Constructor</summary>\n        internal ExtendedPropertiesChangedEventArgs(ExtendedProperty oldProperty,\n                                                    ExtendedProperty newProperty)\n        {\n            if ( oldProperty == null && newProperty == null )\n            {\n                throw new ArgumentNullException(nameof(oldProperty));\n            }\n            _oldProperty = oldProperty;\n            _newProperty = newProperty;\n        }\n\n        /// <summary>\n        /// The value of the previous property.  If the Changed event was caused\n        /// by an ExtendedProperty being added, this value is null\n        /// </summary>\n        internal ExtendedProperty OldProperty\n        {\n            get { return _oldProperty; }\n        }\n\n        /// <summary>\n        /// The value of the new property.  If the Changed event was caused by \n        /// an ExtendedProperty being removed, this value is null\n        /// </summary>","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/Events.cs#L140-L176","documentation":"ExtendedPropertiesChangedEventArgs (internal) throws ArgumentNullException named 'oldProperty' when both oldProperty and newProperty are null. Note the message is a null-argument exception even though the true condition is 'both null'.","triggerScenarios":"Internal code paths constructing ExtendedPropertiesChangedEventArgs(null, null); only reachable via reflection, private copy of WPF source, or subclassed/derived event plumbing.","commonSituations":"Custom ink framework code mimicking WPF internals; debugging WPF source where an ExtendedProperty changed notification was built from two missing values.","solutions":["Ensure at least one of oldProperty/newProperty is non-null before constructing","Add a guard that skips notification when both are null"],"exampleFix":"// before\nnew ExtendedPropertiesChangedEventArgs(oldProperty, newProperty);\n// after\nif (oldProperty != null || newProperty != null) new ExtendedPropertiesChangedEventArgs(oldProperty, newProperty);","handlingStrategy":"validation","validationCode":"if (oldProperty == null && newProperty == null) return; // skip notification","typeGuard":"static bool HasEither(ExtendedProperty o, ExtendedProperty n) => o != null || n != null;","tryCatchPattern":"try { new ExtendedPropertiesChangedEventArgs(oldProperty, newProperty); } catch (ArgumentNullException) { /* both null: skip */ }","preventionTips":["Ensure change notifications always carry old or new value","Skip notification instead of constructing args from nulls"],"tags":["wpf","ink","argumentnullexception","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-21T21:30:21.729Z"}