Skip to content

Commit 89b8185

Browse files
committed
Progress
1 parent 1df61d1 commit 89b8185

16 files changed

+355
-4
lines changed

src/Cli/dotnet/Commands/CliCommandStrings.resx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2648,4 +2648,19 @@ Proceed?</value>
26482648
<data name="CmdMinimumExpectedTestsDescription" xml:space="preserve">
26492649
<value>Specifies the minimum number of tests that are expected to run.</value>
26502650
</data>
2651-
</root>
2651+
<data name="DotnetTestPipeOverlapping" xml:space="preserve">
2652+
<value>'dotnet' unexpectedly received overlapping messages from the 'dotnet test' named pipe.</value>
2653+
</data>
2654+
<data name="DotnetTestPipeIncompleteSize" xml:space="preserve">
2655+
<value>'dotnet' unexpectedly received less than 4 bytes from the 'dotnet test' named pipe.</value>
2656+
</data>
2657+
<data name="InternalLoopAsyncDidNotExitSuccessfullyErrorMessage" xml:space="preserve">
2658+
<value>Method '{0}' did not exit successfully</value>
2659+
</data>
2660+
<data name="DotnetTestPipeFailureHasHandshake" xml:space="preserve">
2661+
<value>Error disposing 'NamedPipeServer' corresponding to handshake:</value>
2662+
</data>
2663+
<data name="DotnetTestPipeFailureWithoutHandshake" xml:space="preserve">
2664+
<value>Error disposing 'NamedPipeServer', and no handshake was found.</value>
2665+
</data>
2666+
</root>

src/Cli/dotnet/Commands/Test/IPC/NamedPipeServer.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#nullable disable
55

66
using System.Buffers;
7+
using System.Diagnostics;
78
using System.Globalization;
89
using System.IO.Pipes;
910

@@ -86,6 +87,11 @@ private async Task InternalLoopAsync(CancellationToken cancellationToken)
8687
if (currentMessageSize == 0)
8788
{
8889
// We need to read the message size, first 4 bytes
90+
if (currentReadBytes < sizeof(int))
91+
{
92+
throw new UnreachableException("");
93+
}
94+
8995
currentMessageSize = BitConverter.ToInt32(_readBuffer, 0);
9096
missingBytesToReadOfCurrentChunk = currentReadBytes - sizeof(int);
9197
missingBytesToReadOfWholeMessage = currentMessageSize;
@@ -99,6 +105,11 @@ private async Task InternalLoopAsync(CancellationToken cancellationToken)
99105
missingBytesToReadOfWholeMessage -= missingBytesToReadOfCurrentChunk;
100106
}
101107

108+
if (missingBytesToReadOfWholeMessage < 0)
109+
{
110+
throw new UnreachableException(CliCommandStrings.DotnetTestPipeOverlapping);
111+
}
112+
102113
// If we have read all the message, we can deserialize it
103114
if (missingBytesToReadOfWholeMessage == 0)
104115
{
@@ -207,7 +218,7 @@ public void Dispose()
207218
// To close gracefully we need to ensure that the client closed the stream line 103.
208219
if (!_loopTask.Wait(TimeSpan.FromSeconds(90)))
209220
{
210-
throw new InvalidOperationException("InternalLoopAsyncDidNotExitSuccessfullyErrorMessage");
221+
throw new InvalidOperationException(CliCommandStrings.InternalLoopAsyncDidNotExitSuccessfullyErrorMessage);
211222
}
212223
}
213224
}

src/Cli/dotnet/Commands/Test/TestApplication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public void Dispose()
393393
StringBuilder messageBuilder;
394394
if (_handshakes.TryGetValue(namedPipeServer, out var handshake))
395395
{
396-
messageBuilder = new StringBuilder("Error disposing NamedPipeServer corresponding to handshake:");
396+
messageBuilder = new StringBuilder(CliCommandStrings.DotnetTestPipeFailureWithoutHandshake);
397397
messageBuilder.AppendLine();
398398
foreach (var kvp in handshake.Properties)
399399
{
@@ -402,7 +402,7 @@ public void Dispose()
402402
}
403403
else
404404
{
405-
messageBuilder = new StringBuilder("Error disposing NamedPipeServer, and no handshake was found.");
405+
messageBuilder = new StringBuilder(CliCommandStrings.DotnetTestPipeFailureWithoutHandshake);
406406
messageBuilder.AppendLine();
407407
}
408408

src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)