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

Add System.Text.Json Support #356

Closed
salarzobir opened this issue Jan 14, 2021 · 5 comments
Closed

Add System.Text.Json Support #356

salarzobir opened this issue Jan 14, 2021 · 5 comments
Assignees

Comments

@salarzobir
Copy link

When targeting .NET Core 3.0 or higher using System.Text.Json will increase the performance and reduce the memory usage.
Maybe the json serializer could be like a provider that user can change it when configure Audit.NET

@thepirat000
Copy link
Owner

That would be nice to have, but will be a very hard task since the library is highly coupled with newtonsoft.json, specifically with the use of the attributes JsonExtensionData and JsonProperty to annotate all the audit event classes on most of the extensions.

So we'll need to first circunvent all the compile-time issues like this in order to provide a way to select the serialization mechanism at run-time.

Feel free to make any suggestions for this

@thepirat000
Copy link
Owner

thepirat000 commented Jan 28, 2021

I still think providing a mechanism to change the serialization at run-time will be very hard to accomplish.

Maybe we can just default to use system.text.json internally intead of json.net on the assemblies targeting >= .net core 3, and if it was needed, provide alternative assemblies/packages to force the non-default serializarion mechanism (i.e. Audit.NET.NewtonsoftJson)

@thepirat000
Copy link
Owner

I've started trying with System.Text.Json and in less than 5 minutes I've found two open issues that will prevent a smooth migration:

So I think that, at this time, System.Text.Json api is not mature enough to start the migration of this library.

@thepirat000 thepirat000 self-assigned this Feb 19, 2021
@thepirat000
Copy link
Owner

8358983

@thepirat000
Copy link
Owner

thepirat000 commented Jul 26, 2021

Added support to System.Text.Json starting on version 18 (only for .NET >= 5.0)

Refer to the following README sections:

All the libraries were impacted since this was a very big change (184 files changed) so please expect some backward compatibility issues on the new serialization mechanism, even though all the unit tests and integration tests are passing, specially since the System.Text.Json doesn't support (yet?) a lot of things that Newtonsoft.Json does.

Please upgrade your references to version 18.0.0 and test.

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

No branches or pull requests

2 participants