Repository navigation
feat: migrate System.CommandLine from deprecated pre-release packages to stable 2.0.2 - #23
Merged
Merged
Conversation
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 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.
…ps://github.com/porrey/Diamond.Core-Patterns into copilot/eliminate-deprecated-system-commandline
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.
There was a problem hiding this comment.
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 withSystem.CommandLineand adaptRootCommandService+ModelCommand<TModel>to the 2.x parse→invoke andSetActionpatterns. - Add new NUnit test projects validating
RootCommandServiceandModelCommand<TModel>behavior with the new API. - Bump project versions to
10.1.5across the repo and apply a few downstream fixes (namespace qualification,newmember 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three deprecated pre-release
System.CommandLinepackages were in use. This replaces them all with the single stableSystem.CommandLine 2.0.2package and adapts all call sites to the new API.Packages removed
System.CommandLine.Rendering 0.4.0-alpha.22272.1Diamond.Core.CommandLineSystem.CommandLine.NamingConventionBinder 2.0.0-beta4.22272.1Diamond.Core.CommandLine.ModelSystem.CommandLine.Hosting 0.4.0-alpha.22272.1BasicConsoleexample (unused — no code references)Invocation pipeline (
RootCommandService.cs)CommandLineBuilder,UseDefaults(), andUseAnsiTerminalWhenAvailable()are gone in 2.x. Replaced with the new parse-then-invoke pattern; also renamesAddCommand→Add:Model binding (
ModelCommand.cs)CommandHandler.Create<TModel>(fromNamingConventionBinder) no longer exists. Replaced withSetAction+ explicitParseResult-based hydration. A_optionBindingslist (built duringBuildOptions()) maps eachPropertyInfoto itsOptioninstance; the handler usesParseResult.GetValue<T>(string)via cached reflection to populate a freshTModelbefore forwarding to the existingOnHandleCommand(TModel)override — no consumer API change.Option<T>constructor also changed from(string[] aliases, string description)to(string name, string[] aliases)withDescriptionas a settable property;BuildOptions()is updated accordingly.The never-called
CreateCommandHandler<T>()helper is removed (HandlerDescriptorno longer exists).Downstream fixes
System.CommandLine 2.x adds a
Command.Actionproperty of typeCommandLineAction, which caused two side effects in example projects:DbCommand.cs—Action.Create/Action.Dropcase labels resolved toCommandLineAction(member lookup beats same-namespace type lookup). Fixed by fully qualifying:Diamond.Core.Example.Action.Create.GetCommandDirect.cs— existingprotected IMeasureAction Actionproperty now triggers CS0108. Fixed by addingnew.