Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.

Commit d98cff2

Browse files
Use UTF8 a default encoding
1 parent 0c3d72b commit d98cff2

4 files changed

Lines changed: 19 additions & 30 deletions

File tree

CSharpInteractive/BuildContext.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ private IEnumerable<BuildMessage> OnTestFinished(IServiceMessage message)
8383
{
8484
duration = TimeSpan.FromMilliseconds(durationMs);
8585
}
86-
8786

8887
_tests.Add(BuildMessage.CreateResult(testKey, message, TestState.Finished).WithDuration(duration).WithOutput(ctx.Output));
8988
}
@@ -191,23 +190,26 @@ private static BuildMessage CreateMessage(IServiceMessage message, BuildMessageS
191190

192191
private TestContext GetTestContext(BuildMessage.TestKey testKey, bool remove = false)
193192
{
194-
if (!_currentTests.TryGetValue(testKey, out var testContext))
193+
lock (_currentTests)
195194
{
196-
testContext = new TestContext();
197-
if (!remove)
195+
if (!_currentTests.TryGetValue(testKey, out var testContext))
198196
{
199-
_currentTests.Add(testKey, testContext);
197+
testContext = new TestContext();
198+
if (!remove)
199+
{
200+
_currentTests.Add(testKey, testContext);
201+
}
200202
}
201-
}
202-
else
203-
{
204-
if (remove)
203+
else
205204
{
206-
_currentTests.Remove(testKey);
205+
if (remove)
206+
{
207+
_currentTests.Remove(testKey);
208+
}
207209
}
210+
211+
return testContext;
208212
}
209-
210-
return testContext;
211213
}
212214

213215
private class TestContext

CSharpInteractive/ProcessRunner.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public ProcessResult Run(ProcessInfo processInfo, TimeSpan timeout)
1717
}
1818

1919
var finished = processManager.WaitForExit(timeout);
20-
2120
return process.Finish(finished);
2221
}
2322

CSharpInteractive/StartInfoFactory.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace CSharpInteractive;
33

44
using System.Diagnostics;
5+
using System.Text;
56
using HostApi;
67

78
internal class StartInfoFactory(
@@ -27,7 +28,9 @@ public ProcessStartInfo Create(IStartInfo info)
2728
UseShellExecute = false,
2829
CreateNoWindow = true,
2930
RedirectStandardOutput = true,
30-
RedirectStandardError = true
31+
RedirectStandardError = true,
32+
StandardErrorEncoding = Encoding.UTF8,
33+
StandardOutputEncoding = Encoding.UTF8
3134
};
3235

3336
log.Trace(() => [new Text($"File name: \"{startInfo.FileName}\".")], description);

Samples/MySampleLib/Build/Program.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,7 @@
2323
.WithShortName("Tests")
2424
.WithNoBuild(true)
2525
.WithConfiguration(configuration)
26-
.Build(i =>
27-
{
28-
if (i.TestResult is { } testResult)
29-
{
30-
switch (testResult.State)
31-
{
32-
case TestState.Failed:
33-
Error($"{testResult.FullyQualifiedName}: {testResult.State}");
34-
break;
35-
36-
case TestState.Ignored:
37-
Warning($"{testResult.FullyQualifiedName}: {testResult.State}");
38-
break;
39-
}
40-
}
41-
});
26+
.Build();
4227

4328
if (testResult.ExitCode != 0)
4429
{

0 commit comments

Comments
 (0)