{"record":{"id":"4a8d95420cfe08d7","repo":"unoplatform/uno","slug":"attempt-to-set-value-from-read-only-property-0","errorCode":null,"errorMessage":"Attempt to set value from read-only property {0}","messagePattern":"Attempt to set value from read-only property (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlMemberInvoker.cs","lineNumber":83,"sourceCode":"\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)\n\t\t{\n\t\t\tthrow new NotImplementedException ();\n\t\t}\n\t}\n}\n","sourceCodeStart":65,"sourceCodeEnd":96,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlMemberInvoker.cs#L65-L96","documentation":"Thrown by XamlMemberInvoker.SetValue when the member has no UnderlyingSetter. This happens for read-only properties (no setter) and for events that cannot be set via reflection. The invoker refuses to write a value it has no method to write with.","triggerScenarios":"Calling SetValue on a XamlMember backed by a get-only property, a computed property, or an event member. Also when a property's setter is non-public and the XamlMember was built without reflecting the setter.","commonSituations":"XAML that tries to assign a read-only CLR property; binding to a property with only a getter; version changes where a previously settable property became read-only; reflecting internal/private setters under trimming where the setter was removed.","solutions":["Do not attempt to set read-only members from XAML; mark them with DesignerSerializationVisibility.Hidden or [Bindable(false)] if appropriate.","Check `member.Invoker.UnderlyingSetter != null` (or member.IsWriteVisible) before calling SetValue.","Add a public setter to the property if it should be XAML-settable.","If trimming removed the setter, ensure the type/property is preserved via DynamicDependency or trimming annotations."],"exampleFix":"// before\nmember.Invoker.SetValue(instance, value);\n\n// after\nif (member.Invoker.UnderlyingSetter == null) {\n    // read-only or event member; skip or log\n    return;\n}\nmember.Invoker.SetValue(instance, value);","handlingStrategy":"validation","validationCode":"// before SetValue\nif (member.Invoker.UnderlyingSetter == null) {\n    // read-only or event member: skip, log, or report\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check member.IsWriteVisible / UnderlyingSetter before writing.","Do not assign read-only CLR properties from XAML; review DesignerSerializationVisibility."],"tags":["xaml","schema","invoker","read-only","reflection"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}