unoplatform/uno · error · ArgumentNullException
xamlNamespace
Error message
xamlNamespace
What it means
Thrown by XamlSchemaContext.GetAllXamlTypes when the xamlNamespace argument is null. GetAllXamlTypes enumerates all XamlTypes registered under a given XAML namespace; a null namespace cannot index the internal dictionary, so it fails fast with an ArgumentNullException.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs:176
{
lock (gate)
{
if (xaml_nss == null)
{
xaml_nss = new Dictionary<string, string>();
foreach (var ass in AssembliesInScope)
FillXamlNamespaces(ass);
}
return xaml_nss.Values.Distinct();
}
}
public virtual ICollection<XamlType> GetAllXamlTypes (string xamlNamespace)
{
lock (gate)
{
if (xamlNamespace == null)
throw new ArgumentNullException("xamlNamespace");
if (all_xaml_types == null)
{
all_xaml_types = new Dictionary<string, List<XamlType>>();
foreach (var ass in AssembliesInScope)
FillAllXamlTypes(ass);
}
List<XamlType> l;
if (all_xaml_types.TryGetValue(xamlNamespace, out l))
return l;
else
return empty_xaml_types;
}
}
public virtual string GetPreferredPrefix (string xmlns)
{
lock (gate)View on GitHub (pinned to 0418340488)
Solutions
- Pass a non-null namespace string to GetAllXamlTypes.
- Null-check the namespace at the source (the lookup that produced it) before forwarding.
- Return early or use a sentinel/empty string if the namespace is optional in your flow.
Example fix
// before
var types = ctx.GetAllXamlTypes(ns); // ns may be null
// after
if (ns != null)
var types = ctx.GetAllXamlTypes(ns); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(xamlNamespace))
throw new InvalidOperationException("xamlNamespace must be non-null before calling GetAllXamlTypes.");
var types = ctx.GetAllXamlTypes(xamlNamespace); Prevention
- Null-check namespaces at the source (the lookup that produced them).
- Treat namespace strings as nullable until validated.
- Add a helper wrapper that guards nulls before delegating to schema-context APIs.
When it happens
Trigger: Calling `schemaContext.GetAllXamlTypes(null)` — typically from code that derived a namespace string that came back null (e.g. a lookup that returned null and was not checked).
Common situations: Programmatic callers passing an unresolved namespace; helper methods forwarding a nullable namespace without null-checking; test code passing null deliberately.
Related errors
- xmlns
- xamlTypeName
- schemaContext
- The {0} string passed in the colorString argument is not a r
- The {0} string passed in the colorString argument is not a r
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/3e1f07d2a14adc2b.
Report an issue: GitHub.