JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.69k stars 1.06k forks source link

Fix UseDefaultOnConversionFailure behavior for nullable types #2275

Open twinee opened 1 month ago

twinee commented 1 month ago

Setting null as the default value for a member with a nullable type with UseDefaultOnConversionFailure set to true will not use that default value when a conversion failure occurs, but throws a TypeConverterException instead. This is unintuitive behavior and seems like a bug.

This code fixes the type comparison when the default value is set to null so that the code behaves like one would expect.

discussion