Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Fixed

- **`OptionsHelper.Assign` ignores computed properties.** It infers the path an assignment set by
comparing two seeded copies of the options, and counted every get-only leaf as set because it can
never be seeded. A kit with `[EndpointUrl]` or `[ResourceUrl]` carries a `ResourceKitUrl`, whose
`IsAbsolute` is computed, so every `Assign<THostKitOptions>(o => ...)` on that host kit threw "Found
n candidate paths". Get-only leaves are now skipped: they can be neither assigned nor configured.
- **`[EndpointUrl]` no longer reveals Aspire's hidden `localhost` URL.** With a dev domain, Aspire shows
the dev-domain URL and keeps a details-only `localhost` copy of the same endpoint. `ResourceKitUrl.Apply`
set the display text and `SummaryAndDetails` on both, so the dashboard showed two links with the same
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aspire-resourcekit",
"version": "2.2.1",
"version": "2.2.2",
"description": "Source-generator-powered framework for structuring .NET Aspire AppHost resource composition as strongly typed, test-friendly classes.",
"keywords": [],
"homepage": "https://purview.dev/projects/aspire-resourcekit/",
Expand Down
11 changes: 11 additions & 0 deletions src/src/ResourceKit/OptionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,17 @@ var property in a.GetType()
var av = property.GetValue(a);
var bv = property.GetValue(b);

var isLeaf =
TryGetScalarSentinel(property.PropertyType, 1, out _)
|| property.PropertyType == typeof(string)
|| property.PropertyType == typeof(object);

// A get-only leaf (a computed value such as ResourceKitUrl.IsAbsolute) cannot be seeded, so it
// is always equal across the two copies; it can be neither assigned nor configured, so it is
// never the path an assignment set.
if (isLeaf && property.SetMethod is null)
continue;

if (TryGetScalarSentinel(property.PropertyType, 1, out _))
{
if (Equals(av, bv))
Expand Down
22 changes: 22 additions & 0 deletions src/tests/ResourceKit.UnitTests/OptionsHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,30 @@ public async Task Environment_GivenResourceKitMode_EmitsEnumMemberName()
await Assert.That(envVars[expectedKey]).IsEqualTo("LocalDevelopment");
}

// A kit with [EndpointUrl] carries a ResourceKitUrl option, whose IsAbsolute is computed. A
// get-only property can be neither assigned nor configured, so it is never a candidate path.
[Test]
public async Task Assign_GivenOptionsWithAComputedProperty_IgnoresIt()
{
// Arrange

// Act
var args = OptionsHelper.Assign<UrlOptions>(static c => c.UseDbGate = false).Build();

// Assert
await Assert.That(args.Length).IsEqualTo(1);
await Assert.That(args[0]).IsEqualTo("--Url:UseDbGate=false");
}

sealed class ModeOptions
{
public ResourceKitMode Mode { get; set; }
}

sealed class UrlOptions
{
public bool UseDbGate { get; set; } = true;

public ResourceKitUrl Https { get; set; } = new() { Endpoint = "https", DisplayText = "API" };
}
}
Loading