SourceGenerationContext.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #nullable disable
  2. using System.Collections.Concurrent;
  3. using System.Text.Json.Serialization;
  4. namespace Terminal.Gui.Configuration;
  5. /// <summary>
  6. /// Allow AOT and self-contained single file applications with the <see cref="System.Text.Json.Serialization"/>.
  7. /// <para>
  8. /// The SourceGenerationContext class leverages the System.Text.Json source generation feature to pre-generate
  9. /// serialization metadata for specific types. This approach avoids runtime reflection, which is problematic in AOT
  10. /// scenarios where metadata might be stripped, and improves performance by generating serialization code at
  11. /// compile time.
  12. /// </para>
  13. /// </summary>
  14. [JsonSerializable (typeof (bool?))]
  15. [JsonSerializable (typeof (Dictionary<string, object>))]
  16. [JsonSerializable (typeof (List<string>))]
  17. [JsonSerializable (typeof (Attribute))]
  18. [JsonSerializable (typeof (Color))]
  19. [JsonSerializable (typeof (Key))]
  20. [JsonSerializable (typeof (Glyphs))]
  21. [JsonSerializable (typeof (Alignment))]
  22. [JsonSerializable (typeof (AlignmentModes))]
  23. [JsonSerializable (typeof (LineStyle))]
  24. [JsonSerializable (typeof (ShadowStyle))]
  25. [JsonSerializable (typeof (MouseState))]
  26. [JsonSerializable (typeof (TextStyle))]
  27. [JsonSerializable (typeof (Dictionary<ColorName16, string>))]
  28. [JsonSerializable (typeof (Dictionary<string, Color>))]
  29. [JsonSerializable (typeof (Dictionary<string, ConfigProperty>))]
  30. [JsonSerializable (typeof (ConcurrentDictionary<string, ConfigProperty>))]
  31. [JsonSerializable (typeof (ConfigProperty))]
  32. [JsonSerializable (typeof (Scope<string>))]
  33. [JsonSerializable (typeof (AppSettingsScope))]
  34. [JsonSerializable (typeof (SettingsScope))]
  35. [JsonSerializable (typeof (ThemeScope))]
  36. [JsonSerializable (typeof (Scope<ThemeScope>))]
  37. [JsonSerializable (typeof (Scope<AppSettingsScope>))]
  38. [JsonSerializable (typeof (Scope<SettingsScope>))]
  39. [JsonSerializable (typeof (ConcurrentDictionary<string, ThemeScope>))]
  40. [JsonSerializable (typeof (Dictionary<string, Scheme>))]
  41. internal partial class SourceGenerationContext : JsonSerializerContext
  42. { }