From 1d5fa8230e71a3754d630fba0c25ec1377b5bfc9 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 26 Jun 2026 16:54:23 -0400 Subject: [PATCH] fix(historian-gateway): Dispose() delegates to DisposeAsync() + sync-dispose test Addresses T7/T8/T11 code-review minors: route the sync dispose through DisposeAsync so a double Dispose()+DisposeAsync() stays a no-op; cover the sync path. Claude-Session: https://claude.ai/code/session_012SDSQ3AcaXqPcBtDESBRii --- .../GatewayHistorianDataSource.cs | 4 ++-- .../GatewayHistorianDataSourceTests.cs | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway/GatewayHistorianDataSource.cs b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway/GatewayHistorianDataSource.cs index e263ae36..5a85ef63 100644 --- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway/GatewayHistorianDataSource.cs +++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway/GatewayHistorianDataSource.cs @@ -335,8 +335,8 @@ public sealed class GatewayHistorianDataSource : IHistorianDataSource, IAsyncDis } } - /// Disposes the underlying gateway client. - public void Dispose() => _client.DisposeAsync().AsTask().GetAwaiter().GetResult(); + /// Disposes the underlying gateway client. Prefer . + public void Dispose() => DisposeAsync().AsTask().GetAwaiter().GetResult(); /// Asynchronously disposes the underlying gateway client. /// A task that completes when the client has been disposed. diff --git a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests/GatewayHistorianDataSourceTests.cs b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests/GatewayHistorianDataSourceTests.cs index 0e7abcbd..423d9b03 100644 --- a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests/GatewayHistorianDataSourceTests.cs +++ b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests/GatewayHistorianDataSourceTests.cs @@ -69,6 +69,15 @@ public sealed class GatewayHistorianDataSourceTests Assert.Equal(1, fake.DisposeCallCount); } + [Fact] + public void Dispose_via_sync_path_disposes_client() + { + var fake = new FakeHistorianGatewayClient(); + var ds = new GatewayHistorianDataSource(fake, NullLogger.Instance); + ((IDisposable)ds).Dispose(); + Assert.Equal(1, fake.DisposeCallCount); + } + // Ts(...) builds a Google.Protobuf.WellKnownTypes.Timestamp from UTC parts. private static Timestamp Ts(int y, int mo, int d, int h, int mi, int s) => Timestamp.FromDateTime(new DateTime(y, mo, d, h, mi, s, DateTimeKind.Utc));