trampster / JsonSrcGen

Json library that uses .NET 5 Source Generators
MIT License
148 stars 4 forks source link

How can JsonSrcGen be configured in ASP.NET Core applications? #50

Open fbridger opened 3 years ago

fbridger commented 3 years ago

Is there any way to use the serializer/deserializer that JsonSrcGen produces as the default Json serializer/deserializer in ASP.NET Core applications?

trampster commented 3 years ago

I haven't built anything to do this, but it is definitely something I would like to look into.

One issue that we might run into is that JsonSrcGen doesn't require a lookup to determine the serializer to use for a type, this is because it exposes a separate method for each type which are called directly. This is big performance win. However this advantage will get lost when used as the default serializer because the methods cannot be called directly and so we will have to make a lookup from the type to the method

Even with this lookup JsonSrcGen will likely still be very competitive, but it is worth noting this potential issue.