feat: freeze v1 transport contracts (#4)
quality-gate / quality (push) Successful in 51s

Closes #4
This commit is contained in:
KyuubiYoru
2026-07-16 04:52:38 +02:00
parent e626b89909
commit 69c8b2d2bc
43 changed files with 3737 additions and 12 deletions
@@ -0,0 +1,49 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace FinalFactory.Rendezvous.Contracts;
public static class ContractJson
{
private static readonly JsonSerializerOptions SharedOptions = CreateReadOnlyOptions();
public static JsonSerializerOptions Options => SharedOptions;
public static JsonSerializerOptions CreateOptions()
{
JsonSerializerOptions options = new(JsonSerializerDefaults.Web);
Configure(options);
return options;
}
public static void Configure(JsonSerializerOptions options)
{
if (options is null)
{
throw new ArgumentNullException(nameof(options));
}
options.AllowTrailingCommas = false;
options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.MaxDepth = 8;
options.NumberHandling = JsonNumberHandling.Strict;
options.PropertyNameCaseInsensitive = false;
options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.ReadCommentHandling = JsonCommentHandling.Disallow;
options.UnmappedMemberHandling = JsonUnmappedMemberHandling.Skip;
options.WriteIndented = false;
if (!options.Converters.OfType<JsonStringEnumConverter>().Any())
{
options.Converters.Add(
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase, allowIntegerValues: false));
}
}
private static JsonSerializerOptions CreateReadOnlyOptions()
{
JsonSerializerOptions options = CreateOptions();
options.MakeReadOnly(populateMissingResolver: true);
return options;
}
}