Skip to content

fix: options assign ignores computed properties - #68

Merged
kieronlanning merged 2 commits into
mainfrom
fix/options-assign-skips-computed-properties
Nov 20, 2026
Merged

kieronlanning merged 2 commits into
mainfrom
fix/options-assign-skips-computed-properties

Conversation

@kieronlanning

Copy link
Copy Markdown
Contributor

Problem

OptionsHelper.Assign<TOptions>(o => ...) infers the path an assignment set by seeding two copies of the options with different sentinels, running the assignment on both, and collecting the leaves that ended up equal. A get-only leaf cannot be seeded, so it is always equal and was always counted.

Since 2.2, a kit with [EndpointUrl] or [ResourceUrl] carries a ResourceKitUrl option, whose IsAbsolute is computed. Every Assign on that host kit's options then threw, for example:

Each assignment action must set exactly one property path. Found 4 candidate paths: API:Urls:Https:IsAbsolute, DocsSite:Urls:Http:IsAbsolute, SqlServer:UseDbGate, Web:Urls:Https:IsAbsolute

Found in a consumer AppHost after adding [EndpointUrl] (2.2.1): its test fixtures and composition tests build arguments with OptionsHelper.Assign.

Fix

CollectEqualLeafPaths skips get-only leaves (scalar, string or object with no setter). They can be neither assigned nor bound from configuration, so they are never the path an assignment set.

Tests

  • Assign_GivenOptionsWithAComputedProperty_IgnoresIt failed before ("Found 2 candidate paths: UseDbGate, Https:IsAbsolute") and passes after.
  • ResourceKit.UnitTests: 300/300 on net10.0 and net11.0; CSharpier check clean.

@kieronlanning
kieronlanning merged commit f271767 into main Nov 20, 2026
1 check passed
@kieronlanning
kieronlanning deleted the fix/options-assign-skips-computed-properties branch November 20, 2026 10:58
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.

1 participant