{"record":{"id":"5771cfa2a5008c1f","repo":"unoplatform/uno","slug":"attempt-to-get-value-from-write-only-property-or-e","errorCode":null,"errorMessage":"Attempt to get value from write-only property or event {0}","messagePattern":"Attempt to get value from write-only property or event (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlMemberInvoker.cs","lineNumber":72,"sourceCode":"\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}\n\n\t\tpublic virtual ShouldSerializeResult ShouldSerializeValue (object instance)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlMemberInvoker.cs#L54-L90","documentation":"Thrown by XamlMemberInvoker.GetValue when the member is known and non-directive but has no UnderlyingGetter — i.e. it is write-only (a set-only property) or an event (events have no getter). Reading such a member has no CLR method to invoke.","triggerScenarios":"Calling GetValue on an invoker whose XamlMember.UnderlyingGetter is null. Occurs for set-only properties, event members, or members backed only by add/remove handlers.","commonSituations":"Generic XAML round-tripping that attempts to serialize every member including write-only ones; serializers that do not check readability; binding code that reads a property not meant to be read.","solutions":["Check member.UnderlyingGetter != null (or member.IsReadVisible / IsReadable) before calling GetValue.","Skip write-only and event members during serialization.","Mark the property with [DesignerSerializationVisibility(Hidden)] to exclude it from serialization."],"exampleFix":"// before\nvar v = invoker.GetValue(instance); // throws for set-only\n\n// after\nif (invoker.UnderlyingGetter != null)\n    var v = invoker.GetValue(instance);","handlingStrategy":"type-guard","validationCode":"if (invoker.UnderlyingGetter == null)\n{\n    // write-only or event; cannot read\n    return;\n}\nvar v = invoker.GetValue(instance);","typeGuard":"static bool IsReadable(XamlMember m) => m != null && m.UnderlyingGetter != null;","tryCatchPattern":null,"preventionTips":["Check member.UnderlyingGetter != null before reading; skip write-only and event members.","Use IsReadVisible / IsReadable schema properties when available.","Annotate write-only properties with [DesignerSerializationVisibility(Hidden)] to keep serializers away."],"tags":["xaml","schema","member-invoker","write-only","uno"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}