{"record":{"id":"47daf706e48f4d40","repo":"unoplatform/uno","slug":"not-supported-operation-on-directive-member-0","errorCode":null,"errorMessage":"not supported operation on directive member {0}","messagePattern":"not supported operation on directive member (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlMemberInvoker.cs","lineNumber":70,"sourceCode":"\t\t}\n\n\t\tpublic MethodInfo UnderlyingSetter {\n\t\t\tget { return member != null ? member.UnderlyingSetter : null; }\n\t\t}\n\n\t\tvoid ThrowIfUnknown ()\n\t\t{\n\t\t\tif (member == null)\n\t\t\t\tthrow new NotSupportedException (\"Current operation is invalid for unknown member.\");\n\t\t}\n\n\t\tpublic virtual object GetValue (object instance)\n\t\t{\n\t\t\tThrowIfUnknown ();\n\t\t\tif (instance == null)\n\t\t\t\tthrow new ArgumentNullException (\"instance\");\n\t\t\tif (member is XamlDirective)\n\t\t\t\tthrow new NotSupportedException (String.Format (CultureInfo.InvariantCulture, \"not supported operation on directive member {0}\", member));\n\t\t\tif (UnderlyingGetter == null)\n\t\t\t\tthrow new NotSupportedException (String.Format (CultureInfo.InvariantCulture, \"Attempt to get value from write-only property or event {0}\", member));\n\t\t\treturn UnderlyingGetter.Invoke (instance, Array.Empty<object>());\n\t\t}\n\t\tpublic virtual void SetValue (object instance, object value)\n\t\t{\n\t\t\tThrowIfUnknown ();\n\t\t\tif (instance == null)\n\t\t\t\tthrow new ArgumentNullException (\"instance\");\n\t\t\tif (member is XamlDirective)\n\t\t\t\tthrow new NotSupportedException (String.Format (CultureInfo.InvariantCulture, \"not supported operation on directive member {0}\", member));\n\t\t\tif (UnderlyingSetter == null)\n\t\t\t\tthrow new NotSupportedException (String.Format (CultureInfo.InvariantCulture, \"Attempt to set value from read-only property {0}\", member));\n\t\t\tif (member.IsAttachable)\n\t\t\t\tUnderlyingSetter.Invoke (null, new object [] {instance, value});\n\t\t\telse\n\t\t\t\tUnderlyingSetter.Invoke (instance, new object [] {value});\n\t\t}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlMemberInvoker.cs#L52-L88","documentation":"Thrown by XamlMemberInvoker.GetValue/SetValue when the member is a XamlDirective (e.g. x:Name, x:Key, or other directive members) rather than a real CLR member. Directives have no underlying getter/setter MethodInfo, so invoking them via reflection is unsupported.","triggerScenarios":"A XAML processor routes a directive member through GetValue/SetValue. This can happen when an invoker is fetched for a directive member and the generic get/set path is taken instead of the directive-specific handler.","commonSituations":"Custom XAML object writers that handle all members uniformly without checking IsDirective; schema contexts that wrap directives in invokers; misrouting of x:Name/x:Key handling.","solutions":["Check member is XamlDirective before invoking and dispatch to directive-specific handling (e.g. name registration, resource-key assignment).","Filter directive members out of the normal property-set loop in your object writer.","Use XamlMember.Invoker only for non-directive members."],"exampleFix":"// before\nforeach (var m in members)\n    m.Invoker.SetValue(instance, value); // throws on x:Name\n\n// after\nforeach (var m in members)\n{\n    if (m is XamlDirective) { HandleDirective(m, instance, value); continue; }\n    m.Invoker.SetValue(instance, value);\n}","handlingStrategy":"type-guard","validationCode":"if (member is XamlDirective)\n{\n    HandleDirective(member, instance, value);\n    return;\n}\ninvoker.SetValue(instance, value);","typeGuard":"static bool IsDirective(XamlMember m) => m is XamlDirective;","tryCatchPattern":null,"preventionTips":["Branch on IsDirective in object writers before generic get/set dispatch.","Keep directive handling (x:Name, x:Key, etc.) separate from property handling.","Do not fetch an Invoker for directive members."],"tags":["xaml","schema","member-invoker","directive","uno"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}