Skip to content

Migrate System.CommandLine from 2.0.0-beta4 to 2.0.5#7484

Merged
baywet merged 12 commits intodependabot/nuget/src/kiota/System.CommandLine-2.0.5from
copilot/sub-pr-7478
Mar 17, 2026
Merged

Migrate System.CommandLine from 2.0.0-beta4 to 2.0.5#7484
baywet merged 12 commits intodependabot/nuget/src/kiota/System.CommandLine-2.0.5from
copilot/sub-pr-7478

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

  • Analyze API changes needed for System.CommandLine 2.0.0-beta4 → 2.0.5 migration
  • Remove System.CommandLine.Hosting and System.CommandLine.Rendering package references
  • Update Program.cs to use new API, including a CancellationTokenSource triggered by Console.CancelKeyPress and AppDomain.CurrentDomain.ProcessExit; pass the token to host.StartAsync, InvokeAsync, and host.StopAsync; guard ProcessExit callback against ObjectDisposedException on normal exit
  • Update BaseKiotaCommandHandler.cs: extend AsynchronousCommandLineAction, new signature; make ServiceProvider property required and non-nullable (IServiceProvider)
  • Update KiotaHost.cs, KiotaClientCommands.cs, KiotaPluginCommands.cs, KiotaWorkspaceCommands.cs; make serviceProvider parameter required and non-nullable in all GetXXXCommand methods
  • Update all 19 handler files; change ServiceProvider?.GetService<>() to ServiceProvider.GetService<>()
  • Make ServiceProvider property required and non-nullable in KiotaRpcCommandHandler
  • Add Spectre.Console package and replace hand-crafted DisplayTable() (pipes/dashes) with AnsiConsole.Write(table) using Spectre.Console Table
  • Update KiotaHostTests.cs tests to use new API with ServiceCollection().BuildServiceProvider()
  • Build succeeds with 0 errors, 0 warnings
  • Run dotnet format and commit changes

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

dependabot bot and others added 2 commits March 13, 2026 13:43
---
updated-dependencies:
- dependency-name: System.CommandLine
  dependency-version: 2.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
@dependabot dependabot bot force-pushed the dependabot/nuget/src/kiota/System.CommandLine-2.0.5 branch from 5792eb5 to a9d2753 Compare March 16, 2026 14:25
Copilot AI and others added 2 commits March 16, 2026 14:47
- Remove System.CommandLine.Hosting and System.CommandLine.Rendering package references
- Update Program.cs to use new host/invocation pattern without CommandLineBuilder
- Change BaseKiotaCommandHandler to extend AsynchronousCommandLineAction
- Change all handlers to override InvokeAsync(ParseResult, CancellationToken)
- Replace GetValueForOption/GetValueForArgument with GetValue
- Replace FindResultFor with GetResult
- Replace AddAlias with Aliases.Add, AddValidator with Validators.Add
- Replace AddCompletions with CompletionSources.Add
- Replace SetDefaultValue with DefaultValueFactory
- Replace IsRequired with Required, ArgumentHelpName with HelpName
- Replace Handler with Action on all commands
- Fix Option constructors to use object initializer syntax with Description
- Replace TableView usage with DisplayTable helper method
- Pass IServiceProvider through command factory methods for handler injection
- Replace ErrorMessage = with AddError() on OptionResult/CommandResult

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copilot AI changed the title [WIP] Update System.CommandLine to version 2.0.5 Migrate System.CommandLine from 2.0.0-beta4 to 2.0.5 Mar 16, 2026
Copilot AI requested a review from baywet March 16, 2026 14:56
@baywet baywet marked this pull request as ready for review March 16, 2026 14:57
@baywet baywet requested a review from a team as a code owner March 16, 2026 14:57
@baywet baywet marked this pull request as draft March 16, 2026 14:58
@baywet
Copy link
Member

baywet commented Mar 16, 2026

@copilot run dotnet format commit the changed files, do nothing else

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 16, 2026

@copilot run dotnet format commit the changed files, do nothing else

Done in commit 21b92bb.

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copilot AI requested a review from baywet March 16, 2026 15:59
…ods and run dotnet format

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 16, 2026

@copilot run dotnet format commit the changed files, do nothing else

Done in commit e6dece3.

Copilot AI requested a review from baywet March 16, 2026 16:06
…der non-nullable in handlers

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copilot AI requested a review from baywet March 16, 2026 16:21
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 17, 2026

@copilot run dotnet format commit the changed files, do nothing else

Done in commit 024fb4e.

Copilot AI requested a review from baywet March 17, 2026 12:34
@baywet baywet marked this pull request as ready for review March 17, 2026 12:46
@baywet baywet merged commit a6e54f7 into dependabot/nuget/src/kiota/System.CommandLine-2.0.5 Mar 17, 2026
286 of 291 checks passed
@baywet baywet deleted the copilot/sub-pr-7478 branch March 17, 2026 12:52
github-actions bot pushed a commit that referenced this pull request Mar 17, 2026
* Bump System.CommandLine from 2.0.0-beta4.22272.1 to 2.0.5

---
updated-dependencies:
- dependency-name: System.CommandLine
  dependency-version: 2.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Migrate System.CommandLine from 2.0.0-beta4 to 2.0.5 (#7484)

* Bump System.CommandLine from 2.0.0-beta4.22272.1 to 2.0.5

---
updated-dependencies:
- dependency-name: System.CommandLine
  dependency-version: 2.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Initial plan

* Initial plan for System.CommandLine 2.0.5 migration

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>

* Migrate System.CommandLine from 2.0.0-beta4 to 2.0.5

- Remove System.CommandLine.Hosting and System.CommandLine.Rendering package references
- Update Program.cs to use new host/invocation pattern without CommandLineBuilder
- Change BaseKiotaCommandHandler to extend AsynchronousCommandLineAction
- Change all handlers to override InvokeAsync(ParseResult, CancellationToken)
- Replace GetValueForOption/GetValueForArgument with GetValue
- Replace FindResultFor with GetResult
- Replace AddAlias with Aliases.Add, AddValidator with Validators.Add
- Replace AddCompletions with CompletionSources.Add
- Replace SetDefaultValue with DefaultValueFactory
- Replace IsRequired with Required, ArgumentHelpName with HelpName
- Replace Handler with Action on all commands
- Fix Option constructors to use object initializer syntax with Description
- Replace TableView usage with DisplayTable helper method
- Pass IServiceProvider through command factory methods for handler injection
- Replace ErrorMessage = with AddError() on OptionResult/CommandResult

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Migrate System.CommandLine from beta4 to 2.0.5 API

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>

* Apply dotnet format

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>

* Make serviceProvider parameter required in all GetXXXCommand methods

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>

* Make serviceProvider parameter non-nullable in all GetXXXCommand methods and run dotnet format

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>

* Pass CancellationToken to InvokeAsync/StopAsync and make ServiceProvider non-nullable in handlers

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>

* Fix ProcessExit disposal guard and use Spectre.Console for tables

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>

* chore: no borders for tables

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Vincent Biret <vibiret@microsoft.com>

* chore: reverts global.json changes

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Vincent Biret <vibiret@microsoft.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Adrian <christiano+github@microsoft.com>
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.

2 participants