Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Update type converters to treat emtpy string the same as null #59

Closed
wants to merge 1 commit into from
Closed

Update type converters to treat emtpy string the same as null #59

wants to merge 1 commit into from

Conversation

akatakritos
Copy link

Empty strings pass through to the base TypeConverter and for enumerable
types at least, this results in a NotSupportedException.

cc90af9 added support for accepting null values, and in pretty much
every case, empty string should be treated as null: no meaninful data
can be gleaned from it for conversion.

EnumConverter works without the check because the empty string gets
pased to the base ConvertFrom method which just returns the default enum
value. But we might as well be explicit about the expected return result
for empty strings.

Fixes #58

Empty strings pass through to the base TypeConverter and for enumerable
types at least, this results in a NotSupportedException.

cc90af9 added support for accepting null values, and in pretty much
every case, empty string should be treated as null: no meaninful data
can be gleaned from it for conversion.

EnumConverter works without the check because the empty string gets
pased to the base ConvertFrom method which just returns the default enum
value. But we might as well be explicit about the expected return result
for empty strings.

Fixes #58
@JimBobSquarePants
Copy link

Merging this into my current branch will cause trouble if done automatically as I've deleted the ConverterHelper class in favour of a base TypeConverter. I'll merge things manually then close this. Thanks for the code! 👍

@akatakritos
Copy link
Author

Cool. Glad to help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

MultiNodeTreePickerConverter<T> throws when passed an empty string
3 participants