unoplatform/uno · error · ArgumentNullException
xamlType
Error message
xamlType
What it means
Thrown by the XamlTypeName(XamlType xamlType) constructor when `xamlType` is null. The constructor copies the XamlType's PreferredXamlNamespace, Name, and TypeArguments into the new XamlTypeName, so a null source has nothing to copy; it is rejected immediately.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlTypeName.cs:200
ret += ta.ToString (prefixLookup);
}
return ret;
}
// instance members
public XamlTypeName ()
{
TypeArguments = empty_type_args;
}
static readonly XamlTypeName [] empty_type_args = Array.Empty<XamlTypeName>();
public XamlTypeName (XamlType xamlType)
: this ()
{
if (xamlType == null)
throw new ArgumentNullException ("xamlType");
Namespace = xamlType.PreferredXamlNamespace;
Name = xamlType.Name;
if (xamlType.TypeArguments != null && xamlType.TypeArguments.Count > 0) {
var l = new List<XamlTypeName> ();
l.AddRange (xamlType.TypeArguments.Select (x => new XamlTypeName (x)));
TypeArguments = l;
}
}
public XamlTypeName (string xamlNamespace, string name)
: this (xamlNamespace, name, null)
{
}
public XamlTypeName (string xamlNamespace, string name, IEnumerable<XamlTypeName> typeArguments)
: this ()
{
Namespace = xamlNamespace;View on GitHub (pinned to 0418340488)
Solutions
- Null-check the XamlType before constructing the XamlTypeName.
- Fix the upstream type resolution so GetXamlType returns a non-null XamlType (verify assembly references and xmlns mappings).
- Construct XamlTypeName from explicit (namespace, name) strings instead when you only have partial type info.
Example fix
// before
var name = new XamlTypeName(resolvedType); // resolvedType may be null
// after
if (resolvedType == null) {
throw new InvalidOperationException("Could not resolve XamlType for type-name construction.");
}
var name = new XamlTypeName(resolvedType); Defensive patterns
Strategy: validation
Validate before calling
// before constructing
if (xamlType == null) throw new InvalidOperationException("XamlType resolution returned null; cannot build XamlTypeName."); Prevention
- Verify type resolution succeeded (non-null GetXamlType result) before constructing a XamlTypeName.
- When only partial info is available, build XamlTypeName from explicit (namespace, name) strings.
When it happens
Trigger: Calling new XamlTypeName(null); or new XamlTypeName(resolvedType) where resolvedType is null from a failed GetXamlType lookup.
Common situations: Type-resolution failures where GetXamlType returns null and the null propagates into XamlTypeName construction; code that assumes a type was always resolved.
Related errors
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/ad2e3d902027c29c.
Report an issue: GitHub.