-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullReference when JsonExtensionData dictionary have a custom JsonConverter #32903
Comments
Note: custom converters for extension properties can only be used on serialization. Deserialization is handled by the serializer. |
That's a bit strange. Is there a reason for that and should we (can we?) fix it? |
@ahsonkhan Overflow properties does not come on a particular order when reading the JSON and the |
@ahsonkhan it's because we may not have all the extra JSON in one go - we'd have to parse and wrap all the extension properties in one JSON object, or pass the entire payload to the converter to be filtered. FWIW Newtonsoft does not honor custom converters for both reading and writing extension data: https://dotnetfiddle.net/qwMrPS. Writing seems doable, so I think the action for this issue is to fix the NRE and make sure custom converters are honored on serialization. @steveharter, it seems that the assumption in runtime/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.cs Line 283 in 0bf721a
|
I think for writing it makes sense to support custom serialization. |
* Fix NullReference on JsonExtensionData Fix NullReferenceException on serialization when JsonExtensionData dictionary has a custom JsonConverter. Fix #32903 * Add test for converters declared through attribute * Ensure custom serialization is not used for reading JsonExtensionData * Cover all the combinations in tests
Repro:
This only happens in master.
@steveharter @layomia
The text was updated successfully, but these errors were encountered: