Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 19, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original issue description:

Background and motivation

As described by dotnet#32760 (comment), the constructor

public NamedPipeClientStream(System.IO.Pipes.PipeDirection direction, bool isAsync, bool isConnected, Microsoft.Win32.SafeHandles.SafePipeHandle safePipeHandle)

Using isConnected: false is invalid, it will throw an exception when Connect is called because it requires a path to establish the connection. We should discourage the use of this ctor and instead suggest using a new ctor that doesn't take bool isConnected.

To preserve compatibility in the existing ctor, I think we should ignore isConnected rather than throwing.

Related:
dotnet#32760
dotnet#83073

API Proposal

namespace System.IO.Pipes;

public sealed partial class NamedPipeClientStream : PipeStream
{
+   [EditorBrowsable(EditorBrowsableState.Never)]
+   [Obsolete("This constructor has been deprecated and argument bool isConnected does not have any effect. Use NamedPipeClientStream(PipeDirection direction, bool isAsync, SafePipeHandle safePipeHandle) instead.")]
    public NamedPipeClientStream(PipeDirection direction, bool isAsync, bool isConnected, SafePipeHandle safePipeHandle) : base (default(PipeDirection), default(int)) { }

+   public NamedPipeClientStream(PipeDirection direction, bool isAsync, SafePipeHandle safePipeHandle) : base(default(PipeDirection), default(int)) { }
}

Alternative Designs

None that I can think of, but I considered fixing the issue by using the provided handle to reconnect to the named pipe server. That doesn't seem feasible, A client Connects by obtaining a handle (via CreateFile in Windows and via Socket.Connect on Unix). reconnecting would imply discarding the existing handle.

Risks

No response

Fixes #5.


💡 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.

Copilot finished work on behalf of jozkee September 19, 2025 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: Hide NamedPipeClientStream ctor with isConnected argument
2 participants