JamesNK / Newtonsoft.Json

Json.NET is a popular high-performance JSON framework for .NET
https://www.newtonsoft.com/json
MIT License
10.84k stars 3.26k forks source link

Needs nativeaot compatibility #2895

Closed NCLnclNCL closed 8 months ago

NCLnclNCL commented 1 year ago

Although system.text.json is compatible with json, it seems that very few projects use it because it is unfamiliar and only available for dotnet core a lot of projects use this but because this is not trimmed it has a lot more size compared to the newer library i wish someone can make it compatible with native aot, or show me how to reduce the compile size with this library

charlesroddie commented 1 year ago

I believe that (with apologies if my knowledge of newtonsoft.json is not up to date: There are aspects of this library that are compatible with nativeaot (e.g. using JsonObject constructors etc. to serialize and deserialize). There are also aspects that are not compatible (e.g. taking a dotnet class and using reflection to serialize and deserialize it).

This library then would need to be annotated for trimming. E.g. DynamicallyAccessedCode annotations on Serialize<'T>. Then consumers of the library will not see warnings unless they use the problematic code.