Fix overload ambiguity breaking main build#9
Merged
Conversation
The Execute(string, OutputHandler) and Execute(string, Elevation) overloads cause target-typed new() in test calls to be ambiguous on the .NET 10 SDK used by CI. Qualify the constructions as new OutputHandler(...) to bind the correct overload. This also affected the new Elevation tests I added in PR #8 — they compiled in this environment but failed on the Windows runner, which caused the post-merge main build to break.
|
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
Fixes the main build failure at https://github.com/ktsu-dev/RunCommand/actions/runs/25781929427.
The new
Execute(string, Elevation)andExecuteAsync(string, Elevation)overloads added in #7/#8 made target-typednew()ambiguous withExecute(string, OutputHandler)andExecuteAsync(string, OutputHandler)— the compiler considers both candidate parameter types before constructor binding, so even thoughElevationis an enum with no matching constructor, the call site is still ambiguous. Six existing test calls and (embarrassingly) the two new elevation tests I added all relied onnew(...)and failed to compile on the Windows runner.This PR qualifies the constructions as
new OutputHandler(...)everywhere inRunCommandTests.cs.Heads-up — possible API design wart
This same ambiguity will hit any caller who uses target-typed
new()for the output handler. If that's a concern, options are:Execute(string, Elevation)/ExecuteAsync(string, Elevation)overloads — callers who want elevation can use the 3-arg form. Simplest API, fewer overloads.ExecuteElevated(...)).new OutputHandler(...)when using only two args.Happy to do whichever you prefer in a follow-up.
Test plan
windows-latest.Generated by Claude Code