autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Generated C# code should avoid using JsonConvert

Open bitsforthought opened this issue 11 years ago • 2 comments

See related issue in the pre-AutoRest Search SDK: https://github.com/Azure/azure-sdk-for-net/issues/1438

JsonConvert has a static DefaultSettings property. Unfortunately, even if you pass your own JsonSerializerSettings to SerializeObject/DeserializeObject, they do not completely replace the default settings. Some settings like JsonConverters are merged rather than replaced.

What this means is that code using an AutoRest-generated client library might modify JsonConvert.DefaultSettings in ways that disrupt the serialization/deserialization of payloads by the client library. Instead, the generated code should call JsonSerializer directly. It is simple to write some wrappers that mimic JsonConvert (see this PR for an example: https://github.com/Azure/azure-sdk-for-net/pull/1451).

bitsforthought avatar Sep 30 '15 22:09 bitsforthought

Tracking via https://www.pivotaltracker.com/story/show/107069918

stankovski avatar Oct 30 '15 18:10 stankovski

I'm going to try to fix this.

bitsforthought avatar Dec 08 '15 22:12 bitsforthought