save progress
This commit is contained in:
@@ -42,12 +42,40 @@ public sealed class DeterminismVerifier
|
||||
private static IReadOnlyList<string> FindDifferences(string a, string b)
|
||||
{
|
||||
var differences = new List<string>();
|
||||
using var docA = JsonDocument.Parse(a);
|
||||
using var docB = JsonDocument.Parse(b);
|
||||
CompareElements(docA.RootElement, docB.RootElement, "$", differences);
|
||||
var parsedA = TryParseJson(a, "inputA", differences, out var docA);
|
||||
var parsedB = TryParseJson(b, "inputB", differences, out var docB);
|
||||
if (!parsedA || !parsedB)
|
||||
{
|
||||
return differences;
|
||||
}
|
||||
|
||||
using (docA)
|
||||
using (docB)
|
||||
{
|
||||
CompareElements(docA.RootElement, docB.RootElement, "$", differences);
|
||||
}
|
||||
return differences;
|
||||
}
|
||||
|
||||
private static bool TryParseJson(
|
||||
string json,
|
||||
string label,
|
||||
List<string> differences,
|
||||
out JsonDocument doc)
|
||||
{
|
||||
try
|
||||
{
|
||||
doc = JsonDocument.Parse(json);
|
||||
return true;
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
differences.Add($"{label}: invalid JSON ({ex.Message})");
|
||||
doc = null!;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CompareElements(JsonElement a, JsonElement b, string path, List<string> differences)
|
||||
{
|
||||
if (a.ValueKind != b.ValueKind)
|
||||
|
||||
Reference in New Issue
Block a user