{"record":{"id":"cb6dd2d63e7bdd5d","repo":"unoplatform/uno","slug":"property-0-is-already-set-to-this-1-object","errorCode":null,"errorMessage":"Property '{0}' is already set to this '{1}' object","messagePattern":"Property '(.+?)' is already set to this '(.+?)' object","errorType":"exception","errorClass":"XamlDuplicateMemberException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlWriterInternalBase.cs","lineNumber":195,"sourceCode":"\t\t\tmanager.Value ();\n\n\t\t\tOnWriteValue (value);\n\t\t}\n\t\t\n\t\tpublic void WriteStartMember (XamlMember property)\n\t\t{\n\t\t\tif (property == null)\n\t\t\t\tthrow new ArgumentNullException (\"property\");\n\n\t\t\tmanager.StartMember ();\n\t\t\tif (property == XamlLanguage.PositionalParameters)\n\t\t\t\t// this is an exception that indicates the state manager to accept more than values within this member.\n\t\t\t\tmanager.AcceptMultipleValues = true;\n\n\t\t\tvar state = object_states.Peek ();\n\t\t\tvar wpl = state.WrittenProperties;\n\t\t\tif (wpl.Any (wp => wp.Member == property))\n\t\t\t\tthrow new XamlDuplicateMemberException (String.Format (CultureInfo.InvariantCulture, \"Property '{0}' is already set to this '{1}' object\", property, object_states.Peek ().Type));\n\t\t\twpl.Add (new MemberAndValue (property));\n\t\t\tif (property == XamlLanguage.PositionalParameters)\n\t\t\t\tstate.PositionalParameterIndex = 0;\n\n\t\t\tOnWriteStartMember (property);\n\t\t}\n\t\t\n\t\tpublic void WriteEndObject ()\n\t\t{\n\t\t\tmanager.EndObject (object_states.Count > 1);\n\n\t\t\tOnWriteEndObject ();\n\n\t\t\tobject_states.Pop ();\n\t\t}\n\n\t\tpublic void WriteEndMember ()\n\t\t{","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlWriterInternalBase.cs#L177-L213","documentation":"WriteStartMember throws XamlDuplicateMemberException ('Property {0} is already set to this {1} object') when the same XamlMember is written twice within a single object scope. The writer tracks WrittenProperties per object state and rejects a second occurrence because XAML semantics do not allow setting the same property twice on one object (except PositionalParameters, which sets AcceptMultipleValues).","triggerScenarios":"XAML that sets the same attribute twice (e.g. <Button Content=\"A\" Content=\"B\"/>), or programmatic writer calls that emit the same StartMember twice before EndObject. PositionalParameters is the only built-in member that may repeat.","commonSituations":"Malformed XAML with duplicate attributes; merge/conflict in generated XAML producing duplicate properties; custom writers or transformers that accidentally duplicate a member node; style/template merging that double-sets a setter.","solutions":["Inspect the XAML for the property named in the message and remove the duplicate declaration on that element.","If generating XAML programmatically, track which members have been written per object and skip duplicates.","For collections that legitimately hold multiple values, ensure they are nested under the collection/add-member pattern rather than re-declaring the property.","If using a transformer pipeline, verify it does not duplicate StartMember nodes."],"exampleFix":"<!-- before -->\n<Button Content=\"A\" Content=\"B\" />\n\n<!-- after -->\n<Button Content=\"A\" />","handlingStrategy":"try-catch","validationCode":"// Pre-check: is this member already written in the current scope?\nvar seen = new HashSet<XamlMember>();\n// before each WriteStartMember: if (!seen.Add(member)) skip or throw your own diagnostic;","typeGuard":null,"tryCatchPattern":"try { writer.WriteStartMember(member); }\ncatch (XamlDuplicateMemberException ex) {\n    // log the offending member + owning type from ex.Message, then fix source XAML\n}","preventionTips":["Validate XAML with a schema-aware lint pass that flags duplicate attributes per element.","In programmatic writers, maintain a per-object set of written members and reject duplicates explicitly.","Review generated/merged XAML for accidental duplication after transforms."],"tags":["xaml","duplicate-member","xamlwriter","validation"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}