{"record":{"id":"a347d300f4c2eeca","repo":"unoplatform/uno","slug":"property-getter-for-0-must-have-exactly-one-argu","errorCode":null,"errorMessage":"Property getter for {0} must have exactly one argument and must have non-void return type.","messagePattern":"Property getter 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":468,"sourceCode":"\t\t\treturn underlying_setter;\n\t\t}\n\n\t\tprotected virtual XamlValueConverter<ValueSerializer> LookupValueSerializer ()\n\t\t{\n\t\t\tif (is_predefined_directive) // FIXME: this is likely a hack.\n\t\t\t\treturn null;\n\t\t\tif (Type == null)\n\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":450,"sourceCodeEnd":480,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlMember.cs#L450-L480","documentation":"Thrown by XamlMember.VerifyGetter when an attachable property getter MethodInfo does not match the expected signature: exactly one parameter and a non-void return type. Attachable property getters follow the static GetX(object target) pattern; a method with a different signature cannot serve as one and is rejected.","triggerScenarios":"Passing a MethodInfo to the XamlMember attachable constructor where the getter takes zero or two+ parameters, or returns void. E.g. passing an instance property getter (0 params) instead of the static attachable accessor.","commonSituations":"Reflection code that picks the wrong overload of a method named Get<PropName> (e.g. a no-arg instance getter vs. the static one-arg attachable accessor). Confusing attachable property accessors with regular instance property accessors.","solutions":["Pass the correct static attachable getter: a method with signature static T GetPropName(object target) — exactly one parameter, non-void return.","Filter reflection results: type.GetMethods().First(m => m.Name == \"Get\"+propName && m.GetParameters().Length == 1 && m.ReturnType != typeof(void)).","Do not pass instance property accessors to the attachable-property XamlMember constructor."],"exampleFix":"// before\nvar getter = type.GetMethod(\"GetName\"); // picks instance getter with 0 params\nvar member = new XamlMember(\"Name\", getter, setter, sctx);\n\n// after\nvar getter = type.GetMethods()\n    .First(m => m.Name == \"GetName\" && m.IsStatic && m.GetParameters().Length == 1);\nvar member = new XamlMember(\"Name\", getter, setter, sctx);","handlingStrategy":"validation","validationCode":"var getter = type.GetMethods()\n    .FirstOrDefault(m => m.Name == \"Get\"+propName && m.IsStatic\n        && m.GetParameters().Length == 1 && m.ReturnType != typeof(void));\nif (getter == null) return null;\nvar member = new XamlMember(propName, getter, setter, sctx);","typeGuard":"static bool IsValidAttachableGetter(MethodInfo m)\n    => m.IsStatic && m.GetParameters().Length == 1 && m.ReturnType != typeof(void);","tryCatchPattern":"try { VerifyGetterIsOk(getter); new XamlMember(...); }\ncatch (ArgumentException) { /* find correct overload */ }","preventionTips":["Attachable getters are static, take exactly one parameter (the target), and return non-void.","Filter reflection results by signature before passing to XamlMember."],"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"}