{"record":{"id":"5465993b1b4a01d5","repo":"dotnet/wpf","slug":"argumentnullexception-nameof-value-staticextension","errorCode":null,"errorMessage":"ArgumentNullException(nameof(value))","messagePattern":"ArgumentNullException\\(nameof\\(value\\)\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Windows/Markup/StaticExtension.cs","lineNumber":160,"sourceCode":"\n                currentType = currentType.BaseType;\n            }\n            while (currentType is not null);\n\n            value = null;\n            return false;\n        }\n\n        /// <summary>\n        /// The static field or property represented by a string. This string is\n        /// of the format Prefix:ClassName.FieldOrPropertyName. The Prefix is\n        /// optional, and refers to the XML prefix in a Xaml file.\n        /// </summary>\n        [ConstructorArgument(\"member\")]\n        public string Member\n        {\n            get => _member;\n            set => _member = value ?? throw new ArgumentNullException(nameof(value));\n        }\n\n        [DefaultValue(null)]\n        public Type MemberType\n        {\n            get => _memberType;\n            set => _memberType = value ?? throw new ArgumentNullException(nameof(value));\n        }\n    }\n}\n","sourceCodeStart":142,"sourceCodeEnd":171,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Windows/Markup/StaticExtension.cs#L142-L171","documentation":"The StaticExtension.Member property setter rejects null with ArgumentNullException because the Member string is the core payload of the extension (marked [ConstructorArgument(\"member\")]). The member path must always be a non-null string, even if it may later prove malformed.","triggerScenarios":"Assigning ext.Member = null, or calling new StaticExtension(null) — the constructor delegates to the Member setter.","commonSituations":"Deserializing markup extension settings where the member value is missing; conditional code passing a variable that is null; data-bound config strings that failed to load.","solutions":["Pass a non-null 'Type.Member' string to the constructor or Member setter.","Coalesce nulls at the call site: new StaticExtension(member ?? fallback).","Check earlier parsing/config code that produced the null member string."],"exampleFix":"// before\nvar ext = new StaticExtension(GetMemberName()); // may return null\n// after\nvar ext = new StaticExtension(GetMemberName() ?? \"MyNamespace.MyClass.MyConstant\");","handlingStrategy":"validation","validationCode":"if (member is null) throw new InvalidOperationException(\"StaticExtension.Member cannot be null\");","typeGuard":"static bool IsValidMember(string? m) => m is not null;","tryCatchPattern":"try { ext.Member = candidate; } catch (ArgumentNullException) { /* supply default or abort */ }","preventionTips":["Null-check config/attribute strings before constructing StaticExtension.","Use ?? fallback at the call site.","Treat Member as a required [ConstructorArgument] in serialization code."],"tags":["xaml","argumentnullexception","null-check","static-extension"],"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"}