{"record":{"id":"8d64c5c685fc4caf","repo":"unoplatform/uno","slug":"property-getter-or-event-adder-for-0-must-have-e","errorCode":null,"errorMessage":"Property getter or event adder for {0} must have exactly one argument and must have non-void return type.","messagePattern":"Property getter or event adder for (.+?) must have exactly one argument and must have non-void return type\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlMember.cs","lineNumber":476,"sourceCode":"\t\t\t\treturn null;\n\n\t\t\treturn XamlType.LookupValueSerializer (Type, LookupCustomAttributeProvider ()) ?? Type.ValueSerializer;\n\t\t}\n\n\t\tvoid VerifyGetter (MethodInfo method)\n\t\t{\n\t\t\tif (method == null)\n\t\t\t\treturn;\n\t\t\tif (method.GetParameters ().Length != 1 || method.ReturnType == typeof (void))\n\t\t\t\tthrow new ArgumentException (String.Format (CultureInfo.InvariantCulture, \"Property getter for {0} must have exactly one argument and must have non-void return type.\", Name));\n\t\t}\n\n\t\tvoid VerifyAdderSetter (MethodInfo method)\n\t\t{\n\t\t\tif (method == null)\n\t\t\t\treturn;\n\t\t\tif (method.GetParameters ().Length != 2)\n\t\t\t\tthrow new ArgumentException (String.Format (CultureInfo.InvariantCulture, \"Property getter or event adder for {0} must have exactly one argument and must have non-void return type.\", Name));\n\t\t}\n\t}\n}\n","sourceCodeStart":458,"sourceCodeEnd":480,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlMember.cs#L458-L480","documentation":"Thrown by XamlMember.VerifyAdderSetter when an attachable property setter (or event adder) MethodInfo does not have exactly two parameters. Attachable setters follow the static SetX(object target, T value) pattern; event adders follow AddX(object target, Handler). A method with a different parameter count is rejected.","triggerScenarios":"Passing a MethodInfo as the setter to the XamlMember attachable constructor where the method takes 1 or 3+ parameters instead of 2. E.g. passing an instance property setter (1 param: value) instead of the static two-arg attachable setter.","commonSituations":"Reflection code resolving Set<PropName> but picking an instance property setter (1 param) rather than the static attachable setter (2 params). Event-handler registration code passing a one-arg add method.","solutions":["Pass the correct static attachable setter: static void SetPropName(object target, T value) — exactly two parameters.","Filter: type.GetMethods().First(m => m.Name == \"Set\"+propName && m.GetParameters().Length == 2).","Distinguish instance accessors from attachable (static) accessors in reflection."],"exampleFix":"// before\nvar setter = type.GetMethod(\"SetName\", new[]{ typeof(string) }); // 1 param\nvar member = new XamlMember(\"Name\", getter, setter, sctx);\n\n// after\nvar setter = type.GetMethods()\n    .First(m => m.Name == \"SetName\" && m.IsStatic && m.GetParameters().Length == 2);\nvar member = new XamlMember(\"Name\", getter, setter, sctx);","handlingStrategy":"validation","validationCode":"var setter = type.GetMethods()\n    .FirstOrDefault(m => m.Name == \"Set\"+propName && m.IsStatic\n        && m.GetParameters().Length == 2);\nif (setter == null) return null;\nvar member = new XamlMember(propName, getter, setter, sctx);","typeGuard":"static bool IsValidAttachableSetter(MethodInfo m)\n    => m.IsStatic && m.GetParameters().Length == 2;","tryCatchPattern":"try { new XamlMember(propName, getter, setter, sctx); }\ncatch (ArgumentException) { /* resolve correct setter */ }","preventionTips":["Attachable setters are static and take exactly two parameters (target, value).","Distinguish static attachable accessors from instance property accessors."],"tags":["xaml","schema","argument","reflection","xaml-member","uno-xaml"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}