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

System.Text.Json and Trimming #392

Open
ColonelBundy opened this issue Jun 26, 2022 · 5 comments
Open

System.Text.Json and Trimming #392

ColonelBundy opened this issue Jun 26, 2022 · 5 comments
Assignees

Comments

@ColonelBundy
Copy link

Swapping out or providing the ability to swap Newtonsoft for System.Text.Json is highly desirable due to performance reasons.

The upcoming .Net 7 release and it's AOT mode is very attractive and to make this library compatible, we'd need proper annotations and configuration available to make this trimmer friendly.

Is there any plans to support the two use cases?

@ClearScriptLib
Copy link
Collaborator

Hello @ColonelBundy,

Swapping out or providing the ability to swap Newtonsoft for System.Text.Json is highly desirable due to performance reasons.

Outside of test code, ClearScript currently uses Newtonsoft.Json only for the recently added EnableStringifyEnhancements feature. Is that what you're referring to?

The upcoming .Net 7 release and it's AOT mode is very attractive and to make this library compatible, we'd need proper annotations and configuration available to make this trimmer friendly.

Please elaborate. What new capabilities will ClearScript need in order to support the scenario you're envisioning?

Thanks!

@ColonelBundy
Copy link
Author

Hello @ColonelBundy,

Swapping out or providing the ability to swap Newtonsoft for System.Text.Json is highly desirable due to performance reasons.

Outside of test code, ClearScript currently uses Newtonsoft.Json only for the recently added EnableStringifyEnhancements feature. Is that what you're referring to?

The upcoming .Net 7 release and it's AOT mode is very attractive and to make this library compatible, we'd need proper annotations and configuration available to make this trimmer friendly.

Please elaborate. What new capabilities will ClearScript need in order to support the scenario you're envisioning?

Thanks!

Yes I'm referrrning to the EnableStringifyEnhancements feature.

For trimming, this is what I'm referring to: https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming
Preliminary tests does indicate Clearscript is not properly supported for trimming. I will test more to confirm this, unless I've made a misstake?

@ClearScriptLib
Copy link
Collaborator

Hi @ColonelBundy,

Yes I'm referrrning to the EnableStringifyEnhancements feature.

We looked into System.Text.Json but went with Json.NET due to the latter's universal compatibility. It's likely that we'll drop support for very old .NET runtime versions at some point, and we'll take another look at System.Text.Json then.

Preliminary tests does indicate Clearscript is not properly supported for trimming.

Certainly. To be honest, AOT is an area we've yet to investigate deeply. At first glance, it's difficult to see how ClearScript could be very functional in such an environment. Not only does it rely heavily on reflection and late binding, but it also enables calls into managed code from scripts – a source that's nowhere to be found at build time. We'll take a closer look.

Thank you!

@cyraid
Copy link

cyraid commented Feb 5, 2023

I too would like if Clearscript supported trimming. :)

@hiyelbaz
Copy link

hiyelbaz commented Feb 5, 2023

Maybe EnableStringifyEnhancements feature should come with separate plugins (one for Newtonsoft, one for System.Text)

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

4 participants