Newtonsoft.Json icon indicating copy to clipboard operation
Newtonsoft.Json copied to clipboard

Is Json.NET Supporting .NET 7 AOT?

Open AloisKraus opened this issue 1 year ago • 6 comments

Stephen Toub has mentioned in https://devblogs.microsoft.com/dotnet/performance_improvements_in_net_7/comment-page-3/#native-aot

that if you publish a .NET 7 application with AOT support no JIT compiler exists. Is Json.NET able to work around that like System.Text.Json which has since .NET 6.0 compile time source generator support? I would love to continue to use Json.NET because it I still want to target .NET 4.8.

AloisKraus avatar Sep 11 '22 19:09 AloisKraus

Unlikely. It wasn’t designed for AOT and adding something like a generator would be a huge amount of work.

JamesNK avatar Sep 11 '22 22:09 JamesNK

@JamesNK So what now? Will there be a compatible version or should I look for a different Json Package? I'm not able to publish my app on iOS unless I have it use the interpreter.

owl-guy avatar Nov 17 '22 07:11 owl-guy

@JamesNK So what now? Will there be a compatible version or should I look for a different Json Package? I'm not able to publish my app on iOS unless I have it use the interpreter.

use System.Text.Json

g0dpain avatar Nov 22 '22 13:11 g0dpain

Không thể. Nó không được thiết kế cho AOT và việc thêm một thứ gì đó như máy phát điện sẽ là một khối lượng công việc khổng lồ.

why??

NCLnclNCL avatar Aug 28 '23 11:08 NCLnclNCL

adding something like a generator would be a huge amount of work

Would just falling back to reflection in the AOT scenario be a more feasible step forward? My guess is that reflection is plenty fast enough for most users.

madelson avatar Jan 06 '24 18:01 madelson

@madelson

Would just falling back to reflection in the AOT scenario be a more feasible step forward? My guess is that reflection is plenty fast enough for most users.

AOT includes trimming, which strips away a lot of reflection metadata. Source generation is basically a requirement for the AOT scenario.

BMurri avatar Apr 08 '24 23:04 BMurri