From fded8054252e9b1136cc74023addc406a5cb165a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:04:26 +0000 Subject: [PATCH 1/2] Initial plan From c05deeee1fcc166d1c71fe545c97a698f6ec37e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:06:31 +0000 Subject: [PATCH 2/2] Fix Dispose(bool disposing) pattern in Tca955x: gate managed cleanup on disposing, forward disposing to base --- src/devices/Tca955x/Tca955x.cs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/devices/Tca955x/Tca955x.cs b/src/devices/Tca955x/Tca955x.cs index 53978f53ad..bf98169bb8 100644 --- a/src/devices/Tca955x/Tca955x.cs +++ b/src/devices/Tca955x/Tca955x.cs @@ -646,24 +646,27 @@ protected override bool IsPinModeSupported(int pinNumber, PinMode mode) => /// protected override void Dispose(bool disposing) { - _controller?.UnregisterCallbackForPinValueChangedEvent(_interrupt, InterruptHandler); - _interruptPending = false; + if (disposing) + { + _controller?.UnregisterCallbackForPinValueChangedEvent(_interrupt, InterruptHandler); + _interruptPending = false; - // Make a copy of the task refernce to avoid a race condition - // between checking it for null and then waiting on it. - var localinterruptProcessingTask = _interruptProcessingTask; - localinterruptProcessingTask?.Wait(); + // Make a copy of the task reference to avoid a race condition + // between checking it for null and then waiting on it. + var localinterruptProcessingTask = _interruptProcessingTask; + localinterruptProcessingTask?.Wait(); - if (_shouldDispose) - { - _controller?.Dispose(); - } + if (_shouldDispose) + { + _controller?.Dispose(); + } - _controller = null; + _controller = null; - _busDevice?.Dispose(); + _busDevice?.Dispose(); + } - base.Dispose(true); + base.Dispose(disposing); } }