unoplatform/uno · error · ArgumentNullException

Either property getter or setter must be non-null.

Error message

Either property getter or setter must be non-null.

What it means

Thrown by the attachable-property XamlMember constructor (string, MethodInfo, MethodInfo, ...) when both getter and setter MethodInfos are null. An attachable property is defined by its get/set accessors; providing neither makes the member meaningless and the library rejects it with an ArgumentNullException keyed on 'getter'.

Source

Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlMember.cs:105

			DeclaringType = schemaContext.GetXamlType (adder.DeclaringType);
			target_type = schemaContext.GetXamlType (typeof (object));
			UnderlyingSetter = adder;
			is_event = true;
			is_attachable = true;
		}

		public XamlMember (string attachablePropertyName, MethodInfo getter, MethodInfo setter, XamlSchemaContext schemaContext)
			: this (attachablePropertyName, getter, setter, schemaContext, null)
		{
		}

		public XamlMember (string attachablePropertyName, MethodInfo getter, MethodInfo setter, XamlSchemaContext schemaContext, XamlMemberInvoker invoker)
			: this (schemaContext, invoker)
		{
			if (attachablePropertyName == null)
				throw new ArgumentNullException ("attachablePropertyName");
			if (getter == null && setter == null)
				throw new ArgumentNullException ("getter", "Either property getter or setter must be non-null.");
			Name = attachablePropertyName;
			VerifyGetter (getter);
			VerifyAdderSetter (setter);
			underlying_member = getter ?? setter;
			DeclaringType = schemaContext.GetXamlType (underlying_member.DeclaringType);
			target_type = schemaContext.GetXamlType (typeof (object));
			UnderlyingGetter = getter;
			UnderlyingSetter = setter;
			is_attachable = true;
		}

		public XamlMember (string name, XamlType declaringType, bool isAttachable)
		{
			if (name == null)
				throw new ArgumentNullException ("name");
			if (declaringType == null)
				throw new ArgumentNullException ("declaringType");
			Name = name;

View on GitHub (pinned to 0418340488)

Solutions

  1. Ensure at least one of getter or setter is a valid MethodInfo before constructing the XamlMember.
  2. Fix the reflection lookup (method name patterns like Get<PropName>/Set<PropName>, binding flags) so it resolves the accessor.
  3. Skip XamlMember construction entirely if neither accessor resolves — the property does not exist on the type.

Example fix

// before
var getter = type.GetMethod("Get" + propName, ...);
var setter = type.GetMethod("Set" + propName, ...);
var member = new XamlMember(propName, getter, setter, sctx);
// both null → throws

// after
var getter = type.GetMethod("Get" + propName, ...);
var setter = type.GetMethod("Set" + propName, ...);
if (getter == null && setter == null)
    return null; // not an attachable property
var member = new XamlMember(propName, getter, setter, sctx);
Defensive patterns

Strategy: validation

Validate before calling

if (getter == null && setter == null) return null;
var member = new XamlMember(propName, getter, setter, sctx);

Type guard

static bool HasAccessor(MethodInfo g, MethodInfo s) => g != null || s != null;

Try / catch

try { return new XamlMember(name, getter, setter, sctx); }
catch (ArgumentNullException) { return null; }

Prevention

When it happens

Trigger: Constructing new XamlMember("MyProp", null, null, schemaContext) — both accessor methods are null. Typically from reflection that resolves accessors by name and finds neither.

Common situations: Reflection-driven attachable member construction where the get/set method names were computed wrong (wrong naming convention, wrong binding flags). Schema-context code that tries to look up an attachable property that does not exist on the target type.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/a584ea2d6ed5604d. Report an issue: GitHub.