Skip to content

Commit 7de900f

Browse files
Copilotdavidfowl
andcommitted
Remove duplicated TryResolvePeerNameCore method and use TryResolvePeerCore instead
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
1 parent b2cb368 commit 7de900f

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

src/Aspire.Dashboard/Model/ResourceOutgoingPeerResolver.cs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -144,35 +144,10 @@ private static bool ArePropertyValuesEquivalent(ResourceViewModel resource1, Res
144144

145145
public bool TryResolvePeer(KeyValuePair<string, string>[] attributes, out string? name, out ResourceViewModel? matchedResource)
146146
{
147-
var address = OtlpHelpers.GetPeerAddress(attributes);
148-
if (address != null)
149-
{
150-
// Apply transformers to the peer address cumulatively
151-
var transformedAddress = address;
152-
153-
// First check exact match
154-
if (TryMatchAgainstResources(transformedAddress, _resourceByName, out name, out matchedResource))
155-
{
156-
return true;
157-
}
158-
159-
// Then apply each transformer cumulatively and check
160-
foreach (var transformer in s_addressTransformers)
161-
{
162-
transformedAddress = transformer(transformedAddress);
163-
if (TryMatchAgainstResources(transformedAddress, _resourceByName, out name, out matchedResource))
164-
{
165-
return true;
166-
}
167-
}
168-
}
169-
170-
name = null;
171-
matchedResource = null;
172-
return false;
147+
return TryResolvePeerCore(_resourceByName, attributes, out name, out matchedResource);
173148
}
174149

175-
internal static bool TryResolvePeerNameCore(IDictionary<string, ResourceViewModel> resources, KeyValuePair<string, string>[] attributes, [NotNullWhen(true)] out string? name, [NotNullWhen(true)] out ResourceViewModel? resourceMatch)
150+
internal static bool TryResolvePeerCore(IDictionary<string, ResourceViewModel> resources, KeyValuePair<string, string>[] attributes, [NotNullWhen(true)] out string? name, [NotNullWhen(true)] out ResourceViewModel? resourceMatch)
176151
{
177152
var address = OtlpHelpers.GetPeerAddress(attributes);
178153
if (address != null)

tests/Aspire.Dashboard.Tests/ResourceOutgoingPeerResolverTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public void NameAndDisplayNameDifferent_MultipleInstances_ReturnName()
217217

218218
private static bool TryResolvePeerName(IDictionary<string, ResourceViewModel> resources, KeyValuePair<string, string>[] attributes, out string? peerName)
219219
{
220-
return ResourceOutgoingPeerResolver.TryResolvePeerNameCore(resources, attributes, out peerName, out _);
220+
return ResourceOutgoingPeerResolver.TryResolvePeerCore(resources, attributes, out peerName, out _);
221221
}
222222

223223
[Fact]

0 commit comments

Comments
 (0)