Skip to content

Commit 09a561f

Browse files
authored
Document ReferenceResolver limitations with custom converters in System.Text.Json (#47606)
1 parent f3f7659 commit 09a561f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/standard/serialization/system-text-json/converters-how-to.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ When the sample code calls the serializer, it uses a <xref:System.Text.Json.Json
355355

356356
The preceding example only does serialization, but a similar approach can be adopted for deserialization.
357357

358+
### ReferenceResolver limitations with custom converters
359+
360+
When you use <xref:System.Text.Json.Serialization.ReferenceHandler.Preserve%2A>, be aware that reference handling state isn't preserved when the serializer calls into a custom converter. This means that if you have a custom converter for a type that's part of an object graph being serialized or deserialized with reference preservation enabled, the converter and any nested serialization calls won't have access to the current <xref:System.Text.Json.Serialization.ReferenceResolver> instance.
361+
358362
## Other custom converter samples
359363

360364
The [Migrate from Newtonsoft.Json to System.Text.Json](migrate-from-newtonsoft.md) article contains additional samples of custom converters.

0 commit comments

Comments
 (0)