CsvHelper
CsvHelper copied to clipboard
Fix remaining nullable warnings
This PR fixes all remaining nullable warnings using a combination of:
- Annotating members (public included) with
?
or nullable attributes- Note, on netfx and netstandard, these attributes don't exist so I have added them in
NullableAttributes.cs
to prevent build failures, but they don't take part in the nullable state analysis
- Note, on netfx and netstandard, these attributes don't exist so I have added them in
- Throwing explicit exceptions which would otherwise have been implicit
NullReferenceException
s - Adding asserts to make assumptions explicit, e.g validating reflection, which hopefully would fire during test runs if such assumptions have changed
- Some slight refactors including a few breaking changes:
- Added protected constructor on
MemberMap
to ensure non-nullable properties are initialised - Changed argument signature of
public static TypeConverterOptions.Merge
fromMerge(params TypeConverterOptions[] sources)
toMerge(TypeConverterOptions options, params TypeConverterOptions[] sources)
(internal callsites unchanged) - Array/Collection/IEnumerable converters now make use of all Names set rather than just the first (I consider this a feature :slightly_smiling_face:)
- Added protected constructor on
Otherwise I tried to keep functional changes to a minimum, and to follow https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/api-guidelines/nullability.md
Comments welcome