unoplatform/uno · error · ArgumentNullException
type
Error message
type
What it means
Thrown by ValueSerializer.GetSerializerFor(Type, IValueSerializerContext) when the type argument is null. The method needs the type to consult the context and to check whether it is a known MarkupExtension, so it rejects null up front.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Windows.Markup/ValueSerializer.cs:74
if (context != null)
{
return context.GetValueSerializerFor (descriptor);
}
var tc = descriptor.Converter;
if (tc != null && tc.GetType () != typeof (TypeConverter))
{
return new TypeConverterValueSerializer (tc);
}
return null;
}
public static ValueSerializer GetSerializerFor (Type type, IValueSerializerContext context)
{
if (type == null)
{
throw new ArgumentNullException ("type");
}
if (context != null)
{
return context.GetValueSerializerFor (type);
}
// Standard MarkupExtensions are serialized without ValueSerializer.
if (typeof (MarkupExtension).IsAssignableFrom (type) && XamlLanguage.AllTypes.Any (x => x.UnderlyingType == type))
{
return null;
}
// DateTime is documented as special.
if (type == typeof (DateTime))
{
return new DateTimeValueSerializer ();
}View on GitHub (pinned to 0418340488)
Solutions
- Resolve the Type (via GetType/UnderlyingType) and null-check before calling.
- Skip members whose UnderlyingType is null rather than passing null through.
- Use GetSerializerFor(PropertyDescriptor,...) when only a descriptor is available.
Example fix
// before Type t = member.UnderlyingType; // may be null var ser = ValueSerializer.GetSerializerFor(t, ctx); // throws // after Type t = member.UnderlyingType; var ser = t != null ? ValueSerializer.GetSerializerFor(t, ctx) : null;
Defensive patterns
Strategy: validation
Validate before calling
Type t = member.UnderlyingType; if (t == null) return null; // nothing to serialize var ser = ValueSerializer.GetSerializerFor(t, ctx);
Type guard
static bool HasSerializableType(Type t) => t != null;
Prevention
- Filter members whose UnderlyingType is null before serializing.
- Use the descriptor overload when a type is unavailable.
- Document which member kinds (directives, attached) may have null types.
When it happens
Trigger: Calling GetSerializerFor((Type)null, context), commonly when the type was derived from a null-valued property or an unresolved reflection result.
Common situations: Serialization code that walks a member list where UnderlyingType can be null (e.g. attached properties, directives); typeof lookups that returned null on a trimmed/AOT scenario.
Related errors
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/7d355a0f29f9ec41.
Report an issue: GitHub.