unoplatform/uno · error · ArgumentNullException

xamlTypeName

Error message

xamlTypeName

What it means

Thrown by the XamlTypeName overload of XamlSchemaContext.GetXamlType when xamlTypeName is null. This overload parses a structured XamlTypeName (namespace, name, type arguments) into a XamlType; a null name cannot be parsed, so it fails fast.

Source

Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs:260

				if (xt == null)
					foreach (var ns in GetAllXamlNamespaces())
						if ((xt = GetAllXamlTypes(ns).FirstOrDefault(t => t.UnderlyingType == type)) != null)
							break;
				if (xt == null)
				{
					xt = new XamlType(type, this);
					run_time_types.Add(xt);
				}
				return xt;
			}
		}
		
		public XamlType GetXamlType (XamlTypeName xamlTypeName)
		{
			lock (gate)
			{
				if (xamlTypeName == null)
					throw new ArgumentNullException("xamlTypeName");

				var n = xamlTypeName;
				if (n.TypeArguments.Count == 0) // non-generic
					return GetXamlType(n.Namespace, n.Name);

				// generic
				XamlType[] typeArgs = new XamlType[n.TypeArguments.Count];
				for (int i = 0; i < typeArgs.Length; i++)
					typeArgs[i] = GetXamlType(n.TypeArguments[i]);
				return GetXamlType(n.Namespace, n.Name, typeArgs);
			}
		}
		
		protected internal virtual XamlType GetXamlType (string xamlNamespace, string name, params XamlType [] typeArguments)
		{
			lock (gate)
			{
				string dummy;

View on GitHub (pinned to 0418340488)

Solutions

  1. Pass a non-null XamlTypeName instance.
  2. Null-check the result of any name-parsing code before calling GetXamlType.
  3. Return a sentinel/early-out in your caller if the parsed name is null.

Example fix

// before
var xt = ctx.GetXamlType(parsed); // parsed may be null
// after
if (parsed != null)
    var xt = ctx.GetXamlType(parsed);
Defensive patterns

Strategy: validation

Validate before calling

if (xamlTypeName == null)
    throw new InvalidOperationException("xamlTypeName must be non-null before calling GetXamlType.");
var xt = ctx.GetXamlType(xamlTypeName);

Prevention

When it happens

Trigger: Calling `schemaContext.GetXamlType((XamlTypeName)null)` — typically a caller that built a XamlTypeName conditionally and it came back null.

Common situations: Name-parsing helpers returning null on malformed input and forwarding it; test scaffolding passing null.

Related errors


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