Match name with ResourceCommandService#10370
Merged
Conversation
Member
Author
|
cc @afscrome |
Contributor
There was a problem hiding this comment.
Pull Request Overview
Implements fallback matching by resource name when no replicas exist and clarifies this behavior in XML documentation, plus adds corresponding unit tests.
- Adds fallback logic in
ResourceNotificationServiceto match resources by name if only one exists. - Updates XML docs in both
ResourceNotificationServiceandResourceCommandServiceto explain resource ID vs. name matching. - Introduces tests covering both failure and success scenarios for resource name matching in
ResourceCommandService.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/ResourceCommandServiceTests.cs | Adds tests for resource name matching (failure and success) |
| src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs | Implements name-based fallback lookup and updates XML docs |
| src/Aspire.Hosting/ApplicationModel/ResourceCommandService.cs | Updates XML docs to clarify resourceId vs. resourceName logic |
Comments suppressed due to low confidence (2)
src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs:448
- Fix the grammar and spelling in this XML comment: change "can be also be used" to "can also be used" and correct "specifing" to "specifying".
/// </para>
src/Aspire.Hosting/ApplicationModel/ResourceCommandService.cs:37
- Fix the grammar and spelling in this XML comment: change "can be also be used" to "can also be used" and correct "specifing" to "specifying".
/// The resource name can be also be used to retrieve the resource state, but it must be unique. If there are multiple resources with the same name, then this method will not return a match.
src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
davidfowl
reviewed
Jul 14, 2025
| else | ||
| { | ||
| // Second match found, so we can't return a match based on the name. | ||
| nameMatch = null; |
davidfowl
approved these changes
Jul 14, 2025
Member
Author
|
/backport to release/9.4 |
Contributor
|
Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16258280487 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
ResourceCommandService.ExecuteCommandAsync(string, ...)takes a resourceId and matches to the resource with that resourceId. That includes the suffix for DCP resources, e.g.cache-sfsdfsdf. This could be confusing as people often only think about the resource name, e.g.cache.PR improves XML docs for API. It also allows the method to match on resource name if there are no replicas.
Fixes #10224
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate