dotnet / dotnet/docs

The "why" of Metadata vs Serialization modes is not described in STJ doc

Open
#38,328 2 comments 1 reaction 1 assignee Claimed by @gewarren View on GitHub
:watch: Not Triaged
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
19h 10m
Merged PRs (30d)
268

Description

https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation?pivots=dotnet-8-0#specify-source-generation-mode

This doc goes into great detail on how to set the modes. It doesn't explain (AFAICT) why to use one vs the other.

This post does a better job: https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-source-generator/. That post still isn't as clear as it could be. I reviewed that post, so that's unfortunate.

My understanding is the following:

- Don't sweat setting anything. The default always works and the downsides of the default are not huge.
- The serialization "logic" option only supports serialization so if you are only using a context for deserialization then metadata mode is a perf optimization. Would be good to quantify how big that is. I assume that only matters for large schemas.
- There are some features that only work with metadata mode, so setting metdata mode is again a perf optimization.

@eiriktsarpalis

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.