-
-
Notifications
You must be signed in to change notification settings - Fork 693
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
Support AOT/Trimming/Blazor WebAssembly using source generation #1322
Comments
@cyrmax wow, what a great idea! How would you approach this transformation with the existing codebase? |
Will this work for |
@tuscen
And here is the link: |
@cyrmax Thanks, we'll probably try to migrate to source generated converters then |
@karb0f0s |
@cyrmax By the way, you really don't want this library to be trimmed since it's an API client. What will it do in case your bot receives an object that should be deserialized to a type that was trimmed during compilation? |
@cyrmax Do you have experience with STJ source generators? I’ve tried to use it in this library, but for some reason it doesn’t generate converters. But in a separate test project I don’t have any problems. |
@tuscen I will try to investigate this on weekend. In my projects this feature works just fine too. I will see. |
I've managed to generate json converters, but I struggle to understand how to make it work in .NET 6 in such a way that one could augment existing |
https://www.planetgeek.ch/2022/10/15/using-system-text-json-alongside-newtonsoft-json-net/ Maybe it would be useful for further research. |
We are now using System.Text.Json in recent versions of the library. |
I would like to request/propose a feature
I suggest replacing NewtonSoft.Json with System.Text.Json with proper source generation used.
The reason is that with newtonsoft we cannot use Aot and/or trimming which then breaks the entire Json package.
With System.Text.Json we can see the similar issue with trimming and Aot. But there we can use source generation aproach and avoid any errors when trimming the executable or building native code.
Here is the documentation for this source generation feature in detail and System.Text.Json docs can be googled easily.
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation?pivots=dotnet-8-0
If anybody has any arguments against my feature request I would be glad to discuss them.
Also I will try to implement the thing I want by myself and if I achieve what I want without any errors I of course will make a pull request to address this issue.
Thanks in advance.
The text was updated successfully, but these errors were encountered: