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

Newtonsoft.Json -> System.Text.Json #605

Merged
merged 15 commits into from
Mar 7, 2024

Conversation

mpreyskurantov
Copy link
Contributor

@mpreyskurantov mpreyskurantov commented Mar 5, 2024

Changelog:

Structural changes:

  • Remove the Newtonsoft.Json ref from a library, move it to explicit consumers projects ("Tests.Common" + all its satellites and "Tests.NET4" separately) and "Sample" instead, bump to the latest version;
  • Add a build configuration symbol / constant to highlight / isolate Newtonsoft.Json tests (for further moving to a separate project);
  • Add the System.Text.Json cross-target ref, bump the net4 target to a minimal supported version in affected projects accordingly;
  • Clean up usings / namespaces in affected files.

Behavior changes:

  • Implement migration at the serialization / de-serialization level only to minify impact to cross-platform / DBMS-agnostic Data Layer / API. It is primarily related to DataSourceLoadOptionsParser class, which is usually used of the ASP.NET MVC / Core Model Binder.
  • There is no straightforward way to implement a good converter for the "Filter" IList (i.e., a single part of API without the explicit type param), because System.Text.Json types rely on a set of private var / flags and non-obvious "goto" operators internally:

https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.cs
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs

That is why, it is kept the default IList traversing with further unwrap its operands tree, whose items (primitives) wrapped with JsonElement.

  • Ignore (for now) some non-supported scenarios (covered with tests) until their proving or may be agreed bump to the net7 target, where advanced functionality for this purpose is available.

Testing:

Tested against the "Sample" project in this solution (JS dxDataGrid + ASP.NET MVC Backend / Controller) and a modern Blazor DxGrid https://demos.devexpress.com/blazor/Grid/DataBinding/LargeQueryableAsHttp + Data Editors (based on a legacy DxDataGrid).

@mpreyskurantov mpreyskurantov added the .NET Pull requests that update .net code label Mar 5, 2024
@mpreyskurantov mpreyskurantov self-assigned this Mar 5, 2024
@IlyaKhD IlyaKhD self-requested a review March 7, 2024 09:19
@mpreyskurantov mpreyskurantov merged commit 82aba9a into DevExpress:master Mar 7, 2024
10 checks passed
@mpreyskurantov mpreyskurantov deleted the newtonsoft-to-stj branch March 8, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Pull requests that update .net code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants