Skip to content

Migrate CLI bootstrap to System.CommandLine 2.0.3 APIs#75

Merged
DanRigby merged 2 commits intomainfrom
copilot/update-codebase-for-breaking-changes
Feb 17, 2026
Merged

Migrate CLI bootstrap to System.CommandLine 2.0.3 APIs#75
DanRigby merged 2 commits intomainfrom
copilot/update-codebase-for-breaking-changes

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

PR #74 upgraded System.CommandLine to 2.0.3, but the app entrypoint still used pre-release APIs removed/renamed in stable releases, which broke build/CI. This updates the CLI wiring in Program.cs to the 2.0.3 surface with minimal behavioral change.

  • CLI option API migration

    • Replaced removed IsRequired with Required.
    • Replaced removed AddAlias(...) with Aliases.Add(...).
    • Updated option construction to set help text via Description instead of old constructor usage.
  • Command handler/invocation migration

    • Replaced SetHandler(...) with SetAction(...).
    • Switched from strongly-typed handler binding to explicit value extraction from ParseResult.
    • Replaced RootCommand.InvokeAsync(args) with rootCommand.Parse(args).InvokeAsync().
  • Dependency alignment

    • Updated MudProxy.csproj to use System.CommandLine 2.0.3 so source and package API expectations are consistent.
Option<string> hostNameOption =
    new("--hostname") { Description = "Hostname of the MUD server to connect to.", Required = true };
hostNameOption.Aliases.Add("-h");

rootCommand.SetAction(async parseResult =>
{
    string hostName = parseResult.GetValue(hostNameOption)!;
    // ...
});

await rootCommand.Parse(args).InvokeAsync();

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:

  • www.jetbrains.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2025.3.2/tools/net8.0/any/inspectcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2025.3.2/tools/net8.0/any/inspectcode.exe --no-build --swea --severity=SUGGESTION --format=xml --output=inspectcode.xml MudProxy.sln (dns block)

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: DanRigby <114417+DanRigby@users.noreply.github.com>
Copilot AI changed the title [WIP] Update codebase to resolve breaking changes from pull request 74 Migrate CLI bootstrap to System.CommandLine 2.0.3 APIs Feb 17, 2026
Copilot AI requested a review from DanRigby February 17, 2026 14:45
@DanRigby DanRigby marked this pull request as ready for review February 17, 2026 15:06
Copilot AI review requested due to automatic review settings February 17, 2026 15:06
@DanRigby DanRigby merged commit 5283b38 into main Feb 17, 2026
5 checks passed
@DanRigby DanRigby deleted the copilot/update-codebase-for-breaking-changes branch February 17, 2026 15:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to migrate the CLI bootstrap code from System.CommandLine beta APIs to the stable 2.0.3 release, following the package upgrade in PR #74. However, the migration uses incorrect API methods that don't exist in System.CommandLine 2.0.3, which will prevent the code from compiling.

Changes:

  • Updated MudProxy.csproj to reference System.CommandLine version 2.0.3 (from beta version)
  • Attempted migration of CLI option definitions and command handler setup in Program.cs, but used incorrect API names

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
MudProxy/MudProxy.csproj Updated System.CommandLine package reference from 2.0.0-beta4.22272.1 to 2.0.3
MudProxy/Program.cs Attempted API migration that uses incorrect method names (SetAction, Required) and invocation pattern not present in System.CommandLine 2.0.3
Comments suppressed due to low confidence (2)

MudProxy/Program.cs:23

  • The property name should be IsRequired in System.CommandLine 2.0.3, not Required.

While the migration from the beta API's constructor parameter to a property is correct, the stable 2.0.3 API uses IsRequired = true as the property name, not Required = true.

    new("--host-port") { Description = "Port to connect to the MUD server on.", Required = true };

MudProxy/Program.cs:28

  • The property name should be IsRequired in System.CommandLine 2.0.3, not Required.

While the migration from the beta API's constructor parameter to a property is correct, the stable 2.0.3 API uses IsRequired = true as the property name, not Required = true.

    new("--proxy-port") { Description = "Port the MUD proxy will listen for clients on.", Required = true };

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 37 to +60
@@ -54,8 +57,8 @@
await Task.WhenAll(clientTask, hostTask);

Console.WriteLine("Program exiting.");
}, hostNameOption, hostPortOption, proxyPortOption, mccp2Option);
});
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method SetAction does not exist in System.CommandLine 2.0.3. The stable 2.0.x API uses SetHandler instead.

In System.CommandLine 2.0.3, you should use SetHandler with a delegate that receives parameters, like:

rootCommand.SetHandler(async (string hostName, int hostPort, int proxyPort, bool enableMccp2) =>
{
    // handler code
}, hostNameOption, hostPortOption, proxyPortOption, mccp2Option);

Alternatively, if you prefer the ParseResult approach, use:

rootCommand.SetHandler(async (ParseResult parseResult) =>
{
    string hostName = parseResult.GetValue(hostNameOption)!;
    // ...
});

The current code using SetAction will not compile with System.CommandLine 2.0.3.

Copilot uses AI. Check for mistakes.
});

await rootCommand.InvokeAsync(args);
await rootCommand.Parse(args).InvokeAsync();
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In System.CommandLine 2.0.3, the invocation pattern should be await rootCommand.InvokeAsync(args), not await rootCommand.Parse(args).InvokeAsync().

The Parse(args).InvokeAsync() pattern was from earlier beta versions. The stable 2.0.3 release uses the simpler InvokeAsync(args) method directly on the command.

Suggested change
await rootCommand.Parse(args).InvokeAsync();
await rootCommand.InvokeAsync(args);

Copilot uses AI. Check for mistakes.
Option<string> hostNameOption =
new("--hostname", "Hostname of the MUD server to connect to.") { IsRequired = true };
hostNameOption.AddAlias("-h");
new("--hostname") { Description = "Hostname of the MUD server to connect to.", Required = true };
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property name should be IsRequired in System.CommandLine 2.0.3, not Required.

While the migration from the beta API's constructor parameter to a property is correct, the stable 2.0.3 API uses IsRequired = true as the property name, not Required = true.

This issue also appears in the following locations of the same file:

  • line 23
  • line 28

See below for a potential fix:

    new("--hostname") { Description = "Hostname of the MUD server to connect to.", IsRequired = true };
hostNameOption.Aliases.Add("-h");
rootCommand.Add(hostNameOption);

Option<int> hostPortOption =
    new("--host-port") { Description = "Port to connect to the MUD server on.", IsRequired = true };
hostPortOption.Aliases.Add("-p");
rootCommand.Add(hostPortOption);

Option<int> proxyPortOption =
    new("--proxy-port") { Description = "Port the MUD proxy will listen for clients on.", IsRequired = true };

Copilot uses AI. Check for mistakes.
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.

3 participants