ClearScript
ClearScript copied to clipboard
System.Text.Json and Trimming
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?
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!
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?
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!
I too would like if Clearscript supported trimming. :)
Maybe EnableStringifyEnhancements feature should come with separate plugins (one for Newtonsoft, one for System.Text)