Elevation follow-ups: fix overload ambiguity, tests, README, CA2025#8
Merged
Conversation
- Fix overload-resolution ambiguity in ExecuteAsync(string): new() was ambiguous between OutputHandler and Elevation, so qualify it as new OutputHandler(). - Inline Task.WhenAll over outputReader.Start() and process.WaitForExitAsync() to clear CA2025 (tasks using IDisposable instances must complete before disposal). - Add tests for the new Elevation overloads, skipping Elevated on Windows to avoid blocking on a UAC prompt. - Document the Elevation enum and its Windows-only behavior in the README, including the output-capture caveat.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-ups to #7 (elevation support):
ExecuteAsync(string)calledExecuteAsync(command, new()), which is ambiguous betweenExecuteAsync(string, OutputHandler)andExecuteAsync(string, Elevation)sincenew()can target-type to either. Qualified asnew OutputHandler().Task.WhenAll(outputReader.Start(), process.WaitForExitAsync())so the analyzer can see all tasks using theProcessare awaited before itsusingdisposes it.Execute/ExecuteAsyncwithElevation.DefaultandElevation.Elevated. TheElevatedcases areAssert.Inconclusiveon Windows to avoid blocking CI on a UAC prompt; on Linux/macOS they exercise the documented no-op path.Elevationenum values plus the output-capture caveat.Test plan
dotnet teston Linux and the new elevation tests pass.RunCommand.Execute("whoami /groups", Elevation.Elevated)produces a UAC prompt and exits 0.Elevation.Elevated+ anOutputHandler, confirm the handler is not invoked (documented behavior).Generated by Claude Code