Enable netfx UI MCP clients (#1639)
This commit is contained in:
parent
8ddb3cc36f
commit
9ba1f47d77
1 changed files with 17 additions and 2 deletions
|
|
@ -187,14 +187,29 @@ public sealed partial class StdioClientTransport : IClientTransport
|
||||||
lock (s_consoleEncodingLock)
|
lock (s_consoleEncodingLock)
|
||||||
{
|
{
|
||||||
Encoding originalInputEncoding = Console.InputEncoding;
|
Encoding originalInputEncoding = Console.InputEncoding;
|
||||||
|
bool encodingChanged = false;
|
||||||
try
|
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();
|
processStarted = process.Start();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Console.InputEncoding = originalInputEncoding;
|
if (encodingChanged)
|
||||||
|
{
|
||||||
|
Console.InputEncoding = originalInputEncoding;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue