diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/HistoryReadPort.cs b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/HistoryReadPort.cs
index 784c5013c..1f8c65661 100644
--- a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/HistoryReadPort.cs
+++ b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/HistoryReadPort.cs
@@ -43,7 +43,7 @@ internal abstract record HistoryReadVariant
public string ComputeDetailsHash() =>
Convert.ToHexStringLower(SHA256.HashData(Encoding.UTF8.GetBytes(CanonicalForm())));
- /// The canonical text digests.
+ /// The canonical text digests — every field invariant-culture formatted.
/// An invariant, field-ordered rendering.
protected abstract string CanonicalForm();
}
@@ -59,7 +59,7 @@ internal sealed record HistoryReadRawVariant(DateTime StartUtc, DateTime EndUtc,
{
///
protected override string CanonicalForm() =>
- $"raw|{StartUtc.Ticks}|{EndUtc.Ticks}|{NumValuesPerNode}|{ReturnBounds}|{IsReadModified}";
+ FormattableString.Invariant($"raw|{StartUtc.Ticks}|{EndUtc.Ticks}|{NumValuesPerNode}|{ReturnBounds}|{IsReadModified}");
}
/// HistoryRead-Processed. The aggregate is per node ().
@@ -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 TimestampsUtc) : HistoryReadVariant
{
///
- 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)));
}
/// One node of a port request, addressed SDK-handle-free by (realm, identifier).
diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/PeerHistoryContinuationStoreTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/PeerHistoryContinuationStoreTests.cs
index 3745237e8..5fbe805ba 100644
--- a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/PeerHistoryContinuationStoreTests.cs
+++ b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/PeerHistoryContinuationStoreTests.cs
@@ -222,6 +222,34 @@ public sealed class PeerHistoryContinuationStoreTests
store.Count.ShouldBe(0);
}
+ [Fact]
+ public void The_details_hash_is_culture_invariant()
+ {
+ var variants = new HistoryReadVariant[]
+ {
+ new HistoryReadRawVariant(DateTime.UnixEpoch, DateTime.UnixEpoch.AddHours(1), 10, ReturnBounds: true),
+ new HistoryReadProcessedVariant(DateTime.UnixEpoch, DateTime.UnixEpoch.AddHours(1), TimeSpan.FromTicks(-5),
+ new Opc.Ua.AggregateConfiguration { PercentDataBad = 100, PercentDataGood = 100 }),
+ new HistoryReadAtTimeVariant([DateTime.UnixEpoch, DateTime.UnixEpoch.AddSeconds(1)]),
+ };
+ var invariant = variants.Select(v => v.ComputeDetailsHash()).ToArray();
+
+ var odd = (System.Globalization.CultureInfo)System.Globalization.CultureInfo.InvariantCulture.Clone();
+ odd.NumberFormat.NegativeSign = "~";
+ odd.NumberFormat.NumberGroupSeparator = "'";
+ odd.TextInfo.ListSeparator = "#";
+ var previous = System.Globalization.CultureInfo.CurrentCulture;
+ try
+ {
+ System.Globalization.CultureInfo.CurrentCulture = odd;
+ variants.Select(v => v.ComputeDetailsHash()).ToArray().ShouldBe(invariant);
+ }
+ finally
+ {
+ System.Globalization.CultureInfo.CurrentCulture = previous;
+ }
+ }
+
/// A monotonic test clock.
private sealed class ManualClock : TimeProvider
{