Skip to content

feat: migrate System.CommandLine from deprecated pre-release packages to stable 2.0.2 - #23

Merged
porrey merged 7 commits into
masterfrom
copilot/eliminate-deprecated-system-commandline
Jul 31, 2026
Merged

porrey merged 7 commits into
masterfrom
copilot/eliminate-deprecated-system-commandline

Conversation

Copilot AI commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Three deprecated pre-release System.CommandLine packages were in use. This replaces them all with the single stable System.CommandLine 2.0.2 package and adapts all call sites to the new API.

Packages removed

Removed Was used in
System.CommandLine.Rendering 0.4.0-alpha.22272.1 Diamond.Core.CommandLine
System.CommandLine.NamingConventionBinder 2.0.0-beta4.22272.1 Diamond.Core.CommandLine.Model
System.CommandLine.Hosting 0.4.0-alpha.22272.1 BasicConsole example (unused — no code references)

Invocation pipeline (RootCommandService.cs)

CommandLineBuilder, UseDefaults(), and UseAnsiTerminalWhenAvailable() are gone in 2.x. Replaced with the new parse-then-invoke pattern; also renames AddCommand → Add:

// Before
int result = await new CommandLineBuilder((RootCommand)this.RootCommand)
    .UseDefaults()
    .UseAnsiTerminalWhenAvailable()
    .Build()
    .InvokeAsync(this.RootCommand.Args);

// After
int result = await CommandLineParser
    .Parse((RootCommand)this.RootCommand, this.RootCommand.Args)
    .InvokeAsync();

Model binding (ModelCommand.cs)

CommandHandler.Create<TModel> (from NamingConventionBinder) no longer exists. Replaced with SetAction + explicit ParseResult-based hydration. A _optionBindings list (built during BuildOptions()) maps each PropertyInfo to its Option instance; the handler uses ParseResult.GetValue<T>(string) via cached reflection to populate a fresh TModel before forwarding to the existing OnHandleCommand(TModel) override — no consumer API change.

Option<T> constructor also changed from (string[] aliases, string description) to (string name, string[] aliases) with Description as a settable property; BuildOptions() is updated accordingly.

The never-called CreateCommandHandler<T>() helper is removed (HandlerDescriptor no longer exists).

Downstream fixes

System.CommandLine 2.x adds a Command.Action property of type CommandLineAction, which caused two side effects in example projects:

  • DbCommand.cs — Action.Create/Action.Drop case labels resolved to CommandLineAction (member lookup beats same-namespace type lookup). Fixed by fully qualifying: Diamond.Core.Example.Action.Create.
  • GetCommandDirect.cs — existing protected IMeasureAction Action property now triggers CS0108. Fixed by adding new.

Copilot AI requested review from Copilot and removed request for Copilot July 31, 2026 11:37
Copilot AI changed the title feat: migrate deprecated System.CommandLine packages to stable 2.0.2 feat: migrate System.CommandLine from deprecated pre-release packages to stable 2.0.2 Jul 31, 2026
Copilot AI requested a review from porrey July 31, 2026 11:41
Copilot stopped work on behalf of porrey due to an error July 31, 2026 11:56
Refactored the instantiation of DiamondServiceProviderFactory to use target-typed `new()` for improved code clarity. Also adjusted closing brace formatting at the end of HostBuilderExtensions.cs for consistency.
Copilot AI requested review from Copilot and removed request for Copilot July 31, 2026 12:14
porrey added 2 commits July 31, 2026 07:22
All projects bumped to v10.1.5. Updated several NuGet dependencies (System.CommandLine, Asp.Versioning.Mvc, Oracle.EntityFrameworkCore, SQLitePCLRaw.bundle_e_sqlite3). Renamed WebbApplicationBuilderDecorator.cs to WebApplicationBuilderDecorator.cs and restored extension methods for configuring WebApplicationBuilder and WebApplication. Removed the old, misspelled file.
Copilot AI review requested due to automatic review settings July 31, 2026 12:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Migrates the solution off deprecated pre-release System.CommandLine packages to the stable System.CommandLine 2.x API surface, updating the hosted invocation pipeline and model-binding approach accordingly. The PR also bumps package/assembly versions across many projects and adds new unit tests covering the updated command-line integration.

Changes:

  • Replace deprecated System.CommandLine.* pre-release packages with System.CommandLine and adapt RootCommandService + ModelCommand<TModel> to the 2.x parse→invoke and SetAction patterns.
  • Add new NUnit test projects validating RootCommandService and ModelCommand<TModel> behavior with the new API.
  • Bump project versions to 10.1.5 across the repo and apply a few downstream fixes (namespace qualification, new member hiding, decorator rename).

Reviewed changes

Copilot reviewed 77 out of 78 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Src/Wpf/Diamond.Core.Wpf/Diamond.Core.Wpf.csproj Bump project/package version metadata to 10.1.5.
Src/Wpf/Diamond.Core.Wpf.Abstractions/Diamond.Core.Wpf.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Workflow/Diamond.Core.Workflow/Diamond.Core.Workflow.csproj Bump project/package version metadata to 10.1.5.
Src/Workflow/Diamond.Core.Workflow.Steps/Diamond.Core.WorkFlow.Steps.csproj Bump project/package version metadata to 10.1.5.
Src/Workflow/Diamond.Core.Workflow.State/Diamond.Core.Workflow.State.csproj Bump project/package version metadata to 10.1.5.
Src/Workflow/Diamond.Core.Workflow.State.Abstractions/Diamond.Core.Workflow.State.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Workflow/Diamond.Core.Workflow.Abstractions/Diamond.Core.Workflow.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Unit of Work/Diamond.Core.UnitOfWork/Diamond.Core.UnitOfWork.csproj Bump project/package version metadata to 10.1.5.
Src/Unit of Work/Diamond.Core.UnitOfWork.Abstractions/Diamond.Core.UnitOfWork.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Tests/Diamond.Core.System.Tests/Diamond.Core.System.Tests.csproj Bump test assembly version metadata to 10.1.5.
Src/Tests/Diamond.Core.Specification.Tests/Diamond.Core.Specification.Tests.csproj Bump test assembly version metadata to 10.1.5.
Src/Tests/Diamond.Core.Rules.Tests/Diamond.Core.Rules.Tests.csproj Bump test assembly version metadata to 10.1.5.
Src/Tests/Diamond.Core.Decorator.Tests/Diamond.Core.Decorator.Tests.csproj Bump test assembly version metadata to 10.1.5.
Src/Tests/Diamond.Core.CommandLine.Tests/RootCommandServiceTests.cs Add unit tests for RootCommandService behavior with System.CommandLine 2.x.
Src/Tests/Diamond.Core.CommandLine.Tests/Diamond.Core.CommandLine.Tests.csproj New test project for command-line hosting tests.
Src/Tests/Diamond.Core.CommandLine.Model.Tests/ModelCommandTests.cs Add unit tests validating ModelCommand option building + ParseResult-based binding.
Src/Tests/Diamond.Core.CommandLine.Model.Tests/Diamond.Core.CommandLine.Model.Tests.csproj New test project for ModelCommand binding tests.
Src/Tests/Diamond.Core.Clonable.Tests/Diamond.Core.Clonable.Tests.csproj Bump test assembly version metadata to 10.1.5.
Src/System/Diamond.Core.System.Text/Diamond.Core.System.Text.csproj Bump project/package version metadata to 10.1.5.
Src/System/Diamond.Core.System.TemporaryFolder/Diamond.Core.System.TemporaryFolder.csproj Bump project/package version metadata to 10.1.5.
Src/System/Diamond.Core.System.Base36/Diamond.Core.System.Base36.csproj Bump project/package version metadata to 10.1.5.
Src/System/Diamond.Core.Performance/Diamond.Core.Performance.csproj Bump project/package version metadata to 10.1.5.
Src/Specification/Diamond.Core.Specification/Diamond.Core.Specification.csproj Bump project/package version metadata to 10.1.5.
Src/Specification/Diamond.Core.Specification.Abstractions/Diamond.Core.Specification.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Shared/Diamond.Core.Abstractions/Diamond.Core.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Rules/Diamond.Core.Rules/Diamond.Core.Rules.csproj Bump project/package version metadata to 10.1.5.
Src/Rules/Diamond.Core.Rules.Abstractions/Diamond.Core.Rules.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Repository/Diamond.Core.Repository/Diamond.Core.Repository.csproj Bump project/package version metadata to 10.1.5.
Src/Repository/Diamond.Core.Repository.EntityFrameworkCore/Diamond.Core.Repository.EntityFrameworkCore.csproj Bump project/package version metadata to 10.1.5.
Src/Repository/Diamond.Core.Repository.DateTimeModel/Diamond.Core.Repository.DateTimeModel.csproj Bump project/package version metadata to 10.1.5.
Src/Repository/Diamond.Core.Repository.Abstractions/Diamond.Core.Repository.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Hosting/Diamond.Core.Extensions.Hosting/Diamond.Core.Extensions.Hosting.csproj Bump project/package version metadata to 10.1.5.
Src/Hosting/Diamond.Core.Extensions.Hosting.Abstractions/Diamond.Core.Extensions.Hosting.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Examples/Diamond.Core.Example.Wpf/Diamond.Core.Example.Wpf.csproj Bump example project version metadata to 10.1.5.
Src/Examples/Diamond.Core.Example.Web/Diamond.Core.Example.Web.csproj Bump example project version metadata; update Asp.Versioning.Mvc package.
Src/Examples/Diamond.Core.Example.Unity/Diamond.Core.Example.Unity.csproj Bump example project version metadata to 10.1.5.
Src/Examples/Diamond.Core.Example.Shared/Diamond.Core.Example.Shared.csproj Bump example project version metadata to 10.1.5.
Src/Examples/Diamond.Core.Example.LoadServices/Diamond.Core.Example.LoadServices.csproj Bump example project version metadata to 10.1.5.
Src/Examples/Diamond.Core.Example.KeyedServices/Diamond.Core.Example.KeyedServices.csproj Bump example project version metadata to 10.1.5.
Src/Examples/Diamond.Core.Example.DbContext/Diamond.Core.Example.DbContext.csproj Bump example project version metadata to 10.1.5.
Src/Examples/Diamond.Core.Example.DbContext/Commands/DbCommand.cs Disambiguate enum references affected by System.CommandLine 2.x Command.Action.
Src/Examples/Diamond.Core.Example.ConsoleCommand/Diamond.Core.Example.ConsoleCommand.csproj Bump example project version metadata to 10.1.5.
Src/Examples/Diamond.Core.Example.ConsoleCommand/Commands/Direct/GetCommandDirect.cs Add new to intentionally hide base Action member introduced by System.CommandLine 2.x.
Src/Examples/Diamond.Core.Example.BasicConsole/Diamond.Core.Example.BasicConsole.csproj Remove deprecated System.CommandLine.Hosting reference; bump SQLitePCLRaw bundle.
Src/Examples/Diamond.Core.Example.AutoMapperDependency/Diamond.Core.Example.AutoMapperDependency.csproj Bump example project version metadata to 10.1.5.
Src/Examples/Diamond.Core.Example.AutoMapperDependency.Profiles/Diamond.Core.Example.AutoMapperDependency.Profiles.csproj Bump example project version metadata to 10.1.5.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection/Models/HostBuilderExtensions.cs Minor cleanup (new() target-typed) and formatting.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection/Diamond.Core.Extensions.DependencyInjection.csproj Bump project/package version metadata to 10.1.5.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection.SqlServer/Diamond.Core.Extensions.DependencyInjection.SqlServer.csproj Bump project/package version metadata to 10.1.5.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection.Sqlite/Diamond.Core.Extensions.DependencyInjection.Sqlite.csproj Bump version metadata; bump SQLitePCLRaw bundle dependency.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection.PostgreSQL/Diamond.Core.Extensions.DependencyInjection.PostgreSQL.csproj Bump project/package version metadata to 10.1.5.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection.Oracle/Diamond.Core.Extensions.DependencyInjection.Oracle.csproj Bump version metadata; update Oracle EF Core package reference.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection.MySql/Diamond.Core.Extensions.DependencyInjection.MySql.csproj Bump project/package version metadata to 10.1.5.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection.InMemory/Diamond.Core.Extensions.DependencyInjection.InMemory.csproj Bump project/package version metadata to 10.1.5.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection.EntityFrameworkCore/Diamond.Core.Extensions.DependencyInjection.EntityFrameworkCore.csproj Bump project/package version metadata to 10.1.5.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection.Cosmos/Diamond.Core.Extensions.DependencyInjection.Cosmos.csproj Bump project/package version metadata to 10.1.5.
Src/Dependency-Injection/Diamond.Core.Extensions.DependencyInjection.Abstractions/Diamond.Core.Extensions.DependencyInjection.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Decorator/Diamond.Core.Decorator/Diamond.Core.Decorator.csproj Bump project/package version metadata to 10.1.5.
Src/Decorator/Diamond.Core.Decorator.Abstractions/Diamond.Core.Decorator.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Command Line/Diamond.Core.CommandLine/Hosted Services/RootCommandService.cs Migrate invocation pipeline to System.CommandLine 2.x parse→invoke; update RootCommand command registration API.
Src/Command Line/Diamond.Core.CommandLine/Diamond.Core.CommandLine.csproj Swap deprecated Rendering package for System.CommandLine 2.x; bump version metadata.
Src/Command Line/Diamond.Core.CommandLine.Model/XmlDocs/Diamond.Core.CommandLine.Model.xml Remove doc entries for removed handler helper; update OptionDescriptor member docs.
Src/Command Line/Diamond.Core.CommandLine.Model/Models/OptionDescriptor.cs Extend OptionDescriptor to carry PropertyInfo for binding.
Src/Command Line/Diamond.Core.CommandLine.Model/Models/ModelCommand.cs Replace NamingConventionBinder handler with SetAction + ParseResult-based hydration.
Src/Command Line/Diamond.Core.CommandLine.Model/Diamond.Core.CommandLine.Model.csproj Swap NamingConventionBinder package for System.CommandLine 2.x; bump version metadata.
Src/Command Line/Diamond.Core.CommandLine.Abstractions/Diamond.Core.CommandLine.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/Clonable/Diamond.Core.Clonable/Diamond.Core.Clonable.csproj Bump project/package version metadata to 10.1.5.
Src/Clonable/Diamond.Core.Clonable.Newtonsoft/Diamond.Core.Clonable.Newtonsoft.csproj Bump project/package version metadata to 10.1.5.
Src/Clonable/Diamond.Core.Clonable.Microsoft/Diamond.Core.Clonable.Microsoft.csproj Bump project/package version metadata to 10.1.5.
Src/Clonable/Diamond.Core.Clonable.Abstractions/Diamond.Core.Clonable.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/AutoMapper/Diamond.Core.AutoMapperExtensions/Diamond.Core.AutoMapperExtensions.csproj Bump project/package version metadata to 10.1.5.
Src/AspNetCore/Diamond.Core.AspNetCore.Swagger/Diamond.Core.AspNetCore.Swagger.csproj Bump project/package version metadata to 10.1.5.
Src/AspNetCore/Diamond.Core.AspNetCore.Rfc7807/Diamond.Core.AspNetCore.Rfc7807.csproj Bump project/package version metadata to 10.1.5.
Src/AspNetCore/Diamond.Core.AspNetCore.Hosting/Diamond.Core.AspNetCore.Hosting.csproj Bump project/package version metadata to 10.1.5.
Src/AspNetCore/Diamond.Core.AspNetCore.Hosting/Decorators/WebApplicationBuilderDecorator.cs Fix class name typo (Webb→Web) for the decorator helper.
Src/AspNetCore/Diamond.Core.AspNetCore.DoAction/Diamond.Core.AspNetCore.DoAction.csproj Bump project/package version metadata to 10.1.5.
Src/AspNetCore/Diamond.Core.AspNetCore.DoAction.Abstractions/Diamond.Core.AspNetCore.DoAction.Abstractions.csproj Bump project/package version metadata to 10.1.5.
Src/AspNetCore/Diamond.Core.AspNetCore.DataTables/Diamond.Core.AspNetCore.DataTables.csproj Bump project/package version metadata to 10.1.5.
Files not reviewed (1)
  • Src/Command Line/Diamond.Core.CommandLine.Model/XmlDocs/Diamond.Core.CommandLine.Model.xml: Generated file
