Skip to content

Instantly share code, notes, and snippets.

@AnthonyGiretti
Created March 7, 2026 23:30
Show Gist options
  • Select an option

  • Save AnthonyGiretti/f8c5a433d8415ed6a00d6902340b5e07 to your computer and use it in GitHub Desktop.

Select an option

Save AnthonyGiretti/f8c5a433d8415ed6a00d6902340b5e07 to your computer and use it in GitHub Desktop.
.NET 10 adds ReferenceHandler support directly inside JsonSourceGenerationOptionsAttribute
using System.Text.Json.Serialization;
// Giving you fine-grained control over how cycles and references are handled at the source generation leve
[JsonSourceGenerationOptions(ReferenceHandler = JsonKnownReferenceHandler.Preserve)]
[JsonSerializable(typeof(Employee))]
internal partial class AppJsonContext : JsonSerializerContext { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment