Is there an existing issue for this?
Describe the bug
Looks like this is related to the pull request #60498 "Limit types that get converted to null for empty/null input in NullableConverter", looks like TimeSpan should be included in the list.
I ran a script against all the NullableConverter types in WellKnownConverters.cs and it looks like there are several types defined there that won't deserialize to null.
- Int128
- UInt128
- Half
- TimeSpan
- Guid
var types = new[]
{
typeof(char),
typeof(bool),
typeof(byte),
typeof(sbyte),
typeof(ushort),
typeof(uint),
typeof(ulong),
typeof(Int128),
typeof(short),
typeof(int),
typeof(long),
typeof(UInt128),
typeof(Half),
typeof(float),
typeof(double),
typeof(decimal),
typeof(DateOnly),
typeof(DateTime),
typeof(DateTimeOffset),
typeof(TimeSpan),
typeof(TimeOnly),
typeof(Guid),
};
foreach (var type in types)
{
var isSupportedUnderlyingType = IsSupportedUnderlyingType(type);
if (!isSupportedUnderlyingType)
Console.WriteLine(type.Name);
}
static bool IsSupportedUnderlyingType(Type type)
{
return Type.GetTypeCode(type) != TypeCode.Object || IsSupportedUnderlyingObjectType(type);
}
static bool IsSupportedUnderlyingObjectType(Type type)
{
return type == typeof(DateOnly) || type == typeof(TimeOnly) || type == typeof(DateTimeOffset);
}
Expected Behavior
A form value of "" should deserialize to null.
Steps To Reproduce
- Create a Blazor server side app
- Create a model object with a property of type
Nullable?
- Create a form that has that property in it
- Submit the form with the value blank
Exceptions (if any)
No response
.NET Version
10.0.203
Anything else?
No response
Is there an existing issue for this?
Describe the bug
Looks like this is related to the pull request #60498 "Limit types that get converted to null for empty/null input in NullableConverter", looks like TimeSpan should be included in the list.
I ran a script against all the NullableConverter types in WellKnownConverters.cs and it looks like there are several types defined there that won't deserialize to null.
Expected Behavior
A form value of "" should deserialize to null.
Steps To Reproduce
Nullable?Exceptions (if any)
No response
.NET Version
10.0.203
Anything else?
No response