unoplatform/uno · error · ArgumentNullException
typeName
Error message
typeName
What it means
Thrown by XamlTypeName.TryParse when the `typeName` argument is null. TryParse is the core parser; a null input string has no characters to tokenize, so it rejects immediately rather than producing a misleading false return.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlTypeName.cs:45
using System.Linq;
namespace Uno.Xaml.Schema
{
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Types manipulated here have been marked earlier")]
public class XamlTypeName
{
public static XamlTypeName Parse (string typeName, IXamlNamespaceResolver namespaceResolver)
{
XamlTypeName n;
if (!TryParse (typeName, namespaceResolver, out n))
throw new FormatException (String.Format (CultureInfo.InvariantCulture, "Invalid typeName: '{0}'", typeName));
return n;
}
public static bool TryParse (string typeName, IXamlNamespaceResolver namespaceResolver, out XamlTypeName result)
{
if (typeName == null)
throw new ArgumentNullException ("typeName");
if (namespaceResolver == null)
throw new ArgumentNullException ("namespaceResolver");
result = null;
IList<XamlTypeName> args = null;
int nArray = 0;
int idx;
if (typeName.Length > 2 && typeName [typeName.Length - 1] == ']') {
idx = typeName.LastIndexOf ('[');
if (idx < 0)
return false; // mismatch brace
nArray = 1;
for (int i = idx + 1; i < typeName.Length - 1; i++) {
if (typeName [i] != ',')
return false; // only ',' is expected
nArray++;
}View on GitHub (pinned to 0418340488)
Solutions
- Null-check the input before calling TryParse and treat null as 'no type' in your flow.
- Provide a default/empty string and let TryParse return false instead.
- Validate upstream sources of the type-name string to ensure they are non-null.
Example fix
// before
XamlTypeName.TryParse(typeNameStr, resolver, out var name);
// after
if (typeNameStr == null) { name = null; return; }
XamlTypeName.TryParse(typeNameStr, resolver, out name); Defensive patterns
Strategy: validation
Validate before calling
// before TryParse
if (typeName == null) { result = null; return; } Prevention
- Null-check input strings before parsing.
- Treat a null type-name as 'no type specified' in your flow.
When it happens
Trigger: Calling XamlTypeName.TryParse(null, resolver, out _); propagating a null type-name string from upstream (e.g. a missing attribute value, an empty element treated as a type reference).
Common situations: Config/code paths that read a type-name string from an optional attribute that was absent (null); deserialization feeding null into type resolution; unguarded string handling.
Related errors
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/0504da2141a157f3.
Report an issue: GitHub.