Fix 2153 TypeConverterFactory not used #2229
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #2153
Notes: I added a new abstract TypeConverterGeneric class to make it easier to create generic type converters.
This is not necessary to fix the issue, but makes it a easier to write generic type converter factories (as can be seen in test).
Please have a look at System.Text.Json.Serialization.JsonConverter (and JsonConverterFactory) which has this and is a quite useful API. I recommend to rename
TypeConverterGeneric<T>
toTypeConverter<T>
to make it consistent (see againJsonConverter
) but this name is already taken without<T>
for something different. I will add another commit to solve this but of course this is a (minor) breaking change as currentTypeConverter
is public (but probably not used by anyone). Please feel free to edit/cherry pick.Let me know if there is anything I can do getting this merged.