unoplatform/uno · error · ArgumentNullException

unknownTypeName

Error message

unknownTypeName

What it means

The XamlType(string unknownTypeNamespace, string unknownTypeName, ...) constructor throws ArgumentNullException('unknownTypeName') when the local type name argument is null. The name is assigned directly to the XamlType.Name property and used for serialization, so it must be present.

Source

Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlType.cs:89

				PreferredXamlNamespace = XamlLanguage.Xaml2006Namespace;
			} else {
				Name = GetXamlName (type);
				PreferredXamlNamespace = schemaContext.GetXamlNamespace (type.Namespace) ?? String.Format (CultureInfo.InvariantCulture, "clr-namespace:{0};assembly={1}", type.Namespace, type.Assembly.GetName ().Name);
			}
			if (type.IsGenericType) {
				TypeArguments = new List<XamlType> ();
				foreach (var gta in type.GetGenericArguments ())
					TypeArguments.Add (schemaContext.GetXamlType (gta));
			}
		}

		public XamlType (string unknownTypeNamespace, string unknownTypeName, IList<XamlType> typeArguments, XamlSchemaContext schemaContext)
			: this (schemaContext, null)
		{
			if (unknownTypeNamespace == null)
				throw new ArgumentNullException ("unknownTypeNamespace");
			if (unknownTypeName == null)
				throw new ArgumentNullException ("unknownTypeName");
			if (schemaContext == null)
				throw new ArgumentNullException ("schemaContext");

			type = typeof (object);
			Name = unknownTypeName;
			PreferredXamlNamespace = unknownTypeNamespace;
			TypeArguments = typeArguments != null && typeArguments.Count == 0 ? null : typeArguments;
//			explicit_ns = unknownTypeNamespace;
		}

		protected XamlType (string typeName, IList<XamlType> typeArguments, XamlSchemaContext schemaContext)
			: this (String.Empty, typeName, typeArguments, schemaContext)
		{
		}

		XamlType (XamlSchemaContext schemaContext, XamlTypeInvoker invoker)
		{
			if (schemaContext == null)

View on GitHub (pinned to 0418340488)

Solutions

  1. Ensure the type name is extracted and non-null before constructing the XamlType.
  2. Treat a missing name as a fatal parse error and report it to the user instead of constructing a nameless XamlType.
  3. Default to a placeholder name (e.g. 'Unknown') if you intentionally need an opaque placeholder type.

Example fix

// before
var xt = new XamlType(ns, null, typeArgs, sctx);

// after
if (typeName == null) throw new ArgumentException("XAML element is missing a type name");
var xt = new XamlType(ns, typeName, typeArgs, sctx);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(unknownTypeName)) throw new ArgumentException("type name required");
var xt = new XamlType(unknownTypeNamespace, unknownTypeName, typeArguments, schemaContext);

Prevention

When it happens

Trigger: Constructing an unknown XamlType without a name — e.g. when parsing failed to extract a local name from a malformed element, or when a caller passes a null name variable.

Common situations: Malformed XAML where the element tag has no name; programmatic XamlType construction with incomplete metadata; tests exercising validation.

Related errors


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