Closed Kingmidas74 closed 2 years ago
It seems to be enough to add context to the serializer options, and then pass them to the client:
var options = new JsonSerializerOptions();
options.AddContext<MyJsonSerializerContext>();
services.AddNClient<IFileClient>(host: "http://localhost:5001", builder =>
builder.WithSystemTextJsonSerialization(options).Build());
By the way, after closing https://github.com/nclient/NClient/issues/410 issue, it will become even easier to do this.
@Kingmidas74, I suggest you write tests to make sure it works :)
According to this list of advice (see No. 5), using your custom serializators it better than generic stuff. Also, System.Text.Json can generate serializators based on DTO. See this.
What if we can implements compile-time generation of serializers based on generic T parameter in default provider?
Maybe it could improve performance of NClient.