Skip to content

Commit e7ff4ce

Browse files
authored
Use Utf8 not just for witing to standard output, but also for reading from standard input (#1735)
1 parent 9e7e507 commit e7ff4ce

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

src/BenchmarkDotNet/Engines/ConsoleHost.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace BenchmarkDotNet.Engines
88
public sealed class ConsoleHost : IHost
99
{
1010
private readonly TextWriter outWriter;
11-
private readonly TextReader inReader;
11+
private readonly StreamReader inReader;
1212

13-
public ConsoleHost([NotNull]TextWriter outWriter, [NotNull]TextReader inReader)
13+
public ConsoleHost([NotNull]TextWriter outWriter, [NotNull]StreamReader inReader)
1414
{
1515
this.outWriter = outWriter ?? throw new ArgumentNullException(nameof(outWriter));
1616
this.inReader = inReader ?? throw new ArgumentNullException(nameof(inReader));

src/BenchmarkDotNet/Templates/BenchmarkProgram.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace BenchmarkDotNet.Autogenerated
2727
#if WASM
2828
BenchmarkDotNet.Engines.NoAcknowledgementConsoleHost host = new BenchmarkDotNet.Engines.NoAcknowledgementConsoleHost(System.Console.Out); // this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
2929
#else
30-
BenchmarkDotNet.Engines.ConsoleHost host = new BenchmarkDotNet.Engines.ConsoleHost(System.Console.Out, System.Console.In); // this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
30+
BenchmarkDotNet.Engines.ConsoleHost host = new BenchmarkDotNet.Engines.ConsoleHost(System.Console.Out, new System.IO.StreamReader(System.Console.OpenStandardInput(), System.Text.Encoding.UTF8)); // this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
3131
#endif
3232

3333
// the first thing to do is to let diagnosers hook in before anything happens

src/BenchmarkDotNet/Toolchains/Executor.cs

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ private ProcessStartInfo CreateStartInfo(BenchmarkCase benchmarkCase, ArtifactsP
9191
RedirectStandardInput = true,
9292
RedirectStandardError = false, // #1629
9393
CreateNoWindow = true,
94+
StandardOutputEncoding = Encoding.UTF8, // #1713
9495
WorkingDirectory = null // by default it's null
9596
};
9697

tests/BenchmarkDotNet.Tests/Engine/EngineFactoryTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private EngineParameters CreateEngineParameters(Action<long> mainNoUnroll, Actio
247247
Dummy3Action = () => { },
248248
GlobalSetupAction = GlobalSetup,
249249
GlobalCleanupAction = GlobalCleanup,
250-
Host = new ConsoleHost(TextWriter.Null, TextReader.Null),
250+
Host = new ConsoleHost(TextWriter.Null, StreamReader.Null),
251251
OverheadActionUnroll = OverheadUnroll,
252252
OverheadActionNoUnroll = OverheadNoUnroll,
253253
IterationCleanupAction = IterationCleanup,

0 commit comments

Comments
 (0)