Address PR comments (#4255)

This commit is contained in:
westey
2026-02-25 14:54:27 +00:00
committed by GitHub
Unverified
parent 17f75c325e
commit d4f95798c2
2 changed files with 14 additions and 4 deletions
@@ -832,12 +832,17 @@ public sealed class ConsoleAppSamplesValidation(ITestOutputHelper outputHelper)
using Process buildProcess = new() { StartInfo = buildInfo };
buildProcess.Start();
// Read both streams asynchronously to avoid deadlocks from filled pipe buffers
Task<string> stdoutTask = buildProcess.StandardOutput.ReadToEndAsync();
Task<string> stderrTask = buildProcess.StandardError.ReadToEndAsync();
await buildProcess.WaitForExitAsync();
string stderr = await stderrTask;
if (buildProcess.ExitCode != 0)
{
string stderr = await buildProcess.StandardError.ReadToEndAsync();
throw new InvalidOperationException($"Failed to build sample at {samplePath}: {stderr}");
string stdout = await stdoutTask;
throw new InvalidOperationException($"Failed to build sample at {samplePath}:\n{stdout}\n{stderr}");
}
this._outputHelper.WriteLine($"Build completed for {samplePath}.");
@@ -830,12 +830,17 @@ public sealed class SamplesValidation(ITestOutputHelper outputHelper) : IAsyncLi
using Process buildProcess = new() { StartInfo = buildInfo };
buildProcess.Start();
// Read both streams asynchronously to avoid deadlocks from filled pipe buffers
Task<string> stdoutTask = buildProcess.StandardOutput.ReadToEndAsync();
Task<string> stderrTask = buildProcess.StandardError.ReadToEndAsync();
await buildProcess.WaitForExitAsync();
string stderr = await stderrTask;
if (buildProcess.ExitCode != 0)
{
string stderr = await buildProcess.StandardError.ReadToEndAsync();
throw new InvalidOperationException($"Failed to build sample at {samplePath}: {stderr}");
string stdout = await stdoutTask;
throw new InvalidOperationException($"Failed to build sample at {samplePath}:\n{stdout}\n{stderr}");
}
this._outputHelper.WriteLine($"Build completed for {samplePath}.");