Skip to content

Commit 1f44eb7

Browse files
thomhurstclaude
andauthored
fix: Remove unnecessary finalizer from ModuleOutputWriter (#1533) (#1727)
- 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 <noreply@anthropic.com>
1 parent 0a60523 commit 1f44eb7

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/ModularPipelines/Logging/ModuleOutputWriter.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ internal void SetException(Exception exception)
119119
/// <summary>
120120
/// Flushes all buffered output with section header/footer.
121121
/// </summary>
122+
/// <remarks>
123+
/// No finalizer is needed since this class only manages managed resources.
124+
/// If Dispose is not called, the IServiceScope will be cleaned up by GC.
125+
/// </remarks>
122126
public void Dispose()
123127
{
124128
lock (_writeLock)
@@ -133,6 +137,7 @@ public void Dispose()
133137

134138
if (!_buffer.HasEvents)
135139
{
140+
_scope.Dispose();
136141
return;
137142
}
138143

@@ -173,12 +178,6 @@ public void Dispose()
173178
}
174179

175180
_scope.Dispose();
176-
GC.SuppressFinalize(this);
177-
}
178-
179-
~ModuleOutputWriter()
180-
{
181-
Dispose();
182181
}
183182

184183
/// <summary>

0 commit comments

Comments
 (0)