From fabfee3aa6bb7544a56777adf5c065af93f03d1e Mon Sep 17 00:00:00 2001 From: Jose Perez Rodriguez Date: Fri, 29 May 2026 16:41:47 -0700 Subject: [PATCH 1/2] API review fixes for 13.4 (PR #17700) Addresses several issues found during API surface review: 1. Rename NetworkID -> NetworkId (and networkID -> networkId) on AllocatedEndpoint, EndpointAnnotation, EndpointReference, EndpointReferenceAnnotation, NetworkEndpointSnapshot, NetworkEndpointSnapshotList, and related methods/parameters. 2. Add [Experimental("ASPIREAZURE003")] to AzureRoleAssignmentResource. 3. Change EndpointReferenceAnnotation.EndpointNames from HashSet to ISet (backing field stays HashSet). 4. Add 'sealed' to new public resource classes that are not subclassed in the repo: KubernetesHelmChartResource, BlazorWasmAppResource, BunAppResource, NextJsAppResource, ViteAppResource, AzureNatGatewayResource, AzureNetworkSecurityGroupResource, AzureNetworkSecurityPerimeterResource, AzurePrivateEndpointResource, AzurePublicIPAddressResource, AzureSubnetResource, AzureVirtualNetworkResource. (GoAppResource and NodeAppResource left non-sealed because they are used as generic type constraints in the same assembly.) 5. Disambiguate WithHiddenOnCompletion overloads by removing the '= 0' default from the int overload, so calls with no argument resolve to the params overload. api/*.cs and api/*.ats.txt are intentionally not updated here - the API surface PR will regenerate them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../AzureNatGatewayResource.cs | 2 +- .../AzureNetworkSecurityGroupResource.cs | 2 +- .../AzureNetworkSecurityPerimeterResource.cs | 2 +- .../AzurePrivateEndpointResource.cs | 2 +- .../AzurePublicIPAddressResource.cs | 2 +- .../AzureSubnetResource.cs | 2 +- .../AzureVirtualNetworkResource.cs | 2 +- .../AzureRoleAssignmentResource.cs | 2 + .../RoleAssignmentResourceAnnotation.cs | 2 + .../Resources/BlazorWasmAppResource.cs | 2 +- .../BunAppResource.cs | 2 +- .../NextJsAppResource.cs | 2 +- .../ViteAppResource.cs | 2 +- .../KubernetesHelmChartResource.cs | 2 +- .../ApplicationModel/AllocatedEndpoint.cs | 8 +-- .../ApplicationModel/EndpointAnnotation.cs | 52 +++++++++---------- .../ApplicationModel/EndpointReference.cs | 20 +++---- .../EndpointReferenceAnnotation.cs | 4 +- .../ApplicationModel/HostUrl.cs | 2 +- .../ApplicationModel/ResourceExtensions.cs | 16 +++--- .../ResourceUrlsCallbackContext.cs | 6 +-- src/Aspire.Hosting/Dcp/DcpExecutor.cs | 2 +- src/Aspire.Hosting/Dcp/DcpModelUtilities.cs | 8 +-- .../Orchestrator/ApplicationOrchestrator.cs | 2 +- .../ResourceBuilderExtensions.cs | 18 +++---- src/Shared/StringComparers.cs | 4 +- .../AzurePostgresExtensionsTests.cs | 2 +- .../AzureUserAssignedIdentityTests.cs | 1 + .../RoleAssignmentTests.cs | 2 + .../AddNodeAppTests.cs | 2 +- .../AddMilvusTests.cs | 2 +- .../AddPostgresTests.cs | 2 +- .../PostgresMcpBuilderTests.cs | 2 +- .../AddQdrantTests.cs | 8 +-- .../AddRedisTests.cs | 8 +-- .../Dcp/DcpExecutorTests.cs | 4 +- .../EndpointReferenceTests.cs | 2 +- .../WithEnvironmentTests.cs | 2 +- 38 files changed, 107 insertions(+), 100 deletions(-) diff --git a/src/Aspire.Hosting.Azure.Network/AzureNatGatewayResource.cs b/src/Aspire.Hosting.Azure.Network/AzureNatGatewayResource.cs index 143afa2cd19..bf79f9c645d 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureNatGatewayResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureNatGatewayResource.cs @@ -16,7 +16,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure NAT Gateway resource. -public class AzureNatGatewayResource(string name, Action configureInfrastructure) +public sealed class AzureNatGatewayResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { /// diff --git a/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupResource.cs b/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupResource.cs index be325f6b551..1b1820fccba 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupResource.cs @@ -16,7 +16,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure Network Security Group resource. -public class AzureNetworkSecurityGroupResource(string name, Action configureInfrastructure) +public sealed class AzureNetworkSecurityGroupResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { /// diff --git a/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityPerimeterResource.cs b/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityPerimeterResource.cs index b88b749ac57..25fd26b39ca 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityPerimeterResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityPerimeterResource.cs @@ -22,7 +22,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure Network Security Perimeter resource. -public class AzureNetworkSecurityPerimeterResource(string name, Action configureInfrastructure) +public sealed class AzureNetworkSecurityPerimeterResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { /// diff --git a/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointResource.cs b/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointResource.cs index 66893918260..598c3f5cfbb 100644 --- a/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointResource.cs @@ -13,7 +13,7 @@ namespace Aspire.Hosting.Azure; /// The subnet where the private endpoint will be created. /// The target Azure resource to connect via private link. /// Callback to configure the Azure Private Endpoint resource. -public class AzurePrivateEndpointResource( +public sealed class AzurePrivateEndpointResource( string name, AzureSubnetResource subnet, IAzurePrivateEndpointTarget target, diff --git a/src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressResource.cs b/src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressResource.cs index f7a607f170d..a111f0f81f2 100644 --- a/src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressResource.cs @@ -15,7 +15,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure Public IP Address resource. -public class AzurePublicIPAddressResource(string name, Action configureInfrastructure) +public sealed class AzurePublicIPAddressResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { /// diff --git a/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs b/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs index e72ce6143da..63acdc56f87 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs @@ -19,7 +19,7 @@ namespace Aspire.Hosting.Azure; /// /// [AspireExport] -public class AzureSubnetResource : Resource, IResourceWithParent +public sealed class AzureSubnetResource : Resource, IResourceWithParent { // Backing field holds either string or ParameterResource private readonly object _addressPrefix; diff --git a/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs b/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs index 0bdb25992b6..81e38bc0d06 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs @@ -13,7 +13,7 @@ namespace Aspire.Hosting.Azure; /// The name of the resource. /// Callback to configure the Azure Virtual Network resource. [AspireExport] -public class AzureVirtualNetworkResource(string name, Action configureInfrastructure) +public sealed class AzureVirtualNetworkResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { private const string DefaultAddressPrefix = "10.0.0.0/16"; diff --git a/src/Aspire.Hosting.Azure/AzureRoleAssignmentResource.cs b/src/Aspire.Hosting.Azure/AzureRoleAssignmentResource.cs index db0da95114b..fa14bc2273e 100644 --- a/src/Aspire.Hosting.Azure/AzureRoleAssignmentResource.cs +++ b/src/Aspire.Hosting.Azure/AzureRoleAssignmentResource.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using Aspire.Hosting.ApplicationModel; namespace Aspire.Hosting.Azure; @@ -19,6 +20,7 @@ namespace Aspire.Hosting.Azure; /// The Aspire resource that owns this set of role assignments, or for global role assignments granted to the deployment principal. /// The user-assigned managed identity whose principal receives the role assignments, or for global role assignments granted to the deployment principal. /// Callback to configure the Azure role assignment resources. +[Experimental("ASPIREAZURE003", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] public sealed class AzureRoleAssignmentResource( string name, AzureProvisioningResource targetAzureResource, diff --git a/src/Aspire.Hosting.Azure/RoleAssignmentResourceAnnotation.cs b/src/Aspire.Hosting.Azure/RoleAssignmentResourceAnnotation.cs index 932becea274..a1f521c235a 100644 --- a/src/Aspire.Hosting.Azure/RoleAssignmentResourceAnnotation.cs +++ b/src/Aspire.Hosting.Azure/RoleAssignmentResourceAnnotation.cs @@ -8,6 +8,7 @@ namespace Aspire.Hosting.Azure; /// /// An annotation that points to the resource that contains the role assignments for an Azure resource. /// +#pragma warning disable ASPIREAZURE003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. internal sealed class RoleAssignmentResourceAnnotation(AzureRoleAssignmentResource rolesResource) : IResourceAnnotation { /// @@ -15,3 +16,4 @@ internal sealed class RoleAssignmentResourceAnnotation(AzureRoleAssignmentResour /// public AzureRoleAssignmentResource RolesResource { get; } = rolesResource; } +#pragma warning restore ASPIREAZURE003 diff --git a/src/Aspire.Hosting.Blazor/Resources/BlazorWasmAppResource.cs b/src/Aspire.Hosting.Blazor/Resources/BlazorWasmAppResource.cs index a4210b92ba8..3a152f7927c 100644 --- a/src/Aspire.Hosting.Blazor/Resources/BlazorWasmAppResource.cs +++ b/src/Aspire.Hosting.Blazor/Resources/BlazorWasmAppResource.cs @@ -17,7 +17,7 @@ namespace Aspire.Hosting; /// [Experimental("ASPIREBLAZOR001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] [AspireExport] -public class BlazorWasmAppResource(string name, string projectPath) : Resource(name), IResourceWithEnvironment, IResourceWithParent +public sealed class BlazorWasmAppResource(string name, string projectPath) : Resource(name), IResourceWithEnvironment, IResourceWithParent { /// Fully-qualified path to the .csproj file. public string ProjectPath { get; } = projectPath; diff --git a/src/Aspire.Hosting.JavaScript/BunAppResource.cs b/src/Aspire.Hosting.JavaScript/BunAppResource.cs index 1c553fea982..866a751efb8 100644 --- a/src/Aspire.Hosting.JavaScript/BunAppResource.cs +++ b/src/Aspire.Hosting.JavaScript/BunAppResource.cs @@ -12,5 +12,5 @@ namespace Aspire.Hosting.JavaScript; /// The command to execute. /// The working directory to use for the command. [AspireExport(ExposeProperties = true)] -public class BunAppResource(string name, string command, string workingDirectory) +public sealed class BunAppResource(string name, string command, string workingDirectory) : JavaScriptAppResource(name, command, workingDirectory), IResourceWithServiceDiscovery, IContainerFilesDestinationResource; diff --git a/src/Aspire.Hosting.JavaScript/NextJsAppResource.cs b/src/Aspire.Hosting.JavaScript/NextJsAppResource.cs index 3c776a8a018..302f706df36 100644 --- a/src/Aspire.Hosting.JavaScript/NextJsAppResource.cs +++ b/src/Aspire.Hosting.JavaScript/NextJsAppResource.cs @@ -13,5 +13,5 @@ namespace Aspire.Hosting.JavaScript; /// The working directory from which the application command is executed. [AspireExport(ExposeProperties = true)] [Experimental("ASPIREJAVASCRIPT001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] -public class NextJsAppResource(string name, string command, string workingDirectory) +public sealed class NextJsAppResource(string name, string command, string workingDirectory) : JavaScriptAppResource(name, command, workingDirectory); diff --git a/src/Aspire.Hosting.JavaScript/ViteAppResource.cs b/src/Aspire.Hosting.JavaScript/ViteAppResource.cs index 627d08439ea..c8c26876993 100644 --- a/src/Aspire.Hosting.JavaScript/ViteAppResource.cs +++ b/src/Aspire.Hosting.JavaScript/ViteAppResource.cs @@ -10,7 +10,7 @@ namespace Aspire.Hosting.JavaScript; /// The command to execute the Vite application, such as the script or entry point. /// The working directory from which the Vite application command is executed. [AspireExport(ExposeProperties = true)] -public class ViteAppResource(string name, string command, string workingDirectory) +public sealed class ViteAppResource(string name, string command, string workingDirectory) : JavaScriptAppResource(name, command, workingDirectory) { /// diff --git a/src/Aspire.Hosting.Kubernetes/KubernetesHelmChartResource.cs b/src/Aspire.Hosting.Kubernetes/KubernetesHelmChartResource.cs index 3580a361116..2c31a784a40 100644 --- a/src/Aspire.Hosting.Kubernetes/KubernetesHelmChartResource.cs +++ b/src/Aspire.Hosting.Kubernetes/KubernetesHelmChartResource.cs @@ -41,7 +41,7 @@ namespace Aspire.Hosting.Kubernetes; /// /// [AspireExport] -public class KubernetesHelmChartResource : Resource, IResourceWithParent +public sealed class KubernetesHelmChartResource : Resource, IResourceWithParent { /// /// Initializes a new instance of . diff --git a/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs b/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs index 8761dd98dab..bc4aa50a32e 100644 --- a/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs +++ b/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs @@ -45,13 +45,13 @@ public class AllocatedEndpoint /// The port number of the endpoint. /// A string representing how to retrieve the target port of the instance. /// The binding mode of the endpoint. - /// The network identifier for the network associated with the endpoint. + /// The network identifier for the network associated with the endpoint. public AllocatedEndpoint( EndpointAnnotation endpoint, string address, int port, EndpointBindingMode bindingMode, string? targetPortExpression = null, - NetworkIdentifier? networkID = null + NetworkIdentifier? networkId = null ) { ArgumentNullException.ThrowIfNull(endpoint); @@ -63,7 +63,7 @@ public AllocatedEndpoint( BindingMode = bindingMode; Port = port; TargetPortExpression = targetPortExpression; - NetworkID = networkID ?? endpoint.DefaultNetworkID; + NetworkId = networkId ?? endpoint.DefaultNetworkId; } /// @@ -139,7 +139,7 @@ public AllocatedEndpoint(EndpointAnnotation endpoint, string address, int port, /// /// Gets the network identifier for the network associated with the instance. /// - public NetworkIdentifier NetworkID { get; private set; } + public NetworkIdentifier NetworkId { get; private set; } /// /// Returns a string representation of the allocated endpoint URI. diff --git a/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs b/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs index 3d1cbc9db7c..fec5c865dc5 100644 --- a/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs +++ b/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs @@ -25,7 +25,7 @@ public sealed class EndpointAnnotation : IResourceAnnotation private bool? _tlsEnabled; private bool _isProxied = true; private bool? _isExplicitlyProxied; - private readonly NetworkIdentifier _networkID; + private readonly NetworkIdentifier _networkId; /// /// Initializes a new instance of . @@ -97,7 +97,7 @@ bool isProxied /// Initializes a new instance of . /// /// Network protocol: TCP or UDP are supported today, others possibly in future. - /// The ID of the network that is the "default" network for the Endpoint. + /// The ID of the network that is the "default" network for the Endpoint. /// Clients connected to the same network can reach the endpoint without any routing or network address translation. /// If a service is URI-addressable, this is the URI scheme to use for constructing service URI. /// Transport that is being used (e.g. http, http2, http3 etc). @@ -108,7 +108,7 @@ bool isProxied /// Specifies if the endpoint will be proxied by DCP. Defaults to . public EndpointAnnotation( ProtocolType protocol, - NetworkIdentifier? networkID, + NetworkIdentifier? networkId, string? uriScheme = null, string? transport = null, [EndpointName] string? name = null, @@ -136,9 +136,9 @@ public EndpointAnnotation( _targetPort = targetPort; IsExternal = isExternal ?? false; IsExplicitlyProxied = isProxied; - _networkID = networkID ?? KnownNetworkIdentifiers.LocalhostNetwork; + _networkId = networkId ?? KnownNetworkIdentifiers.LocalhostNetwork; #pragma warning disable CS0618 // Type or member is obsolete - AllAllocatedEndpoints.TryAdd(_networkID, AllocatedEndpointSnapshot); + AllAllocatedEndpoints.TryAdd(_networkId, AllocatedEndpointSnapshot); #pragma warning restore CS0618 // Type or member is obsolete } @@ -146,7 +146,7 @@ public EndpointAnnotation( /// Initializes a new instance of . /// /// Network protocol: TCP or UDP are supported today, others possibly in future. - /// The ID of the network that is the "default" network for the Endpoint. + /// The ID of the network that is the "default" network for the Endpoint. /// Clients connected to the same network can reach the endpoint without any routing or network address translation. /// If a service is URI-addressable, this is the URI scheme to use for constructing service URI. /// Transport that is being used (e.g. http, http2, http3 etc). @@ -157,7 +157,7 @@ public EndpointAnnotation( /// Specifies if the endpoint will be proxied by DCP. public EndpointAnnotation( ProtocolType protocol, - NetworkIdentifier? networkID, + NetworkIdentifier? networkId, string? uriScheme, string? transport, [EndpointName] string? name, @@ -167,7 +167,7 @@ public EndpointAnnotation( bool isProxied ) : this( protocol, - networkID, + networkId, uriScheme, transport, name, @@ -334,7 +334,7 @@ public bool TlsEnabled /// /// Gets the ID of the network that is the "default" network for the Endpoint (the one the Endpoint is associated with and can be reached without routing or network address translation). /// - public NetworkIdentifier DefaultNetworkID => _networkID; + public NetworkIdentifier DefaultNetworkId => _networkId; /// /// Gets or sets the default for this Endpoint. @@ -364,9 +364,9 @@ public AllocatedEndpoint? AllocatedEndpoint } else { - if (_networkID != value.NetworkID) + if (_networkId != value.NetworkId) { - throw new InvalidOperationException($"The default AllocatedEndpoint's network ID must match the EndpointAnnotation network ID ('{_networkID}'). The attempted AllocatedEndpoint belongs to '{value.NetworkID}'."); + throw new InvalidOperationException($"The default AllocatedEndpoint's network ID must match the EndpointAnnotation network ID ('{_networkId}'). The attempted AllocatedEndpoint belongs to '{value.NetworkId}'."); } AllocatedEndpointSnapshot.SetValue(value); } @@ -390,9 +390,9 @@ public AllocatedEndpoint? AllocatedEndpoint /// Represents an AllocatedEndpoint snapshot associated with a specific network. /// /// AllocatedEndpoint snapshot -/// The ID of the network that is associated with the AllocatedEndpoint snapshot. -[DebuggerDisplay("NetworkID = {NetworkID}, Endpoint = {Snapshot}")] -public record class NetworkEndpointSnapshot(ValueSnapshot Snapshot, NetworkIdentifier NetworkID); +/// The ID of the network that is associated with the AllocatedEndpoint snapshot. +[DebuggerDisplay("NetworkId = {NetworkId}, Endpoint = {Snapshot}")] +public record class NetworkEndpointSnapshot(ValueSnapshot Snapshot, NetworkIdentifier NetworkId); /// /// Holds a list of for an Endpoint, providing thread-safe enumeration and addition. @@ -419,15 +419,15 @@ IEnumerator IEnumerable.GetEnumerator() /// Adds an AllocatedEndpoint snapshot for a specific network if one does not already exist. /// [Obsolete("This method is for internal use only and will be marked internal in a future Aspire release. Use AddOrUpdateAllocatedEndpoint instead.")] - public bool TryAdd(NetworkIdentifier networkID, ValueSnapshot snapshot) + public bool TryAdd(NetworkIdentifier networkId, ValueSnapshot snapshot) { lock (_snapshots) { - if (_snapshots.Any(s => s.NetworkID.Equals(networkID))) + if (_snapshots.Any(s => s.NetworkId.Equals(networkId))) { return false; } - _snapshots.Add(new NetworkEndpointSnapshot(snapshot, networkID)); + _snapshots.Add(new NetworkEndpointSnapshot(snapshot, networkId)); return true; } } @@ -435,33 +435,33 @@ public bool TryAdd(NetworkIdentifier networkID, ValueSnapshot /// /// Adds or updates an AllocatedEndpoint value associated with a specific network in the snapshot list. /// - public void AddOrUpdateAllocatedEndpoint(NetworkIdentifier networkID, AllocatedEndpoint endpoint) + public void AddOrUpdateAllocatedEndpoint(NetworkIdentifier networkId, AllocatedEndpoint endpoint) { - if (endpoint.NetworkID != networkID) + if (endpoint.NetworkId != networkId) { - throw new ArgumentException($"AllocatedEndpoint must use the same network as the {nameof(networkID)} parameter", nameof(endpoint)); + throw new ArgumentException($"AllocatedEndpoint must use the same network as the {nameof(networkId)} parameter", nameof(endpoint)); } - var nes = GetSnapshotFor(networkID); + var nes = GetSnapshotFor(networkId); nes.Snapshot.SetValue(endpoint); } /// /// Gets an AllocatedEndpoint for a given network ID, waiting for it to appear if it is not already present. /// - public Task GetAllocatedEndpointAsync(NetworkIdentifier networkID, CancellationToken cancellationToken = default) + public Task GetAllocatedEndpointAsync(NetworkIdentifier networkId, CancellationToken cancellationToken = default) { - var nes = GetSnapshotFor(networkID); + var nes = GetSnapshotFor(networkId); return nes.Snapshot.GetValueAsync(cancellationToken); } - private NetworkEndpointSnapshot GetSnapshotFor(NetworkIdentifier networkID) + private NetworkEndpointSnapshot GetSnapshotFor(NetworkIdentifier networkId) { lock (_snapshots) { - var nes = _snapshots.FirstOrDefault(s => s.NetworkID.Equals(networkID)); + var nes = _snapshots.FirstOrDefault(s => s.NetworkId.Equals(networkId)); if (nes is null) { - nes = new NetworkEndpointSnapshot(new ValueSnapshot(), networkID); + nes = new NetworkEndpointSnapshot(new ValueSnapshot(), networkId); _snapshots.Add(nes); } return nes; diff --git a/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs b/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs index 6ae84bf893d..4fa6ee2f383 100644 --- a/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs +++ b/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs @@ -16,7 +16,7 @@ public sealed class EndpointReference : IExpressionValue, IManifestExpressionPro // A reference to the endpoint annotation if it exists. private EndpointAnnotation? _endpointAnnotation; private bool? _isAllocated; - private readonly NetworkIdentifier? _contextNetworkID; + private readonly NetworkIdentifier? _contextNetworkId; /// /// Gets the endpoint annotation associated with the endpoint reference. @@ -129,7 +129,7 @@ private string BuildMissingEndpointMessage() /// The reference will be resolved in the context of this network, which may be different /// from the network associated with the default network of the referenced Endpoint. /// - public NetworkIdentifier? ContextNetworkID => _contextNetworkID; + public NetworkIdentifier? ContextNetworkId => _contextNetworkId; /// /// Gets the specified property expression of the endpoint. @@ -244,7 +244,7 @@ public ReferenceExpression GetTlsValue(ReferenceExpression enabledValue, Referen foreach (var nes in endpointAnnotation.AllAllocatedEndpoints) { - if (string.Equals(nes.NetworkID.Value, (_contextNetworkID ?? KnownNetworkIdentifiers.LocalhostNetwork).Value, StringComparisons.NetworkID)) + if (string.Equals(nes.NetworkId.Value, (_contextNetworkId ?? KnownNetworkIdentifiers.LocalhostNetwork).Value, StringComparisons.NetworkId)) { if (!nes.Snapshot.IsValueSet) { @@ -263,14 +263,14 @@ public ReferenceExpression GetTlsValue(ReferenceExpression enabledValue, Referen /// /// The resource with endpoints that owns the referenced endpoint. /// The endpoint annotation. - /// The ID of the network that serves as the context for the EndpointReference. + /// The ID of the network that serves as the context for the EndpointReference. /// /// Most Aspire resources are accessed in the context of the "localhost" network (host processes calling other host processes, /// or host processes calling container via mapped ports). If a is specified, the /// will always resolve in the context of that network. If the is null, the reference will attempt to resolve itself /// based on the context of the requesting resource. /// - public EndpointReference(IResourceWithEndpoints owner, EndpointAnnotation endpoint, NetworkIdentifier? contextNetworkID) + public EndpointReference(IResourceWithEndpoints owner, EndpointAnnotation endpoint, NetworkIdentifier? contextNetworkId) { ArgumentNullException.ThrowIfNull(owner); ArgumentNullException.ThrowIfNull(endpoint); @@ -278,7 +278,7 @@ public EndpointReference(IResourceWithEndpoints owner, EndpointAnnotation endpoi Resource = owner; EndpointName = endpoint.Name; _endpointAnnotation = endpoint; - _contextNetworkID = contextNetworkID; + _contextNetworkId = contextNetworkId; } /// @@ -295,21 +295,21 @@ public EndpointReference(IResourceWithEndpoints owner, EndpointAnnotation endpoi /// /// The resource with endpoints that owns the referenced endpoint. /// The name of the endpoint. - /// The ID of the network that serves as the context for the EndpointReference. + /// The ID of the network that serves as the context for the EndpointReference. /// /// Most Aspire resources are accessed in the context of the "localhost" network (host proceses calling other host processes, /// or host processes calling container via mapped ports). This is why EndpointReference assumes this /// context unless specified otherwise. However, for container-to-container, or container-to-host communication, /// you must specify a container network context for the EndpointReference to be resolved correctly. /// - public EndpointReference(IResourceWithEndpoints owner, string endpointName, NetworkIdentifier? contextNetworkID = null) + public EndpointReference(IResourceWithEndpoints owner, string endpointName, NetworkIdentifier? contextNetworkId = null) { ArgumentNullException.ThrowIfNull(owner); ArgumentNullException.ThrowIfNull(endpointName); Resource = owner; EndpointName = endpointName; - _contextNetworkID = contextNetworkID; + _contextNetworkId = contextNetworkId; } /// @@ -369,7 +369,7 @@ public class EndpointReferenceExpression(EndpointReference endpointReference, En { // If the EndpointReference was for a specific network context, then use that. Otherwise, use the network context from the ValueProviderContext. // This allows the EndpointReference to be resolved in the context of the caller's network if it was not explicitly set. - var networkContext = Endpoint.ContextNetworkID ?? context.GetNetworkIdentifier(); + var networkContext = Endpoint.ContextNetworkId ?? context.GetNetworkIdentifier(); return Property switch { diff --git a/src/Aspire.Hosting/ApplicationModel/EndpointReferenceAnnotation.cs b/src/Aspire.Hosting/ApplicationModel/EndpointReferenceAnnotation.cs index beb2c2fc1d3..ef3eae38416 100644 --- a/src/Aspire.Hosting/ApplicationModel/EndpointReferenceAnnotation.cs +++ b/src/Aspire.Hosting/ApplicationModel/EndpointReferenceAnnotation.cs @@ -24,10 +24,10 @@ public sealed class EndpointReferenceAnnotation(IResourceWithEndpoints resource) /// /// Gets the set of specific endpoint names that are referenced. When is , this set is ignored. /// - public HashSet EndpointNames { get; } = new(StringComparers.EndpointAnnotationName); + public ISet EndpointNames { get; } = new HashSet(StringComparers.EndpointAnnotationName); /// /// Gets or sets the network identifier used as context for resolving endpoint addresses. /// - public NetworkIdentifier ContextNetworkID { get; set; } = KnownNetworkIdentifiers.LocalhostNetwork; + public NetworkIdentifier ContextNetworkId { get; set; } = KnownNetworkIdentifiers.LocalhostNetwork; } diff --git a/src/Aspire.Hosting/ApplicationModel/HostUrl.cs b/src/Aspire.Hosting/ApplicationModel/HostUrl.cs index a77763f5f74..16261a56ddb 100644 --- a/src/Aspire.Hosting/ApplicationModel/HostUrl.cs +++ b/src/Aspire.Hosting/ApplicationModel/HostUrl.cs @@ -149,7 +149,7 @@ internal static bool TryGetLocalHostPort(string url, out int port) internal static bool MatchesHostPort(EndpointAnnotation endpoint, int port) { - return endpoint.DefaultNetworkID == KnownNetworkIdentifiers.LocalhostNetwork && endpoint.Port == port; + return endpoint.DefaultNetworkId == KnownNetworkIdentifiers.LocalhostNetwork && endpoint.Port == port; } private static bool IsLocalHost(string host) => host is "localhost" or "127.0.0.1" or "::1" or "[::1]"; diff --git a/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs b/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs index ee946810e99..5bdd507ae9a 100644 --- a/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs +++ b/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs @@ -635,7 +635,7 @@ internal static async ValueTask ProcessContainerRuntimeArgValues( "Waiting for endpoint '{EndpointName}' on resource '{ResourceName}' for the '{NetworkName}' network", endpointReference.EndpointName, endpointReference.Resource.Name, - endpointReference.ContextNetworkID?.Value); + endpointReference.ContextNetworkId?.Value); } else { @@ -721,14 +721,14 @@ public static IEnumerable GetEndpoints(this IResourceWithEndp /// Gets references to all endpoints for the specified resource. /// /// The which contains annotations. - /// The ID of the network that serves as the context context for the endpoint references. + /// The ID of the network that serves as the context context for the endpoint references. /// An enumeration of based on the annotations from the resources' collection. [AspireExportIgnore(Reason = "Network-specific endpoint enumeration is not part of the ATS surface.")] - public static IEnumerable GetEndpoints(this IResourceWithEndpoints resource, NetworkIdentifier contextNetworkID) + public static IEnumerable GetEndpoints(this IResourceWithEndpoints resource, NetworkIdentifier contextNetworkId) { if (TryGetAnnotationsOfType(resource, out var endpoints)) { - return endpoints.Select(e => new EndpointReference(resource, e, contextNetworkID)); + return endpoints.Select(e => new EndpointReference(resource, e, contextNetworkId)); } return []; @@ -761,10 +761,10 @@ public static EndpointReference GetEndpoint(this IResourceWithEndpoints resource /// /// The which contains annotations. /// The name of the endpoint. - /// The network ID of the network that provides the context for the returned + /// The network ID of the network that provides the context for the returned /// An object providing resolvable reference for the specified endpoint. [AspireExportIgnore(Reason = "Network-specific endpoint lookup is not part of the ATS surface.")] - public static EndpointReference GetEndpoint(this IResourceWithEndpoints resource, string endpointName, NetworkIdentifier contextNetworkID) + public static EndpointReference GetEndpoint(this IResourceWithEndpoints resource, string endpointName, NetworkIdentifier contextNetworkId) { var endpoint = resource.TryGetEndpoints(out var endpoints) ? @@ -772,11 +772,11 @@ public static EndpointReference GetEndpoint(this IResourceWithEndpoints resource null; if (endpoint is null) { - return new EndpointReference(resource, endpointName, contextNetworkID); + return new EndpointReference(resource, endpointName, contextNetworkId); } else { - return new EndpointReference(resource, endpoint, contextNetworkID); + return new EndpointReference(resource, endpoint, contextNetworkId); } } diff --git a/src/Aspire.Hosting/ApplicationModel/ResourceUrlsCallbackContext.cs b/src/Aspire.Hosting/ApplicationModel/ResourceUrlsCallbackContext.cs index 56c699365e3..b36abae189b 100644 --- a/src/Aspire.Hosting/ApplicationModel/ResourceUrlsCallbackContext.cs +++ b/src/Aspire.Hosting/ApplicationModel/ResourceUrlsCallbackContext.cs @@ -41,11 +41,11 @@ public class ResourceUrlsCallbackContext(DistributedApplicationExecutionContext /// If does not implement then returns null. /// /// The name of the endpoint. - /// The identifier of the network that serves as the context for the endpoint reference. - public EndpointReference? GetEndpoint(string name, NetworkIdentifier contextNetworkID) => + /// The identifier of the network that serves as the context for the endpoint reference. + public EndpointReference? GetEndpoint(string name, NetworkIdentifier contextNetworkId) => Resource switch { - IResourceWithEndpoints resourceWithEndpoints => resourceWithEndpoints.GetEndpoint(name, contextNetworkID), + IResourceWithEndpoints resourceWithEndpoints => resourceWithEndpoints.GetEndpoint(name, contextNetworkId), _ => null }; diff --git a/src/Aspire.Hosting/Dcp/DcpExecutor.cs b/src/Aspire.Hosting/Dcp/DcpExecutor.cs index d56d7607b48..a7499c4d31a 100644 --- a/src/Aspire.Hosting/Dcp/DcpExecutor.cs +++ b/src/Aspire.Hosting/Dcp/DcpExecutor.cs @@ -647,7 +647,7 @@ private void PrepareServices() foreach (var endpoint in endpoints) { - var (serviceName, isNew) = _nameGenerator.GetServiceName(sp.ModelResource, endpoint, endpoint.DefaultNetworkID); + var (serviceName, isNew) = _nameGenerator.GetServiceName(sp.ModelResource, endpoint, endpoint.DefaultNetworkId); if (!isNew) { _logger.LogWarning("Encountered the same service-endpoint combination more than once for {EndpointName} on resource {ResourceName} when creating default endpoint services. This should never happen.", endpoint.Name, sp.ModelResource.Name); diff --git a/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs b/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs index 6801c2b6768..3f7311301a6 100644 --- a/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs +++ b/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs @@ -228,7 +228,7 @@ private static void AddContainerNetworkAllocatedEndpoint(RenderedM targetPortExpression: $$$"""{{- portForServing "{{{sp.DcpResource.Metadata.Name}}}" -}}""", KnownNetworkIdentifiers.DefaultAspireContainerNetwork ); - sp.EndpointAnnotation.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(allocatedEndpoint.NetworkID, allocatedEndpoint); + sp.EndpointAnnotation.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(allocatedEndpoint.NetworkId, allocatedEndpoint); } private static void AddExecutableContainerNetworkAllocatedEndpoint(RenderedModelResource resource, ServiceWithModelResource sp, bool enableAspireContainerTunnel, string containerHostName) @@ -312,7 +312,7 @@ ts.Service is not null && throw new InvalidDataException($"The '{endpoint.Name}' on resource '{ts.ResourceName}' should have an associated DCP Service resource already set up"); } - var networkID = new NetworkIdentifier(ts.ContainerNetworkName!); + var networkId = new NetworkIdentifier(ts.ContainerNetworkName!); var address = string.IsNullOrEmpty(ts.TunnelInstanceName) ? containerHostName : KnownHostNames.DefaultContainerTunnelHostName; var port = (int)ts.Service!.AllocatedPort!; @@ -322,9 +322,9 @@ ts.Service is not null && port, EndpointBindingMode.SingleAddress, targetPortExpression: $$$"""{{- portForServing "{{{ts.Service.Metadata.Name}}}" -}}""", - networkID + networkId ); - endpoint.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(networkID, tunnelAllocatedEndpoint); + endpoint.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(networkId, tunnelAllocatedEndpoint); } } } diff --git a/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs b/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs index 67458641902..df32f89d3e6 100644 --- a/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs +++ b/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs @@ -252,7 +252,7 @@ private async Task ProcessResourceUrlCallbacks(IResource resource, CancellationT // will be "localhost" as that's a valid address for the .NET developer certificate. However, // if a service is bound to a specific IP address, the allocated endpoint will be that same IP // address. - var endpointReference = new EndpointReference(resourceWithEndpoints, endpoint, endpoint.DefaultNetworkID); + var endpointReference = new EndpointReference(resourceWithEndpoints, endpoint, endpoint.DefaultNetworkId); var url = new ResourceUrlAnnotation { Url = allocatedEndpoint.UriString, Endpoint = endpointReference }; // In the case that a service is bound to multiple addresses or a *.localhost address, we generate diff --git a/src/Aspire.Hosting/ResourceBuilderExtensions.cs b/src/Aspire.Hosting/ResourceBuilderExtensions.cs index 7eafe2ee5a0..d583bc09143 100644 --- a/src/Aspire.Hosting/ResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ResourceBuilderExtensions.cs @@ -812,7 +812,7 @@ private static Action CreateEndpointReferenceEnviron // Track per-scheme index for service discovery keys to handle multiple endpoints with the same scheme. var schemeIndexTracker = new Dictionary(StringComparer.OrdinalIgnoreCase); - foreach (var endpoint in annotation.Resource.GetEndpoints(annotation.ContextNetworkID)) + foreach (var endpoint in annotation.Resource.GetEndpoints(annotation.ContextNetworkId)) { if (specificEndpointName != null && !string.Equals(endpoint.EndpointName, specificEndpointName, StringComparison.OrdinalIgnoreCase)) { @@ -1407,7 +1407,7 @@ private static void ApplyEndpoints(this IResourceBuilder builder, IResourc endpointReferenceAnnotation = new EndpointReferenceAnnotation(resourceWithEndpoints); if (builder.Resource.IsContainer()) { - endpointReferenceAnnotation.ContextNetworkID = KnownNetworkIdentifiers.DefaultAspireContainerNetwork; + endpointReferenceAnnotation.ContextNetworkId = KnownNetworkIdentifiers.DefaultAspireContainerNetwork; } builder.WithAnnotation(endpointReferenceAnnotation); @@ -1482,7 +1482,7 @@ public static IResourceBuilder WithEndpoint(this IResourceBuilder build // can also be resolved in the context of container-to-container communication by using the target port // and the container name as the host. This is why we only set the context network to localhost, // for both container and non-container resources. - endpoint = new EndpointAnnotation(ProtocolType.Tcp, name: endpointName, networkID: KnownNetworkIdentifiers.LocalhostNetwork); + endpoint = new EndpointAnnotation(ProtocolType.Tcp, name: endpointName, networkId: KnownNetworkIdentifiers.LocalhostNetwork); callback(endpoint); builder.Resource.Annotations.Add(endpoint); } @@ -1612,7 +1612,7 @@ public static IResourceBuilder WithEndpoint(this IResourceBuilder build targetPort: targetPort, isExternal: isExternal, isProxied: isProxied, - networkID: KnownNetworkIdentifiers.LocalhostNetwork); + networkId: KnownNetworkIdentifiers.LocalhostNetwork); ConfigureEndpointEnvironmentVariable(builder, annotation, env); @@ -1885,15 +1885,15 @@ public static IResourceBuilder WithExternalHttpEndpoints(this IResourceBui /// The resource type. /// The the resource builder. /// The name of the endpoint. - /// The network context in which to resolve the endpoint. If null, localhost (loopback) network context will be used. + /// The network context in which to resolve the endpoint. If null, localhost (loopback) network context will be used. /// An that can be used to resolve the address of the endpoint after resource allocation has occurred. /// This method is not available in polyglot app hosts. Use the overload without NetworkIdentifier instead. [AspireExportIgnore(Reason = "NetworkIdentifier is not ATS-compatible.")] - public static EndpointReference GetEndpoint(this IResourceBuilder builder, [EndpointName] string name, NetworkIdentifier contextNetworkID) where T : IResourceWithEndpoints + public static EndpointReference GetEndpoint(this IResourceBuilder builder, [EndpointName] string name, NetworkIdentifier contextNetworkId) where T : IResourceWithEndpoints { ArgumentNullException.ThrowIfNull(builder); - return builder.Resource.GetEndpoint(name, contextNetworkID); + return builder.Resource.GetEndpoint(name, contextNetworkId); } /// @@ -4888,7 +4888,7 @@ public static IResourceBuilder WithHidden(this IResourceBuilder builder /// /// The resource type. /// The resource builder. - /// The completion exit code to treat as successful. Defaults to 0. + /// The completion exit code to treat as successful. /// The . /// /// This method is useful for one-off resources such as setup scripts, migrations, or build steps that should remain visible while running @@ -4896,7 +4896,7 @@ public static IResourceBuilder WithHidden(this IResourceBuilder builder /// Hidden resources can still be accessed directly by their name, by using Show hidden resources toggle in the dashboard or by using aspire describe --include-hidden from the CLI. /// [AspireExportIgnore(Reason = "Use ATS-friendly overload that supports a single exit code or multiple exit codes.")] - public static IResourceBuilder WithHiddenOnCompletion(this IResourceBuilder builder, int exitCode = 0) where T : IResource + public static IResourceBuilder WithHiddenOnCompletion(this IResourceBuilder builder, int exitCode) where T : IResource { ArgumentNullException.ThrowIfNull(builder); diff --git a/src/Shared/StringComparers.cs b/src/Shared/StringComparers.cs index 41ef4ed1f9a..f57c5542866 100644 --- a/src/Shared/StringComparers.cs +++ b/src/Shared/StringComparers.cs @@ -32,7 +32,7 @@ internal static class StringComparers public static StringComparer CommandName => StringComparer.Ordinal; public static StringComparer CliInputOrOutput => StringComparer.Ordinal; public static StringComparer InteractionInputName => StringComparer.OrdinalIgnoreCase; - public static StringComparer NetworkID => StringComparer.Ordinal; + public static StringComparer NetworkId => StringComparer.Ordinal; public static StringComparer NuGetPackageId => StringComparer.OrdinalIgnoreCase; public static StringComparer FullTextSearch => StringComparer.OrdinalIgnoreCase; public static StringComparer ChannelName => StringComparer.OrdinalIgnoreCase; @@ -65,7 +65,7 @@ internal static class StringComparisons public static StringComparison CommandName => StringComparison.Ordinal; public static StringComparison CliInputOrOutput => StringComparison.Ordinal; public static StringComparison InteractionInputName => StringComparison.OrdinalIgnoreCase; - public static StringComparison NetworkID => StringComparison.Ordinal; + public static StringComparison NetworkId => StringComparison.Ordinal; public static StringComparison NuGetPackageId => StringComparison.OrdinalIgnoreCase; public static StringComparison FullTextSearch => StringComparison.OrdinalIgnoreCase; public static StringComparison ChannelName => StringComparison.OrdinalIgnoreCase; diff --git a/tests/Aspire.Hosting.Azure.Tests/AzurePostgresExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzurePostgresExtensionsTests.cs index f0b79fa665d..01062779b87 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzurePostgresExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzurePostgresExtensionsTests.cs @@ -371,7 +371,7 @@ public async Task WithPostgresMcpOnAzureDatabaseRunAsContainerAddsMcpResource() c.WithEndpoint("tcp", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 5432); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "postgres.dev.internal", 5432, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "postgres.dev.internal", 5432, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); }); diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureUserAssignedIdentityTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureUserAssignedIdentityTests.cs index 0710044f720..d9124efcf24 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureUserAssignedIdentityTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureUserAssignedIdentityTests.cs @@ -1,4 +1,5 @@ #pragma warning disable ASPIREAZURE001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. +#pragma warning disable ASPIREAZURE003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. diff --git a/tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs b/tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs index 4bde4eea3ce..95fad316307 100644 --- a/tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#pragma warning disable ASPIREAZURE003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. + using System.Text.Json.Nodes; using Aspire.Hosting.ApplicationModel; using Aspire.Hosting.Utils; diff --git a/tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs b/tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs index 7d5c7449d1a..4bf0292ed27 100644 --- a/tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs +++ b/tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs @@ -564,7 +564,7 @@ public async Task WithReferenceDispatchesNodeAppServiceReference() .WithEndpoint("http", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 5031); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "nodeapp.dev.internal", 5031, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "nodeapp.dev.internal", 5031, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); var consumer = builder.AddContainer("consumer", "fake"); diff --git a/tests/Aspire.Hosting.Milvus.Tests/AddMilvusTests.cs b/tests/Aspire.Hosting.Milvus.Tests/AddMilvusTests.cs index 6eb39f1c5c0..723a0b01480 100644 --- a/tests/Aspire.Hosting.Milvus.Tests/AddMilvusTests.cs +++ b/tests/Aspire.Hosting.Milvus.Tests/AddMilvusTests.cs @@ -99,7 +99,7 @@ public async Task MilvusClientAppWithReferenceContainsConnectionStrings() .WithEndpoint("grpc", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", MilvusPortGrpc); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-milvus.dev.internal", MilvusPortGrpc, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-milvus.dev.internal", MilvusPortGrpc, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); var projectA = appBuilder.AddProject("projecta", o => o.ExcludeLaunchProfile = true) diff --git a/tests/Aspire.Hosting.PostgreSQL.Tests/AddPostgresTests.cs b/tests/Aspire.Hosting.PostgreSQL.Tests/AddPostgresTests.cs index fd64a45cb51..dcae09ba2b7 100644 --- a/tests/Aspire.Hosting.PostgreSQL.Tests/AddPostgresTests.cs +++ b/tests/Aspire.Hosting.PostgreSQL.Tests/AddPostgresTests.cs @@ -195,7 +195,7 @@ public async Task WithReferenceDispatchesPostgresDatabaseReference() .WithEndpoint("tcp", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 2000); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "postgres.dev.internal", 2000, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "postgres.dev.internal", 2000, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); var database = postgres.AddDatabase("db"); var consumer = appBuilder.AddContainer("consumer", "fake"); diff --git a/tests/Aspire.Hosting.PostgreSQL.Tests/PostgresMcpBuilderTests.cs b/tests/Aspire.Hosting.PostgreSQL.Tests/PostgresMcpBuilderTests.cs index 987bc894af0..c68d64b347d 100644 --- a/tests/Aspire.Hosting.PostgreSQL.Tests/PostgresMcpBuilderTests.cs +++ b/tests/Aspire.Hosting.PostgreSQL.Tests/PostgresMcpBuilderTests.cs @@ -78,7 +78,7 @@ public async Task WithPostgresMcpOnDatabaseSetsDatabaseUriEnvironmentVariable() .WithEndpoint("tcp", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 5432); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "postgres.dev.internal", 5432, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "postgres.dev.internal", 5432, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }) .AddDatabase("db") .WithPostgresMcp(); diff --git a/tests/Aspire.Hosting.Qdrant.Tests/AddQdrantTests.cs b/tests/Aspire.Hosting.Qdrant.Tests/AddQdrantTests.cs index f7d9bec19c2..0dd939873e8 100644 --- a/tests/Aspire.Hosting.Qdrant.Tests/AddQdrantTests.cs +++ b/tests/Aspire.Hosting.Qdrant.Tests/AddQdrantTests.cs @@ -179,12 +179,12 @@ public async Task QdrantClientAppWithReferenceContainsConnectionStrings() .WithEndpoint("grpc", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 6334); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-qdrant.dev.internal", 6334, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-qdrant.dev.internal", 6334, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }) .WithEndpoint("http", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 6333); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-qdrant.dev.internal", 6333, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-qdrant.dev.internal", 6333, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); var projectA = appBuilder.AddProject("projecta", o => o.ExcludeLaunchProfile = true) @@ -223,12 +223,12 @@ public async Task WithReferenceDispatchesQdrantReference() .WithEndpoint("grpc", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 6334); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-qdrant.dev.internal", 6334, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-qdrant.dev.internal", 6334, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }) .WithEndpoint("http", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 6333); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-qdrant.dev.internal", 6333, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "my-qdrant.dev.internal", 6333, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); var consumer = appBuilder.AddContainer("consumer", "fake"); diff --git a/tests/Aspire.Hosting.Redis.Tests/AddRedisTests.cs b/tests/Aspire.Hosting.Redis.Tests/AddRedisTests.cs index 6cfea90b8c9..22524207136 100644 --- a/tests/Aspire.Hosting.Redis.Tests/AddRedisTests.cs +++ b/tests/Aspire.Hosting.Redis.Tests/AddRedisTests.cs @@ -278,17 +278,17 @@ public async Task WithRedisInsightProducesCorrectEnvironmentVariables() redis1.WithEndpoint("tcp", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 5001); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "myredis1.dev.internal", 5001, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "myredis1.dev.internal", 5001, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); redis2.WithEndpoint("tcp", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 5002); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "myredis2.dev.internal", 5002, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "myredis2.dev.internal", 5002, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); redis3.WithEndpoint("tcp", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 5003); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "myredis3.dev.internal", 5003, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "myredis3.dev.internal", 5003, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); var redisInsight = Assert.Single(builder.Resources.OfType()); @@ -706,7 +706,7 @@ public async Task RedisInsightEnvironmentCallbackIsIdempotent() .WithEndpoint("tcp", e => { e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 6379); - e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "redis.dev.internal", 6379, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + e.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(e, "redis.dev.internal", 6379, EndpointBindingMode.SingleAddress, targetPortExpression: null, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }) .WithRedisInsight(); diff --git a/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs b/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs index 94017ba6d4b..2fe0937df00 100644 --- a/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs +++ b/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs @@ -3610,9 +3610,9 @@ async ValueTask AssertEndpoint(IResourceWithEndpoints resource, string name, Net var endpoint = resource.GetEndpoint(name).EndpointAnnotation; var allocatedEndpoints = endpoint.AllAllocatedEndpoints; - Assert.Contains(allocatedEndpoints, a => a.NetworkID == network); + Assert.Contains(allocatedEndpoints, a => a.NetworkId == network); - var allocatedEndpoint = await endpoint.AllAllocatedEndpoints.Single(x => x.NetworkID == network).Snapshot.GetValueAsync().DefaultTimeout(); + var allocatedEndpoint = await endpoint.AllAllocatedEndpoints.Single(x => x.NetworkId == network).Snapshot.GetValueAsync().DefaultTimeout(); Assert.Equal(endpoint, allocatedEndpoint.Endpoint); Assert.Equal(address, allocatedEndpoint.Address); diff --git a/tests/Aspire.Hosting.Tests/EndpointReferenceTests.cs b/tests/Aspire.Hosting.Tests/EndpointReferenceTests.cs index 2419809d65d..20ebd634d62 100644 --- a/tests/Aspire.Hosting.Tests/EndpointReferenceTests.cs +++ b/tests/Aspire.Hosting.Tests/EndpointReferenceTests.cs @@ -297,7 +297,7 @@ public void AllocatedEndpoint_ThrowsWhenNetworkIdDoesNotMatch() annotation, "localhost", 8080, EndpointBindingMode.SingleAddress, targetPortExpression: null, - networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork); + networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork); var ex = Assert.Throws(() => annotation.AllocatedEndpoint = mismatchedEndpoint); } diff --git a/tests/Aspire.Hosting.Tests/WithEnvironmentTests.cs b/tests/Aspire.Hosting.Tests/WithEnvironmentTests.cs index 086b5f427f1..068b4facd6d 100644 --- a/tests/Aspire.Hosting.Tests/WithEnvironmentTests.cs +++ b/tests/Aspire.Hosting.Tests/WithEnvironmentTests.cs @@ -230,7 +230,7 @@ public async Task EnvironmentVariableExpressions() { ep.AllocatedEndpoint = new AllocatedEndpoint(ep, "localhost", 17454); - ep.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(ep, "container1.dev.internal", 10005, EndpointBindingMode.SingleAddress, networkID: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); + ep.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(KnownNetworkIdentifiers.DefaultAspireContainerNetwork, new AllocatedEndpoint(ep, "container1.dev.internal", 10005, EndpointBindingMode.SingleAddress, networkId: KnownNetworkIdentifiers.DefaultAspireContainerNetwork)); }); var endpoint = container.GetEndpoint("primary"); From 63a06c7b3b0be733fcfec0e3647e3b5cc83e2b9d Mon Sep 17 00:00:00 2001 From: Jose Perez Rodriguez Date: Fri, 29 May 2026 21:27:13 -0700 Subject: [PATCH 2/2] Revert breaking API changes; bump baseline to 13.3.5 Reverts the subset of API changes from the previous commit that would be binary-breaking against 13.3.5, and bumps PackageValidationBaselineVersion from 13.2.2 to 13.3.5 so pack validation runs against the latest shipped release. Reverts (binary-breaking against 13.3.5): - AllocatedEndpoint.NetworkID (kept ctor param 'networkId' - not breaking) - EndpointAnnotation.DefaultNetworkID (kept ctor param 'networkId') - EndpointReference.ContextNetworkID (kept ctor param 'contextNetworkId') - NetworkEndpointSnapshot.NetworkID record positional param - Removed 'sealed' from 9 shipped resource classes: - NextJsAppResource, ViteAppResource - AzureNatGatewayResource, AzureNetworkSecurityGroupResource, AzureNetworkSecurityPerimeterResource, AzurePrivateEndpointResource, AzurePublicIPAddressResource, AzureSubnetResource, AzureVirtualNetworkResource Kept (not binary-breaking): - All constructor/method parameter renames (networkID->networkId, etc.) - EndpointReferenceAnnotation.ContextNetworkId (new in 13.4) - EndpointNames type change (HashSet -> ISet) - WithHiddenOnCompletion overload disambiguation - [Experimental("ASPIREAZURE003")] on AzureRoleAssignmentResource - 'sealed' on KubernetesHelmChartResource, BlazorWasmAppResource, BunAppResource (new in 13.4) Package validation: - Bumped PackageValidationBaselineVersion 13.2.2 -> 13.3.5 - Regenerated CompatibilitySuppressions.xml in 4 projects: most legacy entries against 13.2.2 are no longer needed because those APIs already shipped in 13.3.x. The remaining suppression is PublishAsNpmScript in Aspire.Hosting.JavaScript (documented removal from PR #17382). --- .../AzureNatGatewayResource.cs | 2 +- .../AzureNetworkSecurityGroupResource.cs | 2 +- .../AzureNetworkSecurityPerimeterResource.cs | 2 +- .../AzurePrivateEndpointResource.cs | 2 +- .../AzurePublicIPAddressResource.cs | 2 +- .../AzureSubnetResource.cs | 2 +- .../AzureVirtualNetworkResource.cs | 2 +- .../CompatibilitySuppressions.xml | 38 +------------------ .../CompatibilitySuppressions.xml | 17 +-------- .../CompatibilitySuppressions.xml | 24 +----------- .../CompatibilitySuppressions.xml | 11 ++++++ .../NextJsAppResource.cs | 2 +- .../ViteAppResource.cs | 2 +- .../ApplicationModel/AllocatedEndpoint.cs | 4 +- .../ApplicationModel/EndpointAnnotation.cs | 18 ++++----- .../ApplicationModel/EndpointReference.cs | 6 +-- .../ApplicationModel/HostUrl.cs | 2 +- .../ApplicationModel/ResourceExtensions.cs | 2 +- .../CompatibilitySuppressions.xml | 31 +-------------- src/Aspire.Hosting/Dcp/DcpExecutor.cs | 2 +- src/Aspire.Hosting/Dcp/DcpModelUtilities.cs | 2 +- .../Orchestrator/ApplicationOrchestrator.cs | 2 +- src/Directory.Build.props | 2 +- .../Dcp/DcpExecutorTests.cs | 4 +- 24 files changed, 46 insertions(+), 137 deletions(-) create mode 100644 src/Aspire.Hosting.JavaScript/CompatibilitySuppressions.xml diff --git a/src/Aspire.Hosting.Azure.Network/AzureNatGatewayResource.cs b/src/Aspire.Hosting.Azure.Network/AzureNatGatewayResource.cs index bf79f9c645d..143afa2cd19 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureNatGatewayResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureNatGatewayResource.cs @@ -16,7 +16,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure NAT Gateway resource. -public sealed class AzureNatGatewayResource(string name, Action configureInfrastructure) +public class AzureNatGatewayResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { /// diff --git a/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupResource.cs b/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupResource.cs index 1b1820fccba..be325f6b551 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupResource.cs @@ -16,7 +16,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure Network Security Group resource. -public sealed class AzureNetworkSecurityGroupResource(string name, Action configureInfrastructure) +public class AzureNetworkSecurityGroupResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { /// diff --git a/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityPerimeterResource.cs b/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityPerimeterResource.cs index 25fd26b39ca..b88b749ac57 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityPerimeterResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityPerimeterResource.cs @@ -22,7 +22,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure Network Security Perimeter resource. -public sealed class AzureNetworkSecurityPerimeterResource(string name, Action configureInfrastructure) +public class AzureNetworkSecurityPerimeterResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { /// diff --git a/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointResource.cs b/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointResource.cs index 598c3f5cfbb..66893918260 100644 --- a/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointResource.cs @@ -13,7 +13,7 @@ namespace Aspire.Hosting.Azure; /// The subnet where the private endpoint will be created. /// The target Azure resource to connect via private link. /// Callback to configure the Azure Private Endpoint resource. -public sealed class AzurePrivateEndpointResource( +public class AzurePrivateEndpointResource( string name, AzureSubnetResource subnet, IAzurePrivateEndpointTarget target, diff --git a/src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressResource.cs b/src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressResource.cs index a111f0f81f2..f7a607f170d 100644 --- a/src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressResource.cs @@ -15,7 +15,7 @@ namespace Aspire.Hosting.Azure; /// /// The name of the resource. /// Callback to configure the Azure Public IP Address resource. -public sealed class AzurePublicIPAddressResource(string name, Action configureInfrastructure) +public class AzurePublicIPAddressResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { /// diff --git a/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs b/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs index 63acdc56f87..e72ce6143da 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs @@ -19,7 +19,7 @@ namespace Aspire.Hosting.Azure; /// /// [AspireExport] -public sealed class AzureSubnetResource : Resource, IResourceWithParent +public class AzureSubnetResource : Resource, IResourceWithParent { // Backing field holds either string or ParameterResource private readonly object _addressPrefix; diff --git a/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs b/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs index 81e38bc0d06..0bdb25992b6 100644 --- a/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs +++ b/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs @@ -13,7 +13,7 @@ namespace Aspire.Hosting.Azure; /// The name of the resource. /// Callback to configure the Azure Virtual Network resource. [AspireExport] -public sealed class AzureVirtualNetworkResource(string name, Action configureInfrastructure) +public class AzureVirtualNetworkResource(string name, Action configureInfrastructure) : AzureProvisioningResource(name, configureInfrastructure) { private const string DefaultAddressPrefix = "10.0.0.0/16"; diff --git a/src/Aspire.Hosting.Azure.Network/CompatibilitySuppressions.xml b/src/Aspire.Hosting.Azure.Network/CompatibilitySuppressions.xml index 22fec018e7d..0497d618a92 100644 --- a/src/Aspire.Hosting.Azure.Network/CompatibilitySuppressions.xml +++ b/src/Aspire.Hosting.Azure.Network/CompatibilitySuppressions.xml @@ -1,39 +1,3 @@  - - - CP0002 - M:Aspire.Hosting.Azure.AzureNatGatewayResource.get_NameOutput - lib/net8.0/Aspire.Hosting.Azure.Network.dll - lib/net8.0/Aspire.Hosting.Azure.Network.dll - true - - - CP0002 - M:Aspire.Hosting.Azure.AzureNetworkSecurityGroupResource.get_NameOutput - lib/net8.0/Aspire.Hosting.Azure.Network.dll - lib/net8.0/Aspire.Hosting.Azure.Network.dll - true - - - CP0002 - M:Aspire.Hosting.Azure.AzurePrivateEndpointResource.get_NameOutput - lib/net8.0/Aspire.Hosting.Azure.Network.dll - lib/net8.0/Aspire.Hosting.Azure.Network.dll - true - - - CP0002 - M:Aspire.Hosting.Azure.AzurePublicIPAddressResource.get_NameOutput - lib/net8.0/Aspire.Hosting.Azure.Network.dll - lib/net8.0/Aspire.Hosting.Azure.Network.dll - true - - - CP0002 - M:Aspire.Hosting.Azure.AzureVirtualNetworkResource.get_NameOutput - lib/net8.0/Aspire.Hosting.Azure.Network.dll - lib/net8.0/Aspire.Hosting.Azure.Network.dll - true - - \ No newline at end of file + \ No newline at end of file diff --git a/src/Aspire.Hosting.Azure/CompatibilitySuppressions.xml b/src/Aspire.Hosting.Azure/CompatibilitySuppressions.xml index 78cdfa201ac..0497d618a92 100644 --- a/src/Aspire.Hosting.Azure/CompatibilitySuppressions.xml +++ b/src/Aspire.Hosting.Azure/CompatibilitySuppressions.xml @@ -1,18 +1,3 @@  - - - CP0002 - M:Aspire.Hosting.Azure.IAzurePrivateEndpointTarget.GetPrivateDnsZoneName - lib/net8.0/Aspire.Hosting.Azure.dll - lib/net8.0/Aspire.Hosting.Azure.dll - true - - - CP0006 - M:Aspire.Hosting.Azure.IAzurePrivateEndpointTarget.GetPrivateDnsZoneNames - lib/net8.0/Aspire.Hosting.Azure.dll - lib/net8.0/Aspire.Hosting.Azure.dll - true - - \ No newline at end of file + \ No newline at end of file diff --git a/src/Aspire.Hosting.Docker/CompatibilitySuppressions.xml b/src/Aspire.Hosting.Docker/CompatibilitySuppressions.xml index bfdd2c52258..0497d618a92 100644 --- a/src/Aspire.Hosting.Docker/CompatibilitySuppressions.xml +++ b/src/Aspire.Hosting.Docker/CompatibilitySuppressions.xml @@ -1,25 +1,3 @@  - - - CP0002 - M:Aspire.Hosting.Docker.Resources.ServiceNodes.Swarm.UpdateConfig.get_FailOnError - lib/net8.0/Aspire.Hosting.Docker.dll - lib/net8.0/Aspire.Hosting.Docker.dll - true - - - CP0002 - M:Aspire.Hosting.Docker.Resources.ServiceNodes.Swarm.UpdateConfig.get_Parallelism - lib/net8.0/Aspire.Hosting.Docker.dll - lib/net8.0/Aspire.Hosting.Docker.dll - true - - - CP0002 - M:Aspire.Hosting.Docker.Resources.ServiceNodes.Swarm.UpdateConfig.set_FailOnError(System.Nullable{System.Boolean}) - lib/net8.0/Aspire.Hosting.Docker.dll - lib/net8.0/Aspire.Hosting.Docker.dll - true - - \ No newline at end of file + \ No newline at end of file diff --git a/src/Aspire.Hosting.JavaScript/CompatibilitySuppressions.xml b/src/Aspire.Hosting.JavaScript/CompatibilitySuppressions.xml new file mode 100644 index 00000000000..bfacb9bb9b6 --- /dev/null +++ b/src/Aspire.Hosting.JavaScript/CompatibilitySuppressions.xml @@ -0,0 +1,11 @@ + + + + + CP0002 + M:Aspire.Hosting.JavaScriptHostingExtensions.PublishAsNpmScript``1(Aspire.Hosting.ApplicationModel.IResourceBuilder{``0},System.String,System.String) + lib/net8.0/Aspire.Hosting.JavaScript.dll + lib/net8.0/Aspire.Hosting.JavaScript.dll + true + + \ No newline at end of file diff --git a/src/Aspire.Hosting.JavaScript/NextJsAppResource.cs b/src/Aspire.Hosting.JavaScript/NextJsAppResource.cs index 302f706df36..3c776a8a018 100644 --- a/src/Aspire.Hosting.JavaScript/NextJsAppResource.cs +++ b/src/Aspire.Hosting.JavaScript/NextJsAppResource.cs @@ -13,5 +13,5 @@ namespace Aspire.Hosting.JavaScript; /// The working directory from which the application command is executed. [AspireExport(ExposeProperties = true)] [Experimental("ASPIREJAVASCRIPT001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] -public sealed class NextJsAppResource(string name, string command, string workingDirectory) +public class NextJsAppResource(string name, string command, string workingDirectory) : JavaScriptAppResource(name, command, workingDirectory); diff --git a/src/Aspire.Hosting.JavaScript/ViteAppResource.cs b/src/Aspire.Hosting.JavaScript/ViteAppResource.cs index c8c26876993..627d08439ea 100644 --- a/src/Aspire.Hosting.JavaScript/ViteAppResource.cs +++ b/src/Aspire.Hosting.JavaScript/ViteAppResource.cs @@ -10,7 +10,7 @@ namespace Aspire.Hosting.JavaScript; /// The command to execute the Vite application, such as the script or entry point. /// The working directory from which the Vite application command is executed. [AspireExport(ExposeProperties = true)] -public sealed class ViteAppResource(string name, string command, string workingDirectory) +public class ViteAppResource(string name, string command, string workingDirectory) : JavaScriptAppResource(name, command, workingDirectory) { /// diff --git a/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs b/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs index bc4aa50a32e..40e6c181cac 100644 --- a/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs +++ b/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs @@ -63,7 +63,7 @@ public AllocatedEndpoint( BindingMode = bindingMode; Port = port; TargetPortExpression = targetPortExpression; - NetworkId = networkId ?? endpoint.DefaultNetworkId; + NetworkID = networkId ?? endpoint.DefaultNetworkID; } /// @@ -139,7 +139,7 @@ public AllocatedEndpoint(EndpointAnnotation endpoint, string address, int port, /// /// Gets the network identifier for the network associated with the instance. /// - public NetworkIdentifier NetworkId { get; private set; } + public NetworkIdentifier NetworkID { get; private set; } /// /// Returns a string representation of the allocated endpoint URI. diff --git a/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs b/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs index fec5c865dc5..354499973c1 100644 --- a/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs +++ b/src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs @@ -334,7 +334,7 @@ public bool TlsEnabled /// /// Gets the ID of the network that is the "default" network for the Endpoint (the one the Endpoint is associated with and can be reached without routing or network address translation). /// - public NetworkIdentifier DefaultNetworkId => _networkId; + public NetworkIdentifier DefaultNetworkID => _networkId; /// /// Gets or sets the default for this Endpoint. @@ -364,9 +364,9 @@ public AllocatedEndpoint? AllocatedEndpoint } else { - if (_networkId != value.NetworkId) + if (_networkId != value.NetworkID) { - throw new InvalidOperationException($"The default AllocatedEndpoint's network ID must match the EndpointAnnotation network ID ('{_networkId}'). The attempted AllocatedEndpoint belongs to '{value.NetworkId}'."); + throw new InvalidOperationException($"The default AllocatedEndpoint's network ID must match the EndpointAnnotation network ID ('{_networkId}'). The attempted AllocatedEndpoint belongs to '{value.NetworkID}'."); } AllocatedEndpointSnapshot.SetValue(value); } @@ -390,9 +390,9 @@ public AllocatedEndpoint? AllocatedEndpoint /// Represents an AllocatedEndpoint snapshot associated with a specific network. /// /// AllocatedEndpoint snapshot -/// The ID of the network that is associated with the AllocatedEndpoint snapshot. -[DebuggerDisplay("NetworkId = {NetworkId}, Endpoint = {Snapshot}")] -public record class NetworkEndpointSnapshot(ValueSnapshot Snapshot, NetworkIdentifier NetworkId); +/// The ID of the network that is associated with the AllocatedEndpoint snapshot. +[DebuggerDisplay("NetworkID = {NetworkID}, Endpoint = {Snapshot}")] +public record class NetworkEndpointSnapshot(ValueSnapshot Snapshot, NetworkIdentifier NetworkID); /// /// Holds a list of for an Endpoint, providing thread-safe enumeration and addition. @@ -423,7 +423,7 @@ public bool TryAdd(NetworkIdentifier networkId, ValueSnapshot { lock (_snapshots) { - if (_snapshots.Any(s => s.NetworkId.Equals(networkId))) + if (_snapshots.Any(s => s.NetworkID.Equals(networkId))) { return false; } @@ -437,7 +437,7 @@ public bool TryAdd(NetworkIdentifier networkId, ValueSnapshot /// public void AddOrUpdateAllocatedEndpoint(NetworkIdentifier networkId, AllocatedEndpoint endpoint) { - if (endpoint.NetworkId != networkId) + if (endpoint.NetworkID != networkId) { throw new ArgumentException($"AllocatedEndpoint must use the same network as the {nameof(networkId)} parameter", nameof(endpoint)); } @@ -458,7 +458,7 @@ private NetworkEndpointSnapshot GetSnapshotFor(NetworkIdentifier networkId) { lock (_snapshots) { - var nes = _snapshots.FirstOrDefault(s => s.NetworkId.Equals(networkId)); + var nes = _snapshots.FirstOrDefault(s => s.NetworkID.Equals(networkId)); if (nes is null) { nes = new NetworkEndpointSnapshot(new ValueSnapshot(), networkId); diff --git a/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs b/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs index 4fa6ee2f383..38bf5581644 100644 --- a/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs +++ b/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs @@ -129,7 +129,7 @@ private string BuildMissingEndpointMessage() /// The reference will be resolved in the context of this network, which may be different /// from the network associated with the default network of the referenced Endpoint. /// - public NetworkIdentifier? ContextNetworkId => _contextNetworkId; + public NetworkIdentifier? ContextNetworkID => _contextNetworkId; /// /// Gets the specified property expression of the endpoint. @@ -244,7 +244,7 @@ public ReferenceExpression GetTlsValue(ReferenceExpression enabledValue, Referen foreach (var nes in endpointAnnotation.AllAllocatedEndpoints) { - if (string.Equals(nes.NetworkId.Value, (_contextNetworkId ?? KnownNetworkIdentifiers.LocalhostNetwork).Value, StringComparisons.NetworkId)) + if (string.Equals(nes.NetworkID.Value, (_contextNetworkId ?? KnownNetworkIdentifiers.LocalhostNetwork).Value, StringComparisons.NetworkId)) { if (!nes.Snapshot.IsValueSet) { @@ -369,7 +369,7 @@ public class EndpointReferenceExpression(EndpointReference endpointReference, En { // If the EndpointReference was for a specific network context, then use that. Otherwise, use the network context from the ValueProviderContext. // This allows the EndpointReference to be resolved in the context of the caller's network if it was not explicitly set. - var networkContext = Endpoint.ContextNetworkId ?? context.GetNetworkIdentifier(); + var networkContext = Endpoint.ContextNetworkID ?? context.GetNetworkIdentifier(); return Property switch { diff --git a/src/Aspire.Hosting/ApplicationModel/HostUrl.cs b/src/Aspire.Hosting/ApplicationModel/HostUrl.cs index 16261a56ddb..a77763f5f74 100644 --- a/src/Aspire.Hosting/ApplicationModel/HostUrl.cs +++ b/src/Aspire.Hosting/ApplicationModel/HostUrl.cs @@ -149,7 +149,7 @@ internal static bool TryGetLocalHostPort(string url, out int port) internal static bool MatchesHostPort(EndpointAnnotation endpoint, int port) { - return endpoint.DefaultNetworkId == KnownNetworkIdentifiers.LocalhostNetwork && endpoint.Port == port; + return endpoint.DefaultNetworkID == KnownNetworkIdentifiers.LocalhostNetwork && endpoint.Port == port; } private static bool IsLocalHost(string host) => host is "localhost" or "127.0.0.1" or "::1" or "[::1]"; diff --git a/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs b/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs index 5bdd507ae9a..8533253d008 100644 --- a/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs +++ b/src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs @@ -635,7 +635,7 @@ internal static async ValueTask ProcessContainerRuntimeArgValues( "Waiting for endpoint '{EndpointName}' on resource '{ResourceName}' for the '{NetworkName}' network", endpointReference.EndpointName, endpointReference.Resource.Name, - endpointReference.ContextNetworkId?.Value); + endpointReference.ContextNetworkID?.Value); } else { diff --git a/src/Aspire.Hosting/CompatibilitySuppressions.xml b/src/Aspire.Hosting/CompatibilitySuppressions.xml index 8ecd3607985..0497d618a92 100644 --- a/src/Aspire.Hosting/CompatibilitySuppressions.xml +++ b/src/Aspire.Hosting/CompatibilitySuppressions.xml @@ -1,32 +1,3 @@  - - - CP0006 - M:Aspire.Hosting.Pipelines.IDeploymentStateManager.ClearAllStateAsync(System.Threading.CancellationToken) - lib/net8.0/Aspire.Hosting.dll - lib/net8.0/Aspire.Hosting.dll - true - - - CP0006 - M:Aspire.Hosting.Publishing.IContainerRuntime.ComposeDownAsync(Aspire.Hosting.Publishing.ComposeOperationContext,System.Threading.CancellationToken) - lib/net8.0/Aspire.Hosting.dll - lib/net8.0/Aspire.Hosting.dll - true - - - CP0006 - M:Aspire.Hosting.Publishing.IContainerRuntime.ComposeListServicesAsync(Aspire.Hosting.Publishing.ComposeOperationContext,System.Threading.CancellationToken) - lib/net8.0/Aspire.Hosting.dll - lib/net8.0/Aspire.Hosting.dll - true - - - CP0006 - M:Aspire.Hosting.Publishing.IContainerRuntime.ComposeUpAsync(Aspire.Hosting.Publishing.ComposeOperationContext,System.Threading.CancellationToken) - lib/net8.0/Aspire.Hosting.dll - lib/net8.0/Aspire.Hosting.dll - true - - + \ No newline at end of file diff --git a/src/Aspire.Hosting/Dcp/DcpExecutor.cs b/src/Aspire.Hosting/Dcp/DcpExecutor.cs index a7499c4d31a..d56d7607b48 100644 --- a/src/Aspire.Hosting/Dcp/DcpExecutor.cs +++ b/src/Aspire.Hosting/Dcp/DcpExecutor.cs @@ -647,7 +647,7 @@ private void PrepareServices() foreach (var endpoint in endpoints) { - var (serviceName, isNew) = _nameGenerator.GetServiceName(sp.ModelResource, endpoint, endpoint.DefaultNetworkId); + var (serviceName, isNew) = _nameGenerator.GetServiceName(sp.ModelResource, endpoint, endpoint.DefaultNetworkID); if (!isNew) { _logger.LogWarning("Encountered the same service-endpoint combination more than once for {EndpointName} on resource {ResourceName} when creating default endpoint services. This should never happen.", endpoint.Name, sp.ModelResource.Name); diff --git a/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs b/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs index 3f7311301a6..f0f8171ffa0 100644 --- a/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs +++ b/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs @@ -228,7 +228,7 @@ private static void AddContainerNetworkAllocatedEndpoint(RenderedM targetPortExpression: $$$"""{{- portForServing "{{{sp.DcpResource.Metadata.Name}}}" -}}""", KnownNetworkIdentifiers.DefaultAspireContainerNetwork ); - sp.EndpointAnnotation.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(allocatedEndpoint.NetworkId, allocatedEndpoint); + sp.EndpointAnnotation.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(allocatedEndpoint.NetworkID, allocatedEndpoint); } private static void AddExecutableContainerNetworkAllocatedEndpoint(RenderedModelResource resource, ServiceWithModelResource sp, bool enableAspireContainerTunnel, string containerHostName) diff --git a/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs b/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs index df32f89d3e6..67458641902 100644 --- a/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs +++ b/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs @@ -252,7 +252,7 @@ private async Task ProcessResourceUrlCallbacks(IResource resource, CancellationT // will be "localhost" as that's a valid address for the .NET developer certificate. However, // if a service is bound to a specific IP address, the allocated endpoint will be that same IP // address. - var endpointReference = new EndpointReference(resourceWithEndpoints, endpoint, endpoint.DefaultNetworkId); + var endpointReference = new EndpointReference(resourceWithEndpoints, endpoint, endpoint.DefaultNetworkID); var url = new ResourceUrlAnnotation { Url = allocatedEndpoint.UriString, Endpoint = endpointReference }; // In the case that a service is bound to multiple addresses or a *.localhost address, we generate diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 95bf20eb97a..aee31ca53ab 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -4,7 +4,7 @@ true true - 13.2.2 + 13.3.5 diff --git a/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs b/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs index 2fe0937df00..94017ba6d4b 100644 --- a/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs +++ b/tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs @@ -3610,9 +3610,9 @@ async ValueTask AssertEndpoint(IResourceWithEndpoints resource, string name, Net var endpoint = resource.GetEndpoint(name).EndpointAnnotation; var allocatedEndpoints = endpoint.AllAllocatedEndpoints; - Assert.Contains(allocatedEndpoints, a => a.NetworkId == network); + Assert.Contains(allocatedEndpoints, a => a.NetworkID == network); - var allocatedEndpoint = await endpoint.AllAllocatedEndpoints.Single(x => x.NetworkId == network).Snapshot.GetValueAsync().DefaultTimeout(); + var allocatedEndpoint = await endpoint.AllAllocatedEndpoints.Single(x => x.NetworkID == network).Snapshot.GetValueAsync().DefaultTimeout(); Assert.Equal(endpoint, allocatedEndpoint.Endpoint); Assert.Equal(address, allocatedEndpoint.Address);