Replace OptionsService with typed settings and ToolConfiguration#264
Conversation
Settings parsed by Spectre now flow into BuildSettingsHolder (a typed DI singleton) and are read back via Resolve*() methods on the settings classes themselves, instead of being laundered through string keys and a stringly-typed bag. Env-var-only secrets and endpoints (GitHub token, NuGet push targets) move to ToolConfiguration.FromEnvironment(), a typed record that will absorb a planned file-backed configuration layer with no consumer changes. The verbosity/color wiring lifts out of the deleted SettingsApplier into a BaseSettings.Apply(IServiceProvider) instance method (split into the BaseSettings-Apply.cs partial). Closes Tenacom#263 by also retiring the env-var fallback for CLI options. Secrets and endpoints stay env-var-read. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@claude please review this PR. |
|
Claude finished @rdeago's task in 4m 47s —— View job PR Review: Replace OptionsService with typed settings and ToolConfigurationTasks:
Overall AssessmentThe refactor is well-structured and a clear improvement: replacing the stringly-typed One correctness issue stands out — a regression for non-release CI builds on GitHub Actions. See below. Bug:
|
ToolConfiguration.FromEnvironment() previously read all secrets eagerly, including the three NuGet push targets. On GitHub Actions, any non-release command (bv build/test/pack/restore) reaches GitHubServerAdapter via the DotNetService ctor; resolving ToolConfiguration there forced the NuGet env vars to be present, which breaks PR builds and other non-release CI that don't carry NuGet credentials. NuGet push targets now live in their own NuGetPushConfiguration record, resolved lazily inside DotNetService.NuGetPushAllAsync (release-only). ToolConfiguration shrinks to just the GitHub token. Property names also drop the now-redundant NuGet suffix (Private/Prerelease/Release). The shared env-var helper moves from ToolConfiguration.RequireEnv to a proper EnvVarHelper.Require in Buildvana.Tool.Utilities. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Fixed.
Added guard against uninitialized use. |
Summary
OptionsService(a string-keyed bag that laundered typed Spectre settings through magic strings) andSettingsApplier(its populate-from-settings glue).BuildSettingsHolder— a typed DI singleton populated by each command — andResolve*()methods onBuildSettings/ReleaseSettingsso consumers read typed values directly. Renaming a setting now breaks the build at the consumer instead of silently falling back to a default.ToolConfiguration(record) +NuGetPushTargetwith aFromEnvironment()static factory for the env-var-only secrets and endpoints (GITHUB_TOKEN, the three*_NUGET_SOURCE/KEYpairs). Same env vars, typed access, registered as a lazy DI singleton. Seedling of the planned file-backed configuration layer — only the factory call site changes when that lands.BaseSettings.Apply(IServiceProvider)(partial).CONFIGURATION,MAIN_BRANCH, the five renamedbv releaseones) are no longer recognized; secrets/endpoints are unaffected.--verbosityparameter to those accepted by the .NET CLI:quiet/q,minimal/m,normal/n,detailed/d,diagnostic/diag.Closes #263.
Test plan
dotnet bv packsucceeds with zero errors and zero warnings; both.nupkgartifacts produced.dotnet dnx JetBrains.ReSharper.GlobalTools inspectcode --swea --severity=WARNING …reports zero results.