{"record":{"id":"1eabe65ecc1d3a33","repo":"unoplatform/uno","slug":"member-0-could-not-be-resolved-to-a-static-mem","errorCode":null,"errorMessage":"Member '{0}' could not be resolved to a static member","messagePattern":"Member '(.+?)' could not be resolved to a static member","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Windows.Markup/StaticExtension.cs","lineNumber":77,"sourceCode":"\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.\n\t\t\tthrow new ArgumentException (String.Format (CultureInfo.InvariantCulture, \"Member '{0}' could not be resolved to a static member\", Member));\n\t\t}\n\t}\n}\n","sourceCodeStart":59,"sourceCodeEnd":81,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Windows.Markup/StaticExtension.cs#L59-L81","documentation":"Thrown by StaticExtension when Member was supplied and MemberType was set, but neither a public static property nor a public static field with that Member name exists on MemberType. The lookup uses BindingFlags.Public | BindingFlags.Static, so non-public, instance-only, or misspelled members will not be found.","triggerScenarios":"Setting MemberType and Member where Member names a private/protected static, an instance member, or simply a non-existent member on the type. Also triggered when MemberType is null and Member-only resolution is attempted (the code explicitly notes this case is unsupported).","commonSituations":"Typos in member names in x:Static directives; referencing instance members when a static was intended; MemberType pointing at a type loaded in a different assembly that lacks InternalsVisibleTo or is internal; relying on case-insensitive matching (the lookup is case-sensitive).","solutions":["Verify the member exists as a public static field or property on MemberType using reflection or an IDE go-to-definition.","Correct spelling and casing of Member to match the declared identifier exactly.","If the member is instance-only, switch to a different binding strategy (cannot use x:Static).","Ensure MemberType is the actual declaring type of the member, not a derived type where the member is shadowed or inaccessible.","If only Member (no MemberType) is set, set MemberType explicitly — member-only resolution is not implemented."],"exampleFix":"// before\nvar ext = new StaticExtension { Member = \"PI\", MemberType = typeof(Math) };\n// Member=\"PI\" works, but a typo like Member=\"pi\" throws:\nvar ext2 = new StaticExtension { Member = \"pi\", MemberType = typeof(Math) };\n\n// after\nvar ext = new StaticExtension { Member = \"PI\", MemberType = typeof(Math) };","handlingStrategy":"validation","validationCode":"// Pre-validate the member exists before invoking the extension\npublic static bool MemberResolves(Type memberType, string member)\n{\n    if (memberType == null || member == null) return false;\n    var flags = BindingFlags.Public | BindingFlags.Static;\n    return memberType.GetProperty(member, flags) != null\n        || memberType.GetField(member, flags) != null;\n}\n\nif (!MemberResolves(ext.MemberType, ext.Member))\n    throw new ArgumentException($\"No static '{ext.Member}' on {ext.MemberType}\");","typeGuard":"static bool IsResolvableStaticMember(Type t, string m)\n    => t.GetProperty(m, BindingFlags.Public | BindingFlags.Static) != null\n    || t.GetField(m, BindingFlags.Public | BindingFlags.Static) != null;","tryCatchPattern":null,"preventionTips":["Always set MemberType explicitly; member-only resolution is not implemented.","Verify member visibility (must be public static) and exact casing.","Use IDE go-to-definition on the member string to confirm it points to a real static symbol."],"tags":["xaml","markup-extension","static","reflection","uno"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}