Add ShouldDispose property to StreamFile for optional direct stream access#103
Add ShouldDispose property to StreamFile for optional direct stream access#103Arlodotexe merged 6 commits intomainfrom
Conversation
|
@Arlodotexe 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: Arlodotexe <9384894+Arlodotexe@users.noreply.github.com>
Co-authored-by: Arlodotexe <9384894+Arlodotexe@users.noreply.github.com>
ShouldDispose property
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Arlodotexe <9384894+Arlodotexe@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Arlodotexe
left a comment
There was a problem hiding this comment.
@copilot The new property should be a getter/setter, shouldn't clutter the constructor parameters.
…or parameter Co-authored-by: Arlodotexe <9384894+Arlodotexe@users.noreply.github.com>
The ShouldDispose property has been added to StreamFile as requested. It's now a settable property (get/set) that controls whether the underlying stream is disposed when the returned stream is disposed. Commit 6edbb45.
Changed ShouldDispose to be a simple get/set property and removed the constructor parameter overloads to avoid cluttering the constructor. The property defaults to false for backward compatibility. Commit 6edbb45. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This PR adds a
ShouldDisposeproperty to theStreamFileclass to enable optional direct stream access with dispose behavior intact, addressing scenarios where single-use stream access is preferred over the default multi-use behavior.Background
Previously,
StreamFilealways wrapped the underlying stream in aNonDisposableStreamWrapper, which is ideal for most use cases where the file might be opened multiple times. However, some scenarios require returning the underlying stream directly with dispose behavior intact, even if that means the file can only be opened once.Changes
ShouldDisposeproperty: A boolean get/set property that controls whether the underlying stream is returned directly or wrappedshouldDisposeparameter to avoid clutteringOpenStreamAsynclogic: Conditionally wraps the stream based on theShouldDisposevalueUsage
Backward Compatibility
All existing code continues to work unchanged. The default value of
ShouldDisposeisfalse, preserving the original behavior of wrapping streams inNonDisposableStreamWrapper.Fixes #102.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.