Suppressed comments (1)

Src/AspNetCore/Diamond.Core.AspNetCore.Hosting/Decorators/WebApplicationBuilderDecorator.cs:12

  • The class was renamed to WebApplicationBuilderDecorator, but the shipped XML docs file still documents the old type name (WebbApplicationBuilderDecorator). This will leave consumers with incorrect IntelliSense/packaged docs unless the corresponding XmlDocs entry is updated to the new type/member names.

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

Comment on lines 55 to +56
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.10" />
<PackageReference Include="System.CommandLine.Rendering" Version="0.4.0-alpha.22272.1" />
<PackageReference Include="System.CommandLine" Version="2.0.10" />
Comment on lines 54 to 56
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.10" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine" Version="2.0.10" />
</ItemGroup>
Comment on lines +9 to +11
<Version>10.1.4</Version>
<FileVersion>10.1.4</FileVersion>
<AssemblyVersion>10.1.4</AssemblyVersion>
…d ConfigureServicesFolders

Co-authored-by: porrey <12475115+porrey@users.noreply.github.com>
Corrected XML doc/member typo to WebApplicationBuilderDecorator.
Added Diamond.Core.CommandLine.Tests to solution and folder.
Bumped test project version to 10.1.5.
Copilot AI review requested due to automatic review settings July 31, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@porrey
porrey marked this pull request as ready for review July 31, 2026 14:01
@porrey
porrey merged commit 0a0b5ad into master Jul 31, 2026
2 checks passed
@porrey
porrey deleted the copilot/eliminate-deprecated-system-commandline branch July 31, 2026 14:02
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