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

Update MonkeyCache to 2.0 and use System.Text.Json #109

Merged
merged 5 commits into from
Mar 31, 2022

Conversation

eerhardt
Copy link
Contributor

  • Drop Newtonsoft and use System.Text.Json instead
    • Allow for source generators to be used in IBarrel
  • Drop Xamarin TFMs and just target net6.0
  • Mark MonkeyCache assemblies as IsTrimmable=true, so unused code can be trimmed

@jamesmontemagno

- Drop Newtonsoft and use System.Text.Json instead
    - Allow for source generators to be used in IBarrel
- Drop Xamarin TFMs and just target net6.0
- Mark MonkeyCache assemblies as IsTrimmable=true, so unused code can be trimmed
@eerhardt eerhardt force-pushed the v2.0 branch 2 times, most recently from 4ede7a8 to 6363e9e Compare March 31, 2022 17:47
There is only one place that needs OS specific APIs in BarrelUtils. So only the main MonkeyCache.csproj needs to be multi-targeted.
@eerhardt
Copy link
Contributor Author

You'll want to review this with whitespace ignored. I formatted the .csprojs because there was a mix of tabs vs spaces in them.

@jamesmontemagno jamesmontemagno merged commit bc7f815 into jamesmontemagno:vnext Mar 31, 2022
@eerhardt eerhardt deleted the v2.0 branch March 31, 2022 18:35
@jamesmontemagno
Copy link
Owner

@eerhardt we should probably write some docs on this.....

@eerhardt
Copy link
Contributor Author

eerhardt commented Apr 2, 2022

Definitely can do. Do we have docs for MonkeyCache somewhere? The root Readme good enough?

@jamesmontemagno
Copy link
Owner

jamesmontemagno commented Apr 2, 2022

Yeah readme is good enough:)

@davidbuckleyni
Copy link

Why their are some nice additions in netown soft why do companies not reach out to developers first before removing stuff

@eerhardt
Copy link
Contributor Author

eerhardt commented Apr 3, 2022

@davidbuckleyni - can you explain a little bit more?

You can still use Newtonsoft to serialize your objects yourself and put them into the Barrel as string.

The biggest reasons for moving to System.Text.Json in this library are:

  1. When using Blazor components in Maui, ASP.NET is already using System.Text.Json. So you are paying double for Json serialization size. In the .NET Podcasts app, using this change reduces the app size by over 10%. See Use System.Text.Json instead of Newtonsoft. microsoft/dotnet-podcasts#58.
  2. You can use Source Generation for JSON serialization and deserialization. See https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-source-generator/ for more details on all the advantages this gives you.

Newtonsoft does have capabilities that System.Text.Json doesn't. But the issue with keeping a reference to Newtonsoft is that Newtonsoft isn't marked as a "Trimmable" assembly. So if you reference it anywhere in your app (even if the code referencing it is trimmed), the whole assembly and anything it references are preserved in your app. This causes bloat in your apps.

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

Successfully merging this pull request may close these issues.

3 participants