From 74f9d5e5e4a42abc6380fd8844de26f59a1bbf64 Mon Sep 17 00:00:00 2001 From: Digifais Date: Sun, 1 Sep 2024 18:19:39 +0200 Subject: [PATCH] Update README.md JSON Source Generator (#1793) JsonSerializerOptions.AddContext is obsolete. (https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions.addcontext?view=net-8.0) Co-authored-by: Chris Pulman --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d384f2c33..d96ae1e5f 100644 --- a/README.md +++ b/README.md @@ -495,8 +495,9 @@ public class Foo To apply the benefits of the new [JSON source generator](https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-source-generator/) for System.Text.Json added in .NET 6, you can use `SystemTextJsonContentSerializer` with a custom instance of `RefitSettings` and `JsonSerializerOptions`: ```csharp -var options = new JsonSerializerOptions(); -options.AddContext(); +var options = new JsonSerializerOptions() { + TypeInfoResolver = MyJsonSerializerContext.Default +}; var gitHubApi = RestService.For("https://api.github.com", new RefitSettings {