Skip to content

Change NuGetCommands.Add to accept Command instead of RootCommand - #7466

Merged
nkolev92 merged 5 commits into
devfrom
copilot/dont-require-rootcommand
Jun 11, 2026
Merged

nkolev92 merged 5 commits into
devfrom
copilot/dont-require-rootcommand

Conversation

Copilot AI commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#14939

Description

NuGetCommands.Add required a RootCommand despite not using any RootCommand-specific features — RootCommand is just a Command subclass. This unnecessarily prevented the dotnet CLI from passing non-root command instances.

  • NuGetCommands.cs: Added a new primary Add overload accepting Command; kept the existing RootCommand overloads as backcompat shims that delegate to the new Command overload (to be removed once the SDK has switched over)
  • PublicAPI.Shipped.txt: Retained the 2-param and 3-param RootCommand entries; removed the 1-param RootCommand entry
  • PublicAPI.Unshipped.txt: Added the new Command-based overload

Since RootCommand derives from Command, existing callers passing a RootCommand instance continue to work without modification via the backcompat overloads.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

- Change `NuGetCommands.Add` to accept `Command` instead of `RootCommand`
- Remove 2 redundant backcompat overloads that were marked for deletion
- Update PublicAPI files to reflect the new API surface
Copilot AI changed the title [WIP] Update NuGet commands to only require Command Change NuGetCommands.Add to accept Command instead of RootCommand Jun 9, 2026
Copilot AI requested a review from nkolev92 June 9, 2026 19:19
Copilot AI requested a review from nkolev92 June 9, 2026 20:16
Both the new Command overload and the shipped RootCommand overload had
IVirtualProjectBuilder? = null, violating RS0026 (multiple overloads
with optional params) and RS0027 (optional-param overload must have
the most params).

Fix: remove = null from both 3-param overloads, making virtualProjectBuilder
a required (nullable) param. Binary compat is preserved since the method
signature is identical; source compat is preserved via the existing 2-param
and 0-param RootCommand backcompat overloads.

Update PublicAPI.Shipped.txt accordingly.
Copilot AI requested a review from nkolev92 June 9, 2026 21:10
@nkolev92
nkolev92 marked this pull request as ready for review June 9, 2026 23:31
@nkolev92
nkolev92 requested a review from a team as a code owner June 9, 2026 23:31
@nkolev92
nkolev92 requested a review from jeffkl June 9, 2026 23:31
@nkolev92
nkolev92 requested a review from donnie-msft June 9, 2026 23:31
@nkolev92
nkolev92 enabled auto-merge (squash) June 10, 2026 22:31
@nkolev92
nkolev92 merged commit e1b1f16 into dev Jun 11, 2026
21 checks passed
@nkolev92
nkolev92 deleted the copilot/dont-require-rootcommand branch June 11, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't require the usage of RootCommand to wire up the NuGet System.CommandLine commands

4 participants