save progress

This commit is contained in:
StellaOps Bot
2025-12-18 09:53:46 +02:00
parent 28823a8960
commit 7d5250238c
87 changed files with 9750 additions and 2026 deletions

View File

@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace StellaOps.Scanner.CallGraph.Serialization;
/// <summary>
/// System.Text.Json converter for <see cref="ImmutableArray{T}"/> to ensure default serializer options
/// can round-trip call graph models without requiring per-call JsonSerializerOptions registration.
/// </summary>
public sealed class ImmutableArrayJsonConverter<T> : JsonConverter<ImmutableArray<T>>
{
public override ImmutableArray<T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
{
return ImmutableArray<T>.Empty;
}
var values = JsonSerializer.Deserialize<List<T>>(ref reader, options);
if (values is null || values.Count == 0)
{
return ImmutableArray<T>.Empty;
}
return ImmutableArray.CreateRange(values);
}
public override void Write(Utf8JsonWriter writer, ImmutableArray<T> value, JsonSerializerOptions options)
{
writer.WriteStartArray();
var normalized = value.IsDefault ? ImmutableArray<T>.Empty : value;
foreach (var item in normalized)
{
JsonSerializer.Serialize(writer, item, options);
}
writer.WriteEndArray();
}
}