Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
464 stars 493 forks source link

[Bug Report] JsonConvert.DefaultSettings = JsonSerializerSettingsInitializer.GetJsonSerializerSettingsDelegate() affects settings globaly #3358

Closed AndreiStselmashenkaEPAM closed 9 months ago

AndreiStselmashenkaEPAM commented 1 year ago

Context

Description of the issue

JsonConvert.DefaultSettings = JsonSerializerSettingsInitializer.GetJsonSerializerSettingsDelegate() modifies Newtonsoft default settings and can affect application behavior

kennethahn commented 11 months ago

Json deserialization changing behavior globally as a side effect of creating an instance of ServiceClient, DeviceClient or RegistryManager. A third party class library changing behavior of another third party library globally, seems like undesirable behavior and something that could cause weird timing sensitive bugs. We had to undo the upgrade to 1.39 due to this breaking stuff in other parts of our system.

Small demo here https://dotnetfiddle.net/a2INHy

stephen-swensen commented 10 months ago

Just ran into same issue, had to downgrade back down to 13.8.1 to resolve. Luckily regression test uncovered the issue but was difficult to pin the culprit. Eventually was able to see through a debug session that JsonConvert.DefaultSetting was pointing to a Azure.Devices type.

kristofferpagels commented 9 months ago

Hi, do you have any news on this issue as it is blocking us from upgrading to 1.39.0.

scherici commented 9 months ago

Same for us, only different .net version (7); it took a lot of work to find out what could be our problem...and discovery this is frustrating. Downgrading to 1.38 fix also for us...but it is not a real....fix Any news?

timtay-microsoft commented 9 months ago

This is definitely a bug and we're looking at this now in #3402

timtay-microsoft commented 9 months ago

This fix has been released as of this release, so I'll close this thread