nats-io / nats.net

Full Async C# / .NET client for NATS
https://nats-io.github.io/nats.net
Apache License 2.0
272 stars 55 forks source link

Simplify JSON serialization setup #417

Closed mtmk closed 7 months ago

mtmk commented 9 months ago

Proposed change

Currently because we're AOT compatible context or ad-hoc JSON serialization requires a bit of setup to register in the connection:

var jsonRegistry = new NatsJsonContextSerializerRegistry(MyJsonContext.Default);
return opts with { SerializerRegistry = jsonRegistry };

We should be able to simplify this when using hosting extensions.

rickdotnet commented 9 months ago

I took an initial stab at this here as part of #392. Let me know if it aligns with what you were thinking and I can tweak it.