Update CLI Output Polling to Task.Run#62
Conversation
Replaced event-based OutputDataReceived and ErrorDataReceived with Task.Run polling of StandardOutput and StandardError streams in RunDotnetAsync. This change improves stability as reported by the user. - Increased capturedStdout capacity to 4096. - Used AppendLine to preserve line structure in captured output. - Ensured all output is drained by awaiting polling tasks after process exit. - Preserved existing colorization and logging logic.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Implemented a more stable output capturing mechanism using a shared `PollStreamReader` helper and a custom `Logger` class, as requested. - Added `PollStreamReader` to handle `StreamReader` polling in background tasks. - Introduced a `Logger` class to encapsulate real-time logging logic. - Updated `RunDotnetAsync` to use these helpers, ensuring both stdout and stderr are correctly drained and processed. - Maintained existing colorization, error counting, and failure reporting functionality. - Addressed C# top-level statement constraints by properly placing type and method declarations.
There was a problem hiding this comment.
Pull request overview
This PR updates the FUnit CLI’s dotnet process output handling to improve reliability by polling StandardOutput/StandardError concurrently via Task.Run, rather than relying on Process.OutputDataReceived/ErrorDataReceived events.
Changes:
- Replaced event-based output capture with concurrent stream polling tasks for stdout/stderr.
- Ensured stream polling tasks are awaited after
WaitForExitAsync()to fully drain output. - Increased the initial
StringBuildercapacity for captured output to 4096 characters.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| proc.BeginOutputReadLine(); | ||
| var tasks = new List<Task>(); | ||
|
|
||
| var defaultLogger = new Logger(line => Console.Out.WriteLine(Colorize(line))); |
| Console.Error.WriteLine(Colorize(line)); // DO NOT use ConsoleLogger here! | ||
| }); | ||
|
|
||
| var capturedStdout = PollStreamReader(proc.StandardOutput, stdoutLogger ?? defaultLogger, tasks); |
| static StringBuilder PollStreamReader(StreamReader stream, Logger? logger, List<Task> tasks) | ||
| { | ||
| var sb = new StringBuilder(capacity: 4096); | ||
| var task = Task.Run( | ||
| () => | ||
| { | ||
| string? line; | ||
| while ((line = stream.ReadLine()) != null) | ||
| { | ||
| sb.AppendLine(line); | ||
| logger?.Debug(line); |
The FUnit CLI was updated to use a more stable output capturing mechanism. Instead of relying on the
Process.OutputDataReceivedandProcess.ErrorDataReceivedevents, which can be unstable, the tool now usesTask.Runto concurrently poll the standard output and error streams of thedotnetprocess. This ensures that all output is reliably captured and logged in real-time, while also improving the robustness of the log capture for diagnostic purposes in case of build or test failures. Additionally, the internal buffer capacity for captured output was increased to 4096 characters.PR created automatically by Jules for task 11974610101210898048 started by @sator-imaging