Generated the JSON contracts of the stored data at compile time (#1148)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-02 18:23:19 +01:00
1 parent fc7399e81b
commit e954881fda
75 files changed
+5437 -298

No files matched your search

@@ -51,12 +51,13 @@ public static class DataBackupFormat
/// How the manifest and the plan of a restore are written: readable for anybody who opens them,
/// and for the runtime, which applies the plan.
/// </summary>
public static readonly JsonSerializerOptions JSON_OPTIONS = new()
public static readonly JsonSerializerOptions JSON_OPTIONS = new JsonSerializerOptions
{
WriteIndented = true,
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
Converters = { new JsonStringEnumConverter() },
};
TypeInfoResolver = DataBackupJsonContext.Default,
}.AsReadOnly();
/// <summary>
/// File types which are compressed already. Compressing them once more costs time and makes the
@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;
namespace AIStudio.Tools.DataBackup;
/// <summary>
/// The contracts with which System.Text.Json reads and writes the manifest of a backup and the plan and report of
/// a restore, built at compile time.
/// </summary>
[JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Metadata)]
[JsonSerializable(typeof(DataBackupManifest))]
[JsonSerializable(typeof(DataRestorePlan))]
[JsonSerializable(typeof(DataRestoreReport))]
internal sealed partial class DataBackupJsonContext : JsonSerializerContext;