From 3c56b3df5dc2ff0f493ff9e92a191dcd37fde4f6 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Thu, 1 Jan 2026 17:48:15 +0000 Subject: [PATCH] fix: Remove unnecessary finalizer from ModuleOutputWriter (#1533) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove finalizer since class only manages managed resources - Fix bug where _scope was not disposed when buffer had no events - Remove GC.SuppressFinalize since no finalizer exists - Add documentation explaining why finalizer is not needed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/ModularPipelines/Logging/ModuleOutputWriter.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ModularPipelines/Logging/ModuleOutputWriter.cs b/src/ModularPipelines/Logging/ModuleOutputWriter.cs index d881b5768d..5a3a658126 100644 --- a/src/ModularPipelines/Logging/ModuleOutputWriter.cs +++ b/src/ModularPipelines/Logging/ModuleOutputWriter.cs @@ -119,6 +119,10 @@ internal void SetException(Exception exception) /// /// Flushes all buffered output with section header/footer. /// + /// + /// No finalizer is needed since this class only manages managed resources. + /// If Dispose is not called, the IServiceScope will be cleaned up by GC. + /// public void Dispose() { lock (_writeLock) @@ -133,6 +137,7 @@ public void Dispose() if (!_buffer.HasEvents) { + _scope.Dispose(); return; } @@ -173,12 +178,6 @@ public void Dispose() } _scope.Dispose(); - GC.SuppressFinalize(this); - } - - ~ModuleOutputWriter() - { - Dispose(); } ///