You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With these, we can simplify our file-based apps dev.cs.
Detail
.NET 11 ships new one-shot Process APIs that make launching a process + waiting + capturing output a single deadlock-free call, so the hand-rolled process plumbing in dev.cs can be deleted and replaced with them.
The relevant .NET 11 APIs
New static methods on System.Diagnostics.Process (from the devblog):
Process.Run / Process.RunAsync — start, wait for exit, return a ProcessExitStatus (with ExitCode, Canceled, Signal). No output capture.
Process.RunAndCaptureText / …Async — same, but returns ProcessTextOutput with StandardOutput / StandardError captured together via multiplexing (no manual stream-draining, no deadlock risk).
Changes in dev.cs
dev.cs is a Cocona file-based CLI with two private helpers doing exactly what these APIs replace:
IsCommandAvailableAsync — runs which/where.exe, manually drains both streams with Task.WhenAll to avoid deadlock, checks exit code
Process.RunAsync(...) (output is discarded anyway) or RunAndCaptureTextAsync if it wants the path
The manual stream-draining Task.WhenAll(ReadToEndAsync, ReadToEndAsync, WaitForExitAsync) in IsCommandAvailableAsync (dev.cs:198-201) is a footgun the new API is designed to eliminate.
Caveats worth flagging back to him
Caution
These are .NET 11 preview APIs - likely need to do this in version sentry-dotnet v7
Summary
.NET 11 adds new
ProcessAPIs, that enables "the pit of success" for one-shot Process invocations:With these, we can simplify our file-based apps
dev.cs.Detail
.NET 11 ships new one-shot
ProcessAPIs that make launching a process + waiting + capturing output a single deadlock-free call, so the hand-rolled process plumbing in dev.cs can be deleted and replaced with them.The relevant .NET 11 APIs
New static methods on
System.Diagnostics.Process(from the devblog):Process.Run/Process.RunAsync— start, wait for exit, return aProcessExitStatus(withExitCode,Canceled,Signal). No output capture.Process.RunAndCaptureText/…Async— same, but returnsProcessTextOutputwithStandardOutput/StandardErrorcaptured together via multiplexing (no manual stream-draining, no deadlock risk).Changes in
dev.csdev.csis a Cocona file-based CLI with two private helpers doing exactly what these APIs replace:RunProcessAsync— buildsProcessStartInfo,Start(),try/catch,WaitForExitAsync(), returnsExitCodeProcess.RunAsync(fileName, args)→.ExitStatus.ExitCodeIsCommandAvailableAsync— runswhich/where.exe, manually drains both streams withTask.WhenAllto avoid deadlock, checks exit codeProcess.RunAsync(...)(output is discarded anyway) orRunAndCaptureTextAsyncif it wants the pathThe manual stream-draining
Task.WhenAll(ReadToEndAsync, ReadToEndAsync, WaitForExitAsync)inIsCommandAvailableAsync(dev.cs:198-201) is a footgun the new API is designed to eliminate.Caveats worth flagging back to him
Caution
These are .NET 11 preview APIs - likely need to do this in version sentry-dotnet v7