fix(grpc-data): H1 details hash formats every field invariant-culture (review 4)

This commit is contained in:
Joseph Doherty
2026-11-23 19:45:55 -05:00
parent 561e6de52b
commit e04a8b419e
2 changed files with 35 additions and 5 deletions
@@ -43,7 +43,7 @@ internal abstract record HistoryReadVariant
public string ComputeDetailsHash() =>
Convert.ToHexStringLower(SHA256.HashData(Encoding.UTF8.GetBytes(CanonicalForm())));
/// <summary>The canonical text <see cref="ComputeDetailsHash"/> digests.</summary>
/// <summary>The canonical text <see cref="ComputeDetailsHash"/> digests — every field invariant-culture formatted.</summary>
/// <returns>An invariant, field-ordered rendering.</returns>
protected abstract string CanonicalForm();
}
@@ -59,7 +59,7 @@ internal sealed record HistoryReadRawVariant(DateTime StartUtc, DateTime EndUtc,
{
/// <inheritdoc />
protected override string CanonicalForm() =>
$"raw|{StartUtc.Ticks}|{EndUtc.Ticks}|{NumValuesPerNode}|{ReturnBounds}|{IsReadModified}";
FormattableString.Invariant($"raw|{StartUtc.Ticks}|{EndUtc.Ticks}|{NumValuesPerNode}|{ReturnBounds}|{IsReadModified}");
}
/// <summary>HistoryRead-Processed. The aggregate is per node (<see cref="HistoryReadPortItem.AggregateType"/>).</summary>
@@ -74,8 +74,9 @@ internal sealed record HistoryReadProcessedVariant(DateTime StartUtc, DateTime E
protected override string CanonicalForm()
{
var c = AggregateConfiguration;
var config = c is null ? "null" : $"{c.UseServerCapabilitiesDefaults}|{c.TreatUncertainAsBad}|{c.PercentDataBad}|{c.PercentDataGood}|{c.UseSlopedExtrapolation}";
return $"processed|{StartUtc.Ticks}|{EndUtc.Ticks}|{ProcessingInterval.Ticks}|{config}";
var config = c is null ? "null" : FormattableString.Invariant(
$"{c.UseServerCapabilitiesDefaults}|{c.TreatUncertainAsBad}|{c.PercentDataBad}|{c.PercentDataGood}|{c.UseSlopedExtrapolation}");
return FormattableString.Invariant($"processed|{StartUtc.Ticks}|{EndUtc.Ticks}|{ProcessingInterval.Ticks}|{config}");
}
}
@@ -84,7 +85,8 @@ internal sealed record HistoryReadProcessedVariant(DateTime StartUtc, DateTime E
internal sealed record HistoryReadAtTimeVariant(IReadOnlyList<DateTime> TimestampsUtc) : HistoryReadVariant
{
/// <inheritdoc />
protected override string CanonicalForm() => "attime|" + string.Join(",", TimestampsUtc.Select(t => t.Ticks));
protected override string CanonicalForm() =>
"attime|" + string.Join(",", TimestampsUtc.Select(t => t.Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)));
}
/// <summary>One node of a port request, addressed SDK-handle-free by <c>(realm, identifier)</c>.</summary>