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

Using System.Text.Json instead #15

Closed
baoduy opened this issue Nov 19, 2019 · 9 comments
Closed

Using System.Text.Json instead #15

baoduy opened this issue Nov 19, 2019 · 9 comments
Labels
enhancement New feature or request net5 feature

Comments

@baoduy
Copy link

baoduy commented Nov 19, 2019

As System.Text.Json had been instroduced from .Net Core 3.0. May I submit an request to migrate Json serialization from Newtonsoft.Json to System.Text.Json

@proudmonkey
Copy link
Owner

proudmonkey commented Nov 19, 2019

Hi @baoduy - Thanks for the feedback! Yes. Transitioning to System.Text.Json is part of my road map. In fact I've created AutoWrapper.Server which is an unwrapper handler for AutoWrapper response in the server that uses System.Text.Json. :)

If you want to contribute, let me know! :)

@proudmonkey proudmonkey added the enhancement New feature or request label Nov 19, 2019
@baoduy
Copy link
Author

baoduy commented Nov 20, 2019

Hi @proudmonkey
I were took a look on your code. Let’s see if I could able to submit some PR as the code should have unit tests to track the breaking changes as well.

@proudmonkey
Copy link
Owner

proudmonkey commented Nov 20, 2019

@baoduy Just an FYI. I can't seem to find any document in .NET Core 3.x that shows how to create a custom contract resolver for System.Text.Json.Serialization and AutoWrapper uses CustomContactResolver from Newtonsoft.Json.Serialization.

@baoduy
Copy link
Author

baoduy commented Nov 21, 2019

You are right, And We are stuck there

@Vouzamo
Copy link

Vouzamo commented Nov 21, 2019

What about using a converter factory as shown here: https://weblogs.thinktecture.com/pawel/2019/10/aspnet-core-3-0-custom-jsonconverter-for-the-new-system_text_json.html

@proudmonkey
Copy link
Owner

@Vouzamo Interesting stuff there. I'll see what i can do. Thanks for sharing the link! :)

@mjftechnology
Copy link

Looking forward to this enhancement :)

@Vikaskumargd
Copy link

@proudmonkey Looking forward to this enhancement 😊

@proudmonkey
Copy link
Owner

All - I've released an RC version just to test out the migration to .NET 5. Alot of code refactoring has been done for v5 and there are breaking changes. I would really appreciate if you could test it out as well: https://www.nuget.org/packages/AutoWrapper.Core/5.0.0-rc

Please provide feedback if there are any issues you encountered. Thank you!

Breaking changes

  • This release only supports .NET 5
  • Middleware has been renamed from UseApiResponseAndExceptionWrapper to UseAutoWrapper. Make sure to update your Startup.cs to use the new name.
  • ProblemDetails is now the default exception format
  • Removed Newtonsoft.Json dependency and replaced it with System.Text.Json
  • Use the interface IApiResponse model instead of the concrete ApiResponse model for returning responses using the default format. This allows you to add your own properties that will wrapped within the Result property.
  • AutoWrapIgnore and RequestDataLogIgnore attributes now leaves under AutoWrapper.Attributes namespace. The implementation was changed from using IActionFilter to use Attribute, eliminating all the request header logic.
  • The following options has been removed:
    • ApiVersion
    • ReferenceLoopHandling
    • UseCustomSchema

ReferenceLoopHandling and DefaultContractResolver aren't still supported in .NET 5 that's why handling reference loop and ApiResponse property mappings will not be supported when targetting .NET 5.
.NET Core 3.1 will still use Newtonsoft.Json and it's only supported by AutoWrapper <= v4.5.0

@baoduy baoduy closed this as completed Jul 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request net5 feature
Projects
None yet
Development

No branches or pull requests

5 participants