Closed fjmorel closed 6 months ago
I was expecting nullable types like DateTime?
to be supported, with null handling done in the custom converter implementation.
Maybe the issue could be solved by changing the code pinpointed by fjmorel to something like this:
return value is T v
? ConvertToString(v, row, memberMapData)
: value == null && default(T) == null ? ConvertToString(default(T), row, memberMapData) : throw new InvalidCastException();
Fixed and in release 31.0.3 on NuGet.
Describe the bug
When using the new generic
TypeConverter<T>
with a nullable value type (likebool?
), writing null values does not work. I was working with Mongo'sObjectId
, but converted this sample to usebool
instead. This probably applies to any structs.To Reproduce
Expected behavior
When testing my type converter, I expect to be able to read and write any valid value.
Screenshots
Additional context
I believe this is due to the cast in
TypeConverter<>
. If you uncomment the first 2 lines of the test, you'll see thatbool? null is bool?
doesn't work.Stack trace: