unoplatform/uno · error · ArgumentNullException
typeName
Error message
typeName
What it means
Thrown by the TypeExtension(string typeName) constructor when null is passed. The constructor immediately assigns the argument to TypeName, so a null would leave the extension in an invalid state; the guard fails fast instead.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Windows.Markup/TypeExtension.cs:45
using System.Reflection;
using Uno.Xaml.Schema;
namespace System.Windows.Markup
{
[MarkupExtensionReturnType (typeof (Type))]
[TypeConverter (typeof (TypeExtensionConverter))]
// [System.Runtime.CompilerServices.TypeForwardedFrom (Consts.AssemblyPresentationFramework_3_5)]
public class TypeExtension : MarkupExtension
{
public TypeExtension ()
{
}
public TypeExtension (string typeName)
{
if (typeName == null)
{
throw new ArgumentNullException ("typeName");
}
TypeName = typeName;
}
public TypeExtension (Type type)
{
if (type == null)
{
throw new ArgumentNullException ("type");
}
Type = type;
}
[ConstructorArgument ("type")]
[DefaultValue (null)]
public Type Type { get; set; }View on GitHub (pinned to 0418340488)
Solutions
- Pass a non-null, assembly-qualified or namespace-qualified type name string.
- Null-check the input before constructing: if (name != null) ext = new TypeExtension(name);.
- Prefer the TypeExtension(Type) overload when you already have a System.Type instance.
Example fix
// before
string name = GetNameOrNull();
var ext = new TypeExtension(name); // throws if null
// after
string name = GetNameOrNull() ?? throw new InvalidOperationException("type name required");
var ext = new TypeExtension(name); Defensive patterns
Strategy: validation
Validate before calling
string name = ResolveTypeName() ?? throw new InvalidOperationException("type name required");
var ext = new TypeExtension(name); Type guard
static bool IsValidTypeName(string s) => !string.IsNullOrWhiteSpace(s);
Prevention
- Null-check nullable strings before passing to the TypeExtension constructor.
- Prefer the TypeExtension(Type) overload when a Type instance is already available.
- Centralize type-name resolution so nulls surface as a single, well-described error.
When it happens
Trigger: Constructing new TypeExtension((string)null) directly, or via reflection/deserialization that resolves the string overload with a null argument.
Common situations: Code that builds TypeExtension from a nullable string without checking; XAML converters that pass through unresolved type-name bindings as null.
Related errors
- type
- serviceProvider
- Either TypeName or Type must be filled before calling Provid
- serviceProvider does not provide IXamlTypeResolver service.
- Type '{0}' is not resolved as a valid type by the type resol
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/285314cda41c8f7f.
Report an issue: GitHub.