Enable netfx UI MCP clients (#1639)

This commit is contained in:
Kirill Osenkov 2026-06-22 16:52:47 -07:00 • committed by GitHub
commit 9ba1f47d77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -187,14 +187,29 @@ public sealed partial class StdioClientTransport : IClientTransport
lock (s_consoleEncodingLock)
{
Encoding originalInputEncoding = Console.InputEncoding;
bool encodingChanged = false;
try
{
Console.InputEncoding = StreamClientSessionTransport.NoBomUtf8Encoding;
try
{
Console.InputEncoding = StreamClientSessionTransport.NoBomUtf8Encoding;
encodingChanged = true;
}
catch
{
// Host has no usable console (e.g. WPF/WinForms on .NET Framework with no
// AllocConsole). The child inherits the current Console.InputEncoding;
// non-ASCII stdin may be misencoded, but the connect itself proceeds.
}
processStarted = process.Start();
}
finally
{
Console.InputEncoding = originalInputEncoding;
if (encodingChanged)
{
Console.InputEncoding = originalInputEncoding;
}
}
}
#endif