{"record":{"id":"8c71d1de2cb45114","repo":"unoplatform/uno","slug":"member-property-must-be-set-to-staticextension-bef","errorCode":null,"errorMessage":"Member property must be set to StaticExtension before calling ProvideValue method.","messagePattern":"Member property must be set to StaticExtension before calling ProvideValue method\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Windows.Markup/StaticExtension.cs","lineNumber":58,"sourceCode":"\t\t{\n\t\t}\n\n\t\tpublic StaticExtension (string member)\n\t\t{\n\t\t\tMember = member;\n\t\t}\n\n\t\t[ConstructorArgument (\"member\")]\n\t\tpublic string Member { get; set; }\n\n\t\t[DefaultValue (null)]\n\t\tpublic Type MemberType { get; set; }\n\n\t\tpublic override object ProvideValue (IServiceProvider serviceProvider)\n\t\t{\n\t\t\tif (Member == null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException (\"Member property must be set to StaticExtension before calling ProvideValue method.\");\n\t\t\t}\n\n\t\t\tif (MemberType != null) {\n\t\t\t\tvar pi = MemberType.GetProperty (Member, BindingFlags.Public | BindingFlags.Static);\n\t\t\t\tif (pi != null)\n\t\t\t\t{\n\t\t\t\t\treturn pi.GetValue (null, null);\n\t\t\t\t}\n\n\t\t\t\tvar fi = MemberType.GetField (Member, BindingFlags.Public | BindingFlags.Static);\n\t\t\t\tif (fi != null)\n\t\t\t\t{\n\t\t\t\t\treturn fi.GetValue (null);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// there might be some cases that it could still\n\t\t\t// resolve a static member without MemberType, \n\t\t\t// but we don't know any of such so far.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Windows.Markup/StaticExtension.cs#L40-L76","documentation":"Thrown by StaticExtension (x:Static) when ProvideValue is called before its Member property has been assigned. Member is the required, constructor-argument-backed string that identifies which static member to return, so the extension cannot produce a value without it.","triggerScenarios":"Instantiating StaticExtension and calling ProvideValue without setting Member (or without using the string constructor). Programmatic construction with the parameterless ctor followed by immediate ProvideValue.","commonSituations":"Custom XAML pre-processors that build markup extensions imperatively; copy-paste mistakes where Member was set on a different instance; deserialization paths that skip required property binding.","solutions":["Set Member before ProvideValue, ideally via the constructor: new StaticExtension(\"namespace:Type.Field\").","If parsing XAML, confirm the x:Static directive has a Member= attribute or positional argument.","Guard with a null check on Member before calling ProvideValue to fail earlier with a clearer message.","Ensure your XAML namespace prefixes are declared so the Member string can be parsed."],"exampleFix":"// before\nvar ext = new StaticExtension();\nvar v = ext.ProvideValue(sp); // throws\n\n// after\nvar ext = new StaticExtension(\"sys:Math.PI\");\nvar v = ext.ProvideValue(sp);","handlingStrategy":"validation","validationCode":"var ext = new StaticExtension();\n// ... possibly set other props ...\nif (ext.Member == null)\n    throw new InvalidOperationException(\"Set Member before ProvideValue\");\nvar value = ext.ProvideValue(sp);","typeGuard":"static bool IsStaticExtensionReady(StaticExtension e) => !string.IsNullOrEmpty(e.Member);","tryCatchPattern":null,"preventionTips":["Prefer the string constructor new StaticExtension(\"ns:Type.Member\") to force Member at construction.","Centralize markup-extension construction in a helper that asserts required properties.","Review XAML x:Static usages to confirm each has a Member operand."],"tags":["xaml","markup-extension","static","validation","uno"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}