From 919009c5efa9d4ab57331f4bd17543bc50db091c Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 9 Nov 2026 13:40:07 -0500 Subject: [PATCH] fix(ablegacy): stamp health from the injectable Clock; drop the redundant per-project TreatWarningsAsErrors (lmxopcua#768) AbLegacyDriver stamped LastSuccessfulRead (init, read, write), the read's sample timestamps and host-state change times from raw DateTime.UtcNow; only the backoff path read the injectable Clock. All of them now read Clock(), so NativePcccBridgeStatusHealthTests drives a manual clock (init at T0, read at T1) and asserts LastSuccessfulRead == T1 exactly instead of spin-waiting for the wall clock to pass the init stamp (#767). Without the driver change the 6 tests fail (init stamp is wall-clock, not T0). Directory.Build.props sets TreatWarningsAsErrors for every project since #766, so the 75 per-csproj copies (64 src + 11 tests) are removed and the props comment says it is now the only place. tools/mem-probe keeps its explicit opt-out. Release build: 0 warnings, 0 errors; a planted CS0168 still fails the build in a src project and in a test project that used to carry its own copy. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV --- Directory.Build.props | 6 +-- .../ZB.MOM.WW.OtOpcUa.Client.CLI.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Client.Shared.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Client.UI.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Cluster.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Commons.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Configuration.csproj | 1 - ...ZB.MOM.WW.OtOpcUa.Core.Abstractions.csproj | 1 - ....MOM.WW.OtOpcUa.Core.AlarmHistorian.csproj | 1 - ....MOM.WW.OtOpcUa.Core.ScriptedAlarms.csproj | 1 - ...OtOpcUa.Core.Scripting.Abstractions.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Core.Scripting.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Core.VirtualTags.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Core.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.AbCip.Cli.csproj | 1 - ....MOM.WW.OtOpcUa.Driver.AbLegacy.Cli.csproj | 1 - ...ZB.MOM.WW.OtOpcUa.Driver.Cli.Common.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Cli.csproj | 1 - ...ZB.MOM.WW.OtOpcUa.Driver.Modbus.Cli.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.S7.Cli.csproj | 1 - ...B.MOM.WW.OtOpcUa.Driver.TwinCAT.Cli.csproj | 1 - ....MOM.WW.OtOpcUa.Driver.Ab.Transport.csproj | 1 - ...M.WW.OtOpcUa.Driver.AbCip.Contracts.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.AbCip.csproj | 1 - ...W.OtOpcUa.Driver.AbLegacy.Contracts.csproj | 1 - .../AbLegacyDriver.cs | 18 +++---- .../ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.csproj | 1 - ...tOpcUa.Driver.Calculation.Contracts.csproj | 1 - ...B.MOM.WW.OtOpcUa.Driver.Calculation.csproj | 1 - ...M.WW.OtOpcUa.Driver.FOCAS.Contracts.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.FOCAS.csproj | 1 - ...OM.WW.OtOpcUa.Driver.Galaxy.Browser.csproj | 1 - ....WW.OtOpcUa.Driver.Galaxy.Contracts.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.Galaxy.csproj | 1 - ...WW.OtOpcUa.Driver.Historian.Gateway.csproj | 1 - ...WW.OtOpcUa.Driver.Historian.QuestDb.csproj | 1 - ...OtOpcUa.Driver.Historian.Sql.Common.csproj | 1 - ....OtOpcUa.Driver.Historian.SqlServer.csproj | 1 - ....OtOpcUa.Driver.MTConnect.Contracts.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.MTConnect.csproj | 1 - ...WW.OtOpcUa.Driver.Modbus.Addressing.csproj | 1 - ....WW.OtOpcUa.Driver.Modbus.Contracts.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.Modbus.csproj | 1 - ....MOM.WW.OtOpcUa.Driver.Mqtt.Browser.csproj | 1 - ...OM.WW.OtOpcUa.Driver.Mqtt.Contracts.csproj | 1 - ...OM.WW.OtOpcUa.Driver.Mqtt.Transport.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.Mqtt.csproj | 1 - ....OtOpcUa.Driver.OpcUaClient.Browser.csproj | 1 - ...tOpcUa.Driver.OpcUaClient.Contracts.csproj | 1 - ....OtOpcUa.Driver.OpcUaClient.Session.csproj | 1 - ...B.MOM.WW.OtOpcUa.Driver.OpcUaClient.csproj | 1 - ....MOM.WW.OtOpcUa.Driver.S7.Contracts.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.S7.csproj | 1 - ...B.MOM.WW.OtOpcUa.Driver.Sql.Browser.csproj | 1 - ...MOM.WW.OtOpcUa.Driver.Sql.Contracts.csproj | 1 - ...B.MOM.WW.OtOpcUa.Driver.Sql.Dialect.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.Sql.csproj | 1 - ...WW.OtOpcUa.Driver.TwinCAT.Contracts.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.AdminUI.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.ControlPlane.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Host.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.OpcUaServer.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Runtime.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Security.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Analyzers.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Cluster.Tests.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Commons.Tests.csproj | 1 - .../NativePcccBridgeStatusHealthTests.cs | 47 ++++++++++--------- ...pcUa.Driver.Mqtt.SparkplugSimulator.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj | 1 - ...B.MOM.WW.OtOpcUa.ControlPlane.Tests.csproj | 1 - ...OM.WW.OtOpcUa.Host.IntegrationTests.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Host.Tests.csproj | 1 - ...tOpcUa.OpcUaServer.IntegrationTests.csproj | 1 - ...ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Runtime.Tests.csproj | 1 - .../ZB.MOM.WW.OtOpcUa.Security.Tests.csproj | 1 - 78 files changed, 39 insertions(+), 107 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index f2ceb237..b4355f96 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,9 +4,9 @@ TreatWarningsAsErrors is ON for every project, src/ and tests alike (#766 ratchet). The solution builds with 0 warnings since #725 (xUnit1051 etc. cleaned), so any new warning, including analyzer ones, now fails the - build instead of accumulating. The 61 src/ projects also still set it in their own csproj (#606); that is - redundant but harmless. A project that genuinely needs an exception should suppress the specific warning - via NoWarn, not turn this off. + build instead of accumulating. This is the ONLY place it is set: the per-project copies (#606) were removed + (#768), so do not add it back to a csproj. A project that genuinely needs an exception should suppress the + specific warning via NoWarn, not turn this off (only the throwaway tools/mem-probe probes opt out). --> net10.0 diff --git a/src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI/ZB.MOM.WW.OtOpcUa.Client.CLI.csproj b/src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI/ZB.MOM.WW.OtOpcUa.Client.CLI.csproj index 03aa382a..fa00ef1c 100644 --- a/src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI/ZB.MOM.WW.OtOpcUa.Client.CLI.csproj +++ b/src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI/ZB.MOM.WW.OtOpcUa.Client.CLI.csproj @@ -4,7 +4,6 @@ Exe net10.0 enable - true enable ZB.MOM.WW.OtOpcUa.Client.CLI diff --git a/src/Client/ZB.MOM.WW.OtOpcUa.Client.Shared/ZB.MOM.WW.OtOpcUa.Client.Shared.csproj b/src/Client/ZB.MOM.WW.OtOpcUa.Client.Shared/ZB.MOM.WW.OtOpcUa.Client.Shared.csproj index a2e8e203..4ad02026 100644 --- a/src/Client/ZB.MOM.WW.OtOpcUa.Client.Shared/ZB.MOM.WW.OtOpcUa.Client.Shared.csproj +++ b/src/Client/ZB.MOM.WW.OtOpcUa.Client.Shared/ZB.MOM.WW.OtOpcUa.Client.Shared.csproj @@ -3,7 +3,6 @@ net10.0 enable - true enable ZB.MOM.WW.OtOpcUa.Client.Shared diff --git a/src/Client/ZB.MOM.WW.OtOpcUa.Client.UI/ZB.MOM.WW.OtOpcUa.Client.UI.csproj b/src/Client/ZB.MOM.WW.OtOpcUa.Client.UI/ZB.MOM.WW.OtOpcUa.Client.UI.csproj index db6dcb97..5e5a5e0e 100644 --- a/src/Client/ZB.MOM.WW.OtOpcUa.Client.UI/ZB.MOM.WW.OtOpcUa.Client.UI.csproj +++ b/src/Client/ZB.MOM.WW.OtOpcUa.Client.UI/ZB.MOM.WW.OtOpcUa.Client.UI.csproj @@ -4,7 +4,6 @@ WinExe net10.0 enable - true enable ZB.MOM.WW.OtOpcUa.Client.UI diff --git a/src/Core/ZB.MOM.WW.OtOpcUa.Cluster/ZB.MOM.WW.OtOpcUa.Cluster.csproj b/src/Core/ZB.MOM.WW.OtOpcUa.Cluster/ZB.MOM.WW.OtOpcUa.Cluster.csproj index 2d45cdf5..33fd9f05 100644 --- a/src/Core/ZB.MOM.WW.OtOpcUa.Cluster/ZB.MOM.WW.OtOpcUa.Cluster.csproj +++ b/src/Core/ZB.MOM.WW.OtOpcUa.Cluster/ZB.MOM.WW.OtOpcUa.Cluster.csproj @@ -2,7 +2,6 @@ ZB.MOM.WW.OtOpcUa.Cluster - true diff --git a/src/Core/ZB.MOM.WW.OtOpcUa.Commons/ZB.MOM.WW.OtOpcUa.Commons.csproj b/src/Core/ZB.MOM.WW.OtOpcUa.Commons/ZB.MOM.WW.OtOpcUa.Commons.csproj index bd560b43..eb092910 100644 --- a/src/Core/ZB.MOM.WW.OtOpcUa.Commons/ZB.MOM.WW.OtOpcUa.Commons.csproj +++ b/src/Core/ZB.MOM.WW.OtOpcUa.Commons/ZB.MOM.WW.OtOpcUa.Commons.csproj @@ -2,7 +2,6 @@ ZB.MOM.WW.OtOpcUa.Commons - true diff --git a/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/ZB.MOM.WW.OtOpcUa.Configuration.csproj b/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/ZB.MOM.WW.OtOpcUa.Configuration.csproj index bb99850d..cea5ae4b 100644 --- a/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/ZB.MOM.WW.OtOpcUa.Configuration.csproj +++ b/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/ZB.MOM.WW.OtOpcUa.Configuration.csproj @@ -5,7 +5,6 @@ enable enable latest - true true diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbCip/ZB.MOM.WW.OtOpcUa.Driver.AbCip.csproj b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbCip/ZB.MOM.WW.OtOpcUa.Driver.AbCip.csproj index 9398a04a..19f90456 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbCip/ZB.MOM.WW.OtOpcUa.Driver.AbCip.csproj +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbCip/ZB.MOM.WW.OtOpcUa.Driver.AbCip.csproj @@ -5,7 +5,6 @@ enable enable latest - true true $(NoWarn);CS1591 ZB.MOM.WW.OtOpcUa.Driver.AbCip diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts.csproj b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts.csproj index 9dbcccee..e9e87216 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts.csproj +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts.csproj @@ -3,7 +3,6 @@ net10.0 enable enable - true diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/AbLegacyDriver.cs b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/AbLegacyDriver.cs index 9fdcddf9..c3743077 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/AbLegacyDriver.cs +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/AbLegacyDriver.cs @@ -217,7 +217,7 @@ public sealed partial class AbLegacyDriver : IDriver, IReadable, IWritable, ITag ?? throw new InvalidOperationException( $"AbLegacy device has invalid HostAddress '{device.HostAddress}' — expected 'ab://gateway[:port]/cip-path'."); var profile = AbLegacyPlcFamilyProfile.ForFamily(device.PlcFamily); - devices[device.HostAddress] = new DeviceState(addr, device, profile); + devices[device.HostAddress] = new DeviceState(addr, device, profile) { HostStateChangedUtc = Clock() }; } // Build the RawPath → definition table from the authored raw tags. Each entry's TagConfig // blob is mapped by the pure factory; the entry's WriteIdempotent flag is threaded onto the @@ -286,7 +286,7 @@ public sealed partial class AbLegacyDriver : IDriver, IReadable, IWritable, ITag state.ProbeTask = Task.Run(() => ProbeLoopAsync(state, probe, ct), ct); } } - _health = new DriverHealth(DriverState.Healthy, DateTime.UtcNow, null); + _health = new DriverHealth(DriverState.Healthy, Clock(), null); } } catch (Exception ex) @@ -451,9 +451,11 @@ public sealed partial class AbLegacyDriver : IDriver, IReadable, IWritable, ITag internal const int FaultsToMarkDeviceDown = 2; /// - /// The clock every per-device backoff decision reads (window open? when does it end?). Wall-clock UTC in - /// production; a test substitutes a manual clock so the window can be crossed deterministically rather than by - /// sleeping (review 07 r0 M7). + /// The clock every per-device backoff decision reads (window open? when does it end?) AND every health stamp + /// (LastSuccessfulRead at init / read / write, the read's sample timestamps, host-state change times). + /// Wall-clock UTC in production; a test substitutes a manual clock so a window can be crossed, or a stamp proven + /// to advance, deterministically rather than by sleeping or spinning (review 07 r0 M7, lmxopcua#768). Set it + /// before InitializeAsync for the init stamp to come from it. /// internal Func Clock { get; set; } = () => DateTime.UtcNow; @@ -508,7 +510,7 @@ public sealed partial class AbLegacyDriver : IDriver, IReadable, IWritable, ITag { ArgumentNullException.ThrowIfNull(fullReferences); var epoch = CurrentEpoch; - var now = DateTime.UtcNow; + var now = Clock(); var results = new DataValueSnapshot[fullReferences.Count]; var devices = _devices; // one snapshot of the published table for the whole call @@ -1080,7 +1082,7 @@ public sealed partial class AbLegacyDriver : IDriver, IReadable, IWritable, ITag } outcome.FoldOpaque(); - ApplyHealth(epoch, outcome.FaultMessage, anyGood: outcome.AnyAnswered, anyAnswered: outcome.AnyAnswered, DateTime.UtcNow); + ApplyHealth(epoch, outcome.FaultMessage, anyGood: outcome.AnyAnswered, anyAnswered: outcome.AnyAnswered, Clock()); return results; } @@ -1230,7 +1232,7 @@ public sealed partial class AbLegacyDriver : IDriver, IReadable, IWritable, ITag old = state.HostState; if (old == newState) return; state.HostState = newState; - state.HostStateChangedUtc = DateTime.UtcNow; + state.HostStateChangedUtc = Clock(); } if (newState == HostState.Stopped) _logger.LogWarning( diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.csproj b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.csproj index 2f7896cd..019681d7 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.csproj +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.csproj @@ -5,7 +5,6 @@ enable enable latest - true true $(NoWarn);CS1591 ZB.MOM.WW.OtOpcUa.Driver.AbLegacy diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts.csproj b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts.csproj index ad5239ba..ee3a9fe5 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts.csproj +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts.csproj @@ -4,7 +4,6 @@ net10.0 enable enable - true true $(NoWarn);CS1591 ZB.MOM.WW.OtOpcUa.Driver.Calculation diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/ZB.MOM.WW.OtOpcUa.Driver.Calculation.csproj b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/ZB.MOM.WW.OtOpcUa.Driver.Calculation.csproj index 0efbc7e0..ea2926ef 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/ZB.MOM.WW.OtOpcUa.Driver.Calculation.csproj +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/ZB.MOM.WW.OtOpcUa.Driver.Calculation.csproj @@ -5,7 +5,6 @@ enable enable latest - true true $(NoWarn);CS1591 ZB.MOM.WW.OtOpcUa.Driver.Calculation diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts.csproj b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts.csproj index 48b2f1bd..f37cc6bb 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts.csproj +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts.csproj @@ -3,7 +3,6 @@ net10.0 enable enable - true ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.csproj b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.csproj index d8e6892c..a93a9d07 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.csproj +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.csproj @@ -5,7 +5,6 @@ enable enable latest - true true $(NoWarn);CS1591 ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts.csproj b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts.csproj index 55d40545..fec44dec 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts.csproj +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts.csproj @@ -4,7 +4,6 @@ net10.0 enable enable - true diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.csproj b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.csproj index 5c41789a..1fae3113 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.csproj +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.csproj @@ -5,7 +5,6 @@ enable enable latest - true true $(NoWarn);CS1591 ZB.MOM.WW.OtOpcUa.Driver.TwinCAT diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/ZB.MOM.WW.OtOpcUa.AdminUI.csproj b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/ZB.MOM.WW.OtOpcUa.AdminUI.csproj index 5e79799d..9d241e92 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/ZB.MOM.WW.OtOpcUa.AdminUI.csproj +++ b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/ZB.MOM.WW.OtOpcUa.AdminUI.csproj @@ -3,7 +3,6 @@ ZB.MOM.WW.OtOpcUa.AdminUI true - true diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/ZB.MOM.WW.OtOpcUa.ControlPlane.csproj b/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/ZB.MOM.WW.OtOpcUa.ControlPlane.csproj index 36fedc39..a1b2f9ab 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/ZB.MOM.WW.OtOpcUa.ControlPlane.csproj +++ b/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/ZB.MOM.WW.OtOpcUa.ControlPlane.csproj @@ -2,7 +2,6 @@ ZB.MOM.WW.OtOpcUa.ControlPlane - true diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Host/ZB.MOM.WW.OtOpcUa.Host.csproj b/src/Server/ZB.MOM.WW.OtOpcUa.Host/ZB.MOM.WW.OtOpcUa.Host.csproj index c76e4184..34a25433 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Host/ZB.MOM.WW.OtOpcUa.Host.csproj +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Host/ZB.MOM.WW.OtOpcUa.Host.csproj @@ -4,7 +4,6 @@ ZB.MOM.WW.OtOpcUa.Host OtOpcUa.Host zb-mom-ww-otopcua-host - true netstandard2.0 enable - true latest false true diff --git a/tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests/ZB.MOM.WW.OtOpcUa.Cluster.Tests.csproj b/tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests/ZB.MOM.WW.OtOpcUa.Cluster.Tests.csproj index e1febe3f..a3761d95 100644 --- a/tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests/ZB.MOM.WW.OtOpcUa.Cluster.Tests.csproj +++ b/tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests/ZB.MOM.WW.OtOpcUa.Cluster.Tests.csproj @@ -4,7 +4,6 @@ false true ZB.MOM.WW.OtOpcUa.Cluster.Tests - true diff --git a/tests/Core/ZB.MOM.WW.OtOpcUa.Commons.Tests/ZB.MOM.WW.OtOpcUa.Commons.Tests.csproj b/tests/Core/ZB.MOM.WW.OtOpcUa.Commons.Tests/ZB.MOM.WW.OtOpcUa.Commons.Tests.csproj index f42dd463..27f4ec30 100644 --- a/tests/Core/ZB.MOM.WW.OtOpcUa.Commons.Tests/ZB.MOM.WW.OtOpcUa.Commons.Tests.csproj +++ b/tests/Core/ZB.MOM.WW.OtOpcUa.Commons.Tests/ZB.MOM.WW.OtOpcUa.Commons.Tests.csproj @@ -4,7 +4,6 @@ false true ZB.MOM.WW.OtOpcUa.Commons.Tests - true diff --git a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/NativePcccBridgeStatusHealthTests.cs b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/NativePcccBridgeStatusHealthTests.cs index ad39c4f9..84f14aa9 100644 --- a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/NativePcccBridgeStatusHealthTests.cs +++ b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/NativePcccBridgeStatusHealthTests.cs @@ -45,20 +45,17 @@ public sealed class NativePcccBridgeStatusHealthTests } /// - /// InitializeAsync stamps LastSuccessfulRead with DateTime.UtcNow and the read stamps its own - /// UtcNow microseconds later; on a coarse/identical clock reading the two are equal, so an "advanced" - /// assertion (ShouldNotBe(before)) failed ~70% of runs (lmxopcua#767). Spin until the clock has strictly - /// passed the init stamp so any later stamp is provably newer. The assertion itself is unchanged. + /// A manual clock the driver stamps health from (lmxopcua#768). Init stamps ; each test + /// moves it to before reading, so an "advanced" LastSuccessfulRead is provably + /// the read's stamp (it used to be DateTime.UtcNow twice microseconds apart, equal ~70% of runs on a + /// coarse clock, lmxopcua#767). /// - private static void WaitUntilClockPast(DateTime? stamp) - { - if (stamp is null) return; - var spin = new SpinWait(); - while (DateTime.UtcNow <= stamp.Value) spin.SpinOnce(); - } + private static readonly DateTime InitTime = new(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + private static readonly DateTime ReadTime = InitTime.AddSeconds(1); #pragma warning disable OTOPCUA0001 // the driver is called directly to pin its OWN classification (no resilience wrap) - private static async Task DriverAsync(FakeEipServer server) + private static async Task DriverAsync(FakeEipServer server, Func clock) { var host = $"ab://127.0.0.1:{server.Port}/1,0"; var driver = new AbLegacyDriver(new AbLegacyDriverOptions @@ -67,7 +64,10 @@ public sealed class NativePcccBridgeStatusHealthTests RawTags = AbLegacyRawTags.Entries([new AbLegacyTagDefinition("T", host, "N7:0", AbLegacyDataType.Int)]), Timeout = TimeSpan.FromSeconds(5), Probe = new AbLegacyProbeOptions { Enabled = false }, - }, "drv-pccc-bridge", new NativeAbLegacyTagFactory(new DeviceSessionPool())); + }, "drv-pccc-bridge", new NativeAbLegacyTagFactory(new DeviceSessionPool())) + { + Clock = clock, + }; await driver.InitializeAsync("{}", TestContext.Current.CancellationToken); return driver; } @@ -78,8 +78,11 @@ public sealed class NativePcccBridgeStatusHealthTests { var ct = TestContext.Current.CancellationToken; await using var server = StsServer(0x30); - var driver = await DriverAsync(server); + var now = InitTime; + var driver = await DriverAsync(server, () => now); var before = driver.GetHealth().LastSuccessfulRead; + before.ShouldBe(InitTime); + now = ReadTime; var result = (await driver.ReadAsync(["T"], ct)).Single(); @@ -97,17 +100,18 @@ public sealed class NativePcccBridgeStatusHealthTests { var ct = TestContext.Current.CancellationToken; await using var server = StsServer(0x60); - var driver = await DriverAsync(server); + var now = InitTime; + var driver = await DriverAsync(server, () => now); var before = driver.GetHealth().LastSuccessfulRead; - WaitUntilClockPast(before); + before.ShouldBe(InitTime); + now = ReadTime; var result = (await driver.ReadAsync(["T"], ct)).Single(); result.StatusCode.ShouldBe(AbOpcUaStatusMap.BadNotWritable); var health = driver.GetHealth(); health.State.ShouldBe(DriverState.Healthy); - health.LastSuccessfulRead.ShouldNotBeNull(); - health.LastSuccessfulRead.ShouldNotBe(before); + health.LastSuccessfulRead.ShouldBe(ReadTime); await driver.ShutdownAsync(ct); server.HandlerErrors.ShouldBeEmpty(); } @@ -128,17 +132,18 @@ public sealed class NativePcccBridgeStatusHealthTests { var ct = TestContext.Current.CancellationToken; await using var server = general == 0 ? StsServer(0x10) : CipEnvelopeServer(general); - var driver = await DriverAsync(server); + var now = InitTime; + var driver = await DriverAsync(server, () => now); var before = driver.GetHealth().LastSuccessfulRead; - WaitUntilClockPast(before); + before.ShouldBe(InitTime); + now = ReadTime; var result = (await driver.ReadAsync(["T"], ct)).Single(); result.StatusCode.ShouldBe(AbLegacyStatusMapper.BadNotSupported); var health = driver.GetHealth(); health.State.ShouldBe(DriverState.Healthy); - health.LastSuccessfulRead.ShouldNotBeNull(); - health.LastSuccessfulRead.ShouldNotBe(before); + health.LastSuccessfulRead.ShouldBe(ReadTime); await driver.ShutdownAsync(ct); server.HandlerErrors.ShouldBeEmpty(); } diff --git a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.IntegrationTests/SparkplugSimulator/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.SparkplugSimulator.csproj b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.IntegrationTests/SparkplugSimulator/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.SparkplugSimulator.csproj index fec0ea4e..79af14a0 100644 --- a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.IntegrationTests/SparkplugSimulator/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.SparkplugSimulator.csproj +++ b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.IntegrationTests/SparkplugSimulator/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.SparkplugSimulator.csproj @@ -27,7 +27,6 @@ enable enable latest - true true $(NoWarn);CS1591 false diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj index 69af045a..438e49fa 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj @@ -4,7 +4,6 @@ false true ZB.MOM.WW.OtOpcUa.AdminUI.Tests - true diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests.csproj b/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests.csproj index 3b55cf6c..1e6c1d35 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests.csproj +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests.csproj @@ -4,7 +4,6 @@ false true ZB.MOM.WW.OtOpcUa.ControlPlane.Tests - true diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests.csproj b/tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests.csproj index 64a02c31..3d330106 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests.csproj +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests.csproj @@ -4,7 +4,6 @@ false true ZB.MOM.WW.OtOpcUa.Host.IntegrationTests - true diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Host.Tests/ZB.MOM.WW.OtOpcUa.Host.Tests.csproj b/tests/Server/ZB.MOM.WW.OtOpcUa.Host.Tests/ZB.MOM.WW.OtOpcUa.Host.Tests.csproj index b4d6f70e..4d254b39 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Host.Tests/ZB.MOM.WW.OtOpcUa.Host.Tests.csproj +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Host.Tests/ZB.MOM.WW.OtOpcUa.Host.Tests.csproj @@ -4,7 +4,6 @@ false true ZB.MOM.WW.OtOpcUa.Host.Tests - true diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests.csproj b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests.csproj index 1a47a002..ba01033e 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests.csproj +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests.csproj @@ -4,7 +4,6 @@ false true ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests - true