unoplatform/uno · error · ArgumentException
Property getter or event adder for {0} must have exactly one
Error message
Property getter or event adder for {0} must have exactly one argument and must have non-void return type. What it means
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.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlMember.cs:476
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 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.
Example fix
// before
var setter = type.GetMethod("SetName", new[]{ typeof(string) }); // 1 param
var member = new XamlMember("Name", getter, setter, sctx);
// after
var setter = type.GetMethods()
.First(m => m.Name == "SetName" && m.IsStatic && m.GetParameters().Length == 2);
var member = new XamlMember("Name", getter, setter, sctx); Defensive patterns
Strategy: validation
Validate before calling
var setter = type.GetMethods()
.FirstOrDefault(m => m.Name == "Set"+propName && m.IsStatic
&& m.GetParameters().Length == 2);
if (setter == null) return null;
var member = new XamlMember(propName, getter, setter, sctx); Type guard
static bool IsValidAttachableSetter(MethodInfo m)
=> m.IsStatic && m.GetParameters().Length == 2; Try / catch
try { new XamlMember(propName, getter, setter, sctx); }
catch (ArgumentException) { /* resolve correct setter */ } Prevention
- Attachable setters are static and take exactly two parameters (target, value).
- Distinguish static attachable accessors from instance property accessors.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Property getter for {0} must have exactly one argument and m
- 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/8d64c5c685fc4caf.
Report an issue: GitHub.