Skip to content

Fix System.CommandLine beta5 breaking changes#149

Merged
majastrz merged 2 commits intodependabot/nuget/src/multi-1e9a648a07from
copilot/sub-pr-147-again
Mar 9, 2026
Merged

Fix System.CommandLine beta5 breaking changes#149
majastrz merged 2 commits intodependabot/nuget/src/multi-1e9a648a07from
copilot/sub-pr-147-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

System.CommandLine 2.0.0-beta5 introduced breaking API changes that fail compilation. Updates Program.cs to conform to the new API.

Breaking changes addressed

  • Option<T> constructor — description parameter removed; set via Description property instead
  • IsRequiredRequired
  • AddOption()Add()
  • SetHandler()SetAction(ParseResult, CancellationToken) — option values retrieved explicitly via parseResult.GetValue(option) rather than positional binding
  • command.InvokeAsync(args)command.Parse(args).InvokeAsync()

Example migration

// Before (beta4)
var opt = new Option<string>("--output-file", "Path to output.")
    { IsRequired = true };
rootCommand.AddOption(opt);
rootCommand.SetHandler((output) => DoWork(output), opt);
return await rootCommand.InvokeAsync(args);

// After (beta5)
var opt = new Option<string>("--output-file")
    { Description = "Path to output.", Required = true };
rootCommand.Add(opt);
rootCommand.SetAction(async (ParseResult pr, CancellationToken ct) =>
{
    var output = pr.GetValue(opt)!; // Required = true guarantees non-null
    return await DoWork(output);
});
return await rootCommand.Parse(args).InvokeAsync();

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

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

Copilot AI commented Mar 9, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • learn.microsoft.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update System.CommandLine to version 2.0.0-beta5 Fix System.CommandLine beta5 breaking changes Mar 9, 2026
@majastrz majastrz marked this pull request as ready for review March 9, 2026 20:48
@majastrz majastrz merged commit 60a44a8 into dependabot/nuget/src/multi-1e9a648a07 Mar 9, 2026
1 check passed
@majastrz majastrz deleted the copilot/sub-pr-147-again branch March 9, 2026 20:49
microsoft-github-policy-service bot pushed a commit that referenced this pull request Mar 9, 2026
* Bump System.CommandLine and System.CommandLine.Hosting

Bumps System.CommandLine from 2.0.0-beta4.22272.1 to 2.0.0-beta5.25306.1
Bumps System.CommandLine.Hosting from 0.4.0-alpha.22272.1 to 0.4.0-alpha.25306.1

---
updated-dependencies:
- dependency-name: System.CommandLine
  dependency-version: 2.0.0-beta5.25306.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: System.CommandLine.Hosting
  dependency-version: 0.4.0-alpha.25306.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Fix System.CommandLine beta5 breaking changes (#149)

* Initial plan

* Fix System.CommandLine beta5 breaking changes in Program.cs

Co-authored-by: majastrz <22460039+majastrz@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: majastrz <22460039+majastrz@users.noreply.github.com>

* Additional fixes

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: majastrz <22460039+majastrz@users.noreply.github.com>
Co-authored-by: Marcin Jastrzebski <majastrz@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