Azure/azure-iot-sdk-csharp

[Bug Report] JsonConvert.DefaultSettings is being modified

citruspress opened this issue · 2 comments

Description of the issue

This library modifies JsonConvert.DefaultSettings. For example in this commit: c1d6e97. In our case we have previously depended on using our own default settings for a lot of other things. Upgrading the DeviceClient means we have to manually specify the settings everywhere we serialize or deserialize anything now.

It doesn't feel correct to modify a global static from a library where the application using the library may previously depend on it.

Code sample exhibiting the issue

We use these settings by setting the DefaultSettings when configuring our app:

new JsonSerializerSettings
{
    Formatting = Formatting.Indented,
    ContractResolver = new CamelCasePropertyNamesContractResolver()
};

When doing the following after creating the device client:

var messageContent = JsonConvert.SerializeObject(new { Test = "test" }, Formatting.None);

it's not using our settings, but it seems like it's rather settings being set by this library.

Seems related to #3358

Closing this thread as it is a duplicate of #3358 as noted above.