Tool refactoring Phase 2: replace CakeHost with Spectre.Console.Cli#254
Conversation
Plumb a singleton holder of MSBuild properties through DotNetService.StandardMSBuildArgs(). No population path yet — the Spectre.Console.Cli cutover (Tenacom#236) will wire CLI-parsed /p:Key=Value pairs into it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Phase 2 of the Tool refactoring: swap the Frosting host for a Spectre.Console.Cli CommandApp over a plain ServiceProvider. - New Program.Main builds a ServiceCollection (IAnsiConsole, SpectreLoggerProvider, MSBuildProperties, all Phase-1 services), wraps it in a TypeRegistrar/TypeResolver adapter pair, and dispatches via CommandApp. BuildFailedException is caught at the top and its ExitCode surfaced to the process. - Each Frosting task becomes an AsyncCommand. The pre-pipeline (Clean -> Restore -> Build -> Test -> ...) is expressed as explicit awaits in the command body; the step bodies live in a static BuildSteps class so they can be invoked individually (e.g., for a future 'bv just <step>'). - BaseSettings / BuildSettings / ReleaseSettings carry the global, build, and release options; SettingsApplier maps them to OptionsService / SpectreLoggerProvider.MinLevel / IAnsiConsole.Profile.Capabilities.Ansi. Both camelCase and kebab-case aliases are accepted. - /p:Key=Value (and -p:Key=Value) are pre-extracted from args in Program.Main and pushed into the MSBuildProperties singleton plumbed in the previous commit. - ICommandOptions/EmptyCommandOptions are removed; OptionsService now reads SetOption-pushed values and env-vars only. - Frosting host scaffolding is deleted: BuildContext, BuildStartup, BuildLifetime, CommandLineParser, CakeLogLoggerProvider*, EnvVar, Tasks/, Options/. The Cake.Frosting package reference stays in csproj for now -- Phase 3 will remove it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Inspectcode now reports zero results at WARNING severity for the whole solution. Changes: - Delete GitLabServerRelease.cs: the class is unreachable because GitLabServerAdapter.CreateReleaseAsync already throws. - Delete GitProtocol enum and drop GitUrlInfo.Protocol property: never consumed; the parsing logic that distinguished URL forms is preserved. - Drop GitService.Origin property: set in the ctor but never read. - Tag ProcessResult and GitService with [PublicAPI] so JetBrains doesn't flag externally-unused members. - Tag GetWinePath and GetWinePaths task classes with [UsedImplicitly(WithMembers)]: their [Output] properties are read back via MSBuild reflection. - Drop redundant 'using Buildvana.Core' from the two HomeDirectory providers (implicit inside Buildvana.Core.HomeDirectory). - Suppress two PossibleMultipleEnumeration false positives in ProcessRunner.RunAsync with 'disable once' comments. Root cause is that CommunityToolkit.Diagnostics.Guard.IsNotNull is not annotated with [NoEnumeration]; an external-annotations XML mechanism would be the right fix but inspectcode doesn't pick it up from the documented locations. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@claude please review. |
|
Claude finished @rdeago's task in 4m 37s —— View job PR Review: Tool refactoring Phase 2 — replace CakeHost with Spectre.Console.CliTasks:
Overall this is a clean, well-structured refactor. The commit breakdown is logical, the code is idiomatic, and the acceptance criteria are largely met. I have two medium-priority findings and three lower-priority observations. Medium priority1. Stale pragma comment in
|
Removed.
Text corrected.
Fixed.
Fixed.
Fixed. |
We cannot enable UseJetBrainsAnnotations until Cecil.XmlDocNames and ReSharper.ExportAnnotations have been updated. In particular, ReSharper.ExportAnnotations looks for the .NET 6.0 runtime and breaks the build.
9e9c0fe to
5d78d6e
Compare
Closes #236.
Summary
Phase 2 of the Tool refactoring: swap the Frosting host for a
Spectre.Console.Cli.CommandAppover a plainServiceProvider. After this lands, no production code undersrc/Buildvana.Tool/**/*.csreferences aCake.*type — only theCake.Frostingpackage reference incsprojremains, and Phase 3 will remove it.
Three substantive commits:
39dd2b3— AddMSBuildPropertiessingleton plumbed throughDotNetService.StandardMSBuildArgs().No population path yet; this commit only widens the seam so the Spectre.Console.Cli cutover can push parsed
/p:Key=Valuepairs into it.402ec90— The host swap itself.Program.Mainbuilds aServiceCollection(IAnsiConsole,SpectreLoggerProvider,MSBuildProperties, all Phase-1 services), wraps it in aTypeRegistrar/TypeResolveradapter pair, and dispatches viaCommandApp.BuildFailedExceptionis caught at the top and itsExitCodesurfaced to the process.FrostingTaskbecomes anAsyncCommand. The pre-pipeline (Clean → Restore → Build → Test → …) is expressed as explicit awaits in the command body; the step bodies live in a staticBuildStepsclass so they can be invoked individually (e.g., for a futurebv just <step>).BaseSettings/BuildSettings/ReleaseSettingscarry global, build, and release options;SettingsAppliermaps them toOptionsService/SpectreLoggerProvider.MinLevel/IAnsiConsole.Profile.Capabilities.Ansi. Both camelCase and kebab-case aliases are accepted./p:Key=Value(and-p:Key=Value) are pre-extracted fromargsinProgram.Mainand pushed into theMSBuildPropertiessingleton.ICommandOptions/EmptyCommandOptionsare removed;OptionsServicenow readsSetOption-pushed values and env-vars only.BuildContext,BuildStartup,BuildLifetime,CommandLineParser,CakeLogLoggerProvider*,EnvVar,Tasks/,Options/.5cf9bcf— Inspectcode now reports zero results at WARNING severity for the whole solution. Pre-existing findings cleared as drive-by:GitLabServerRelease.cs(unreachable — adapter throws before construction).GitProtocolenum and drop the unusedGitUrlInfo.Protocolproperty; URL-form parsing is preserved.GitService.Origin(set in ctor, never read).ProcessResultandGitServicewith[PublicAPI].GetWinePath/GetWinePathswith[UsedImplicitly(WithMembers)]so MSBuild[Output]properties aren't flagged.using Buildvana.Corefrom the two HomeDirectory providers.PossibleMultipleEnumerationfalse positives inProcessRunner.RunAsyncwith// ReSharper disable oncecomments. Root cause:CommunityToolkit.Diagnostics.Guard.IsNotNullis not annotated[NoEnumeration]. An external-annotations XML file would be the right fix; inspectcode didn't pick it up from the documented locations during this branch.Acceptance criteria — all met
dotnet bv clean,restore,build,test,pack,releaseall dispatch throughSpectre.Console.Cli.dotnet bv --helpand per-command--helprender Spectre's help with the same information content as before.dotnet bv build /p:ContinuousIntegrationBuild=trueforwards the MSBuild property.--no-coloremits plain text; default in a TTY emits color.BuildFailedExceptionfrom a service surfaces as a non-zero process exit code.grep -r 'Cake\.' src/Buildvana.Tool/**/*.csreturns no production matches (only theCake.Frostingpackage reference incsprojremains; Phase 3).dotnet bv buildself-hosts.Test plan
dotnet bv pack— 0 errors, 0 warnings.inspectcode --swea --severity=WARNING— 0 results.Buildvana.Sdk,bv).