Background and motivation
Since we've introduced some new APIs for Process
wondering that maybe we could also add static methods Process.RunAndCaptureLinesAsync likes Process.RunAndCaptureTextAsync to simplify the read process output lines as a stream
API Proposal
namespace System.Diagnostics;
public class Process
{
public static IAsyncEnumerable<ProcessOutputLine> RunAndCaptureLinesAsync(string fileName, IList<string>? arguments = null, CancellationToken cancellationToken = default);
public static IAsyncEnumerable<ProcessOutputLine> RunAndCaptureLinesAsync(ProcessStartInfo startInfo, CancellationToken cancellationToken = default);
}
API Usage
await foreach (var line in Process.RunAndCaptureLinesAsync("dotnet", ["--info"]))
{
ConsoleHelper.WriteLineWithColor(line.Content, line.StandardError ? ConsoleColor.Red : ConsoleColor.Green);
}
Alternative Designs
No response
Risks
No response
Background and motivation
Since we've introduced some new APIs for Process
wondering that maybe we could also add static methods
Process.RunAndCaptureLinesAsynclikesProcess.RunAndCaptureTextAsyncto simplify the read process output lines as a streamAPI Proposal
API Usage
Alternative Designs
No response
Risks
No response