System.Text.Json contract customization ignoring custom CreateObject
delegates in certain collection types
#73382
Labels
Milestone
Consider the following code sample:
This is because many collection converters are hardcoding their
CreateObject
implementation which ignores any user-defined delegates:runtime/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableOfTConverter.cs
Lines 23 to 31 in 02910b4
Note that this is currently not possible to fix unless we expose an API equivalent to the
JsonCollectionConverter.Add
method. For .NET 7 we should add detection for converters hardcodingCreateObject
/Add
implementations to specific types and have theJsonTypeInfo.CreateObject
setter throw if not supported by the converter.Related to #71944.
The text was updated successfully, but these errors were encountered: