OData / OData/AspNetCoreOData

JPageResultValueConverter does not respect Newtonsoft json serializer naming strategy

Open
#849 6 comments 1 reaction 1 assignee View on GitHub

@xuzhg is already working on this.

Since Feb 27, 2023.

followup
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

Assemblies affected
Microsoft.AspNetCore.OData Version="8.0.12"
Microsoft.AspNetCore.OData.NewtonsoftJson Version="8.0.12"

Describe the bug
In an asp.net core project (.NET 6) using NewtonsoftJson and using the extension method AddODataNewtonsoftJson() when returning a PageResult from a controller the JPageResultValueConverter does not respect the naming strategy used by newtonsoft.json as
the PageResult ToDictionary() method hard-codes the properties names in lowercase

https://github.com/OData/AspNetCoreOData/blob/69eec03c7003fe12d92cdc619efdc16781683694/src/Microsoft.AspNetCore.OData/Results/PageResultOfT.cs#L68

https://github.com/OData/AspNetCoreOData/blob/69eec03c7003fe12d92cdc619efdc16781683694/src/Microsoft.AspNetCore.OData.NewtonsoftJson/JPageResultValueConverter.cs#L53

Reproduce steps
Create a new asp.net core project (.NET 6), install newtonsoft json, set the naming strategy to be PascalCase and return a PageResult from a controller. It will be serialized with {"count" : x, "items": [...] } instead of {"Count" : x, "Items": [...] }

Expected behavior
I expected the newtonsoft json naming strategy to be respected

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.