unoplatform/uno · error · ArgumentException
Property getter for {0} must have exactly one argument and m
Error message
Property getter for {0} must have exactly one argument and must have non-void return type. What it means
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.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlMember.cs:468
return underlying_setter;
}
protected virtual XamlValueConverter<ValueSerializer> LookupValueSerializer ()
{
if (is_predefined_directive) // FIXME: this is likely a hack.
return null;
if (Type == null)
return null;
return XamlType.LookupValueSerializer (Type, LookupCustomAttributeProvider ()) ?? Type.ValueSerializer;
}
void VerifyGetter (MethodInfo method)
{
if (method == null)
return;
if (method.GetParameters ().Length != 1 || method.ReturnType == typeof (void))
throw new ArgumentException (String.Format (CultureInfo.InvariantCulture, "Property getter for {0} must have exactly one argument and must have non-void return type.", Name));
}
void VerifyAdderSetter (MethodInfo method)
{
if (method == null)
return;
if (method.GetParameters ().Length != 2)
throw 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));
}
}
}
View on GitHub (pinned to 0418340488)
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.
Example fix
// before
var getter = type.GetMethod("GetName"); // picks instance getter with 0 params
var member = new XamlMember("Name", getter, setter, sctx);
// after
var getter = type.GetMethods()
.First(m => m.Name == "GetName" && m.IsStatic && m.GetParameters().Length == 1);
var member = new XamlMember("Name", getter, setter, sctx); Defensive patterns
Strategy: validation
Validate before calling
var getter = type.GetMethods()
.FirstOrDefault(m => m.Name == "Get"+propName && m.IsStatic
&& m.GetParameters().Length == 1 && m.ReturnType != typeof(void));
if (getter == null) return null;
var member = new XamlMember(propName, getter, setter, sctx); Type guard
static bool IsValidAttachableGetter(MethodInfo m)
=> m.IsStatic && m.GetParameters().Length == 1 && m.ReturnType != typeof(void); Try / catch
try { VerifyGetterIsOk(getter); new XamlMember(...); }
catch (ArgumentException) { /* find correct overload */ } Prevention
- Attachable getters are static, take exactly one parameter (the target), and return non-void.
- Filter reflection results by signature before passing to XamlMember.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Property getter or event adder for {0} must have exactly one
- Either of converterType, targetType or name must be non-null
- Either property getter or setter must be non-null.
- Attempt to set value from read-only property {0}
- Current operation is valid only when the underlying type on
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/a347d300f4c2eeca.
Report an issue: GitHub.