Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save AnthonyGiretti/9f3c38eb566773a84a521410ad415c0d to your computer and use it in GitHub Desktop.
Before .NET 10, Handling circular references with source generation simply wasn't possible
using System.Text.Json.Serialization;
// This would throw at runtime if Employee has circular references
[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