Implement IDisposable on stream readers/writers#233
Merged
MaxHeimbrock merged 2 commits intomainfrom Apr 10, 2026
Merged
Conversation
… streams TextStreamReader, ByteStreamReader, TextStreamWriter, and ByteStreamWriter now implement IDisposable to properly release their native FFI handles. Public methods throw ObjectDisposedException after disposal. Room.cs now disposes stream readers when no handler is registered for their topic, fixing the native handle leak noted in the TODOs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
TextStreamReader,ByteStreamReader,TextStreamWriter, andByteStreamWriterhold native FFI handles but never implementIDisposable. If a stream is abandoned without completing (e.g., no handler registered, or user drops the object mid-stream), the native handle leaks. This also resolves the TODO comments in Room.cs about disposing unhandled stream readers.Changes
IDisposableto all four stream reader/writer classes inDataStream.csObjectDisposedExceptionguards to all public methods (ReadAll,ReadIncremental,WriteToFile,Write,Close)Room.cswhen no handler is registered for the stream's topic🤖 Generated with Claude Code