SourceGenerationContext.cs 2.0 KB

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