Skip to content
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

Use of JsonConvert.DefaultSettings breaks unrelated serialization in v1.4 #229

Closed
seancolonello opened this issue May 18, 2021 · 1 comment · Fixed by #233
Closed

Use of JsonConvert.DefaultSettings breaks unrelated serialization in v1.4 #229

seancolonello opened this issue May 18, 2021 · 1 comment · Fixed by #233

Comments

@seancolonello
Copy link

Upgrading from version 1.3.0 to 1.4.0 resulted in breaking changes for other aspects of my project. The project uses JsonConvert.SerializeObject() with default settings, which retains the POCO property casing (PascalCase in my situation). After the 1.4 update JsonConvert.SerializeObject() defaults to camelCase. This is running locally via Visual Studio 2019, I'm not sure if the same behavior exists deployed to Azure infrastructure.

I assume it's due to the following code fragment in SignalRConfigProvider.Initialize(), which is marked [Obsolete("preview")].

JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
{
Converters = new List<JsonConverter>() { new ServiceEndpointJsonConverter() },
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy()
}
};

I'd say it's bad practice to set global serialization defaults in a library like this, that should be reserved for top level applications. Custom JsonSerializerSettings should be passed via the appropriate overload to JsonConvert methods.

@Y-Sindo
Copy link
Member

Y-Sindo commented May 19, 2021

Thanks for your feedback. We will consider improve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants