Change Json.net default to camel case causes HMR to stop working #79

Closed
opened 2025-08-09 17:14:55 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @sherif-elmetainy on 5/1/2018

Steps to reproduce:

  • Create a new angular application
    dotnet new angular
  • In Startup.cs constructor type the following code
    JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() };
  • Run the app.

Result

Angular will run in production mode and HMR will not be enabled.

Expected Result

Angular should run in development mode and HMR would be enabled.

Reason

The HotModuleReplacement property is serialized as hotModuleReplacement while WebpackDevMiddleware.js file in aspnet-webpack npm package expects it to start with a capital letter.

Workaround

I solved the issue by removing the line that changes Json.net default settings. However, I think a better solution would be putting JsonProperty attributes on the properties that get serialized.

*Originally created by @sherif-elmetainy on 5/1/2018* #### Steps to reproduce: - Create a new angular application ```dotnet new angular``` - In Startup.cs constructor type the following code ```JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() };``` - Run the app. #### Result Angular will run in production mode and HMR will not be enabled. #### Expected Result Angular should run in development mode and HMR would be enabled. #### Reason The HotModuleReplacement property is serialized as hotModuleReplacement while WebpackDevMiddleware.js file in aspnet-webpack npm package expects it to start with a capital letter. #### Workaround I solved the issue by removing the line that changes Json.net default settings. However, I think a better solution would be putting JsonProperty attributes on the properties that get serialized.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#79
No description provided.