3 instantiations of ReferenceExpression
Aspire.Hosting (3)
1714 references to ReferenceExpression
Aspire.Hosting (181)
ApplicationModel\ReferenceExpression.cs (33)
18/// A <see cref="ReferenceExpression"/> operates in one of two modes:
37public static readonly ReferenceExpression Empty = Create(string.Empty, [], [], []);
43private readonly ReferenceExpression? _whenTrue;
44private readonly ReferenceExpression? _whenFalse;
60private ReferenceExpression(IValueProvider condition, string matchValue, ReferenceExpression whenTrue, ReferenceExpression whenFalse)
118public ReferenceExpression? WhenTrue => _whenTrue;
124public ReferenceExpression? WhenFalse => _whenFalse;
194var branch = string.Equals(conditionValue, _matchValue, StringComparison.OrdinalIgnoreCase) ? _whenTrue! : _whenFalse!;
230internal static ReferenceExpression Create(string format, IValueProvider[] valueProviders, string[] manifestExpressions, string?[] stringFormats)
236/// Creates a new instance of <see cref="ReferenceExpression"/> with the specified format and value providers.
239/// <returns>A new instance of <see cref="ReferenceExpression"/> with the specified format and value providers.</returns>
240public static ReferenceExpression Create(in ExpressionInterpolatedStringHandler handler)
246/// Creates a conditional <see cref="ReferenceExpression"/> that selects between two branch expressions
255/// <returns>A new conditional <see cref="ReferenceExpression"/>.</returns>
256public static ReferenceExpression CreateConditional(IValueProvider condition, string matchValue, ReferenceExpression whenTrue, ReferenceExpression whenFalse)
261private static string GenerateConditionalName(IValueProvider condition, string matchValue, ReferenceExpression whenTrue, ReferenceExpression whenFalse)
280private static string ComputeConditionalHash(IValueProvider condition, ReferenceExpression whenTrue, ReferenceExpression whenFalse, string matchValue)
387public void AppendFormatted(ReferenceExpression valueProvider, string format)
436internal readonly ReferenceExpression GetExpression() =>
482/// A builder for creating <see cref="ReferenceExpression"/> instances.
514_builder.Append(ReferenceExpression.ExpressionInterpolatedStringHandler.EscapeUnescapedBraces(value));
542_builder.Append(ReferenceExpression.ExpressionInterpolatedStringHandler.EscapeUnescapedBraces(value));
563public void AppendFormatted(ReferenceExpression valueProvider, string format)
618/// Builds the <see cref="ReferenceExpression"/>.
622public ReferenceExpression Build() =>
623ReferenceExpression.Create(_builder.ToString(), [.. _valueProviders], [.. _manifestExpressions], [.. _stringFormats]);
631/// <param name="builder">The builder that will be used to create the <see cref="ReferenceExpression"/>.</param>
672public void AppendFormatted(ReferenceExpression valueProvider, string format)
Dcp\ExecutableConfigurationResolver.cs (6)
72CertificateBundlePath = ReferenceExpression.Create($"{bundleOutputPath}"),
73CertificateDirectoriesPath = ReferenceExpression.Create($"{string.Join(Path.PathSeparator, directories)}"),
79CertificatePath = ReferenceExpression.Create($"{Path.Join(baseServerAuthOutputPath, $"{certificate.Thumbprint}.crt")}"),
80KeyPath = ReferenceExpression.Create($"{Path.Join(baseServerAuthOutputPath, $"{certificate.Thumbprint}.key")}"),
81CertificateWithKeyPath = ReferenceExpression.Create($"{Path.Join(baseServerAuthOutputPath, $"{certificate.Thumbprint}.pem")}"),
82PfxPath = ReferenceExpression.Create($"{Path.Join(baseServerAuthOutputPath, $"{certificate.Thumbprint}.pfx")}"),
ResourceBuilderExtensions.cs (18)
261typeof(ReferenceExpression),
277ReferenceExpression expression => builder.WithEnvironment(name, expression),
300public static IResourceBuilder<T> WithEnvironment<T>(this IResourceBuilder<T> builder, string name, in ReferenceExpression.ExpressionInterpolatedStringHandler value)
306var expression = value.GetExpression();
340public static IResourceBuilder<T> WithEnvironment<T>(this IResourceBuilder<T> builder, string name, ReferenceExpression value)
617public static IResourceBuilder<T> WithConnectionProperty<T>(this IResourceBuilder<T> builder, string name, ReferenceExpression value) where T : IResourceWithConnectionString
640return builder.WithAnnotation(new ConnectionPropertyAnnotation(name, ReferenceExpression.Create($"{value}")));
655[AspireUnion(typeof(string), typeof(ReferenceExpression))] object value) where T : IResourceWithConnectionString
664ReferenceExpression referenceExpression => builder.WithConnectionProperty(name, referenceExpression),
1481public static ReferenceExpression GetConnectionProperty(this IResourceWithConnectionString resource, string key)
1491return ReferenceExpression.Empty;
2385[AspireUnion(typeof(string), typeof(ReferenceExpression))] object url,
2395ReferenceExpression expression => builder.WithUrl(expression, displayText),
2414public static IResourceBuilder<T> WithUrl<T>(this IResourceBuilder<T> builder, in ReferenceExpression.ExpressionInterpolatedStringHandler url, string? displayText = null)
2419var expression = url.GetExpression();
2429/// <param name="url">A <see cref="ReferenceExpression"/> that will produce the URL.</param>
2437public static IResourceBuilder<T> WithUrl<T>(this IResourceBuilder<T> builder, ReferenceExpression url, string? displayText = null)
4913ReferenceExpression expression) where T : IResource
Aspire.Hosting.Azure (13)
Aspire.Hosting.Azure.AppConfiguration (3)
Aspire.Hosting.Azure.AppContainers (24)
Aspire.Hosting.Azure.ApplicationInsights (2)
Aspire.Hosting.Azure.AppService (24)
Aspire.Hosting.Azure.CognitiveServices (10)
Aspire.Hosting.Azure.ContainerRegistry (4)
Aspire.Hosting.Azure.CosmosDB (22)
Aspire.Hosting.Azure.EntraId (16)
Aspire.Hosting.Azure.EntraId.Tests (14)
Aspire.Hosting.Azure.EventHubs (18)
Aspire.Hosting.Azure.FrontDoor (5)
Aspire.Hosting.Azure.Functions (17)
Aspire.Hosting.Azure.KeyVault (11)
AzureKeyVaultResourceExtensions.cs (4)
267[AspireUnion(typeof(IResourceBuilder<ParameterResource>), typeof(ReferenceExpression))] object value,
278ReferenceExpression expression => builder.AddSecret(name, secretName, expression),
312public static IResourceBuilder<AzureKeyVaultSecretResource> AddSecret(this IResourceBuilder<AzureKeyVaultResource> builder, string name, ReferenceExpression value)
373public static IResourceBuilder<AzureKeyVaultSecretResource> AddSecret(this IResourceBuilder<AzureKeyVaultResource> builder, [ResourceName] string name, string secretName, ReferenceExpression value)
Aspire.Hosting.Azure.Kubernetes (6)
Aspire.Hosting.Azure.Kubernetes.Tests (9)
Aspire.Hosting.Azure.Kusto (11)
Aspire.Hosting.Azure.Kusto.Tests (2)
Aspire.Hosting.Azure.Network (15)
Aspire.Hosting.Azure.PostgreSQL (39)
Aspire.Hosting.Azure.Provisioning (1)
Aspire.Hosting.Azure.Provisioning.Tests (2)
Aspire.Hosting.Azure.Redis (26)
Aspire.Hosting.Azure.Sandboxes (14)
AzureSandboxContainerDeployment.cs (7)
1191when TryResolveEndpointReferenceValue(endpointReference, currentComputeEnvironment, out var endpointExpression):
1198when TryResolveEndpointReferenceValue(endpointReferenceExpression, currentComputeEnvironment, out var endpointExpression):
1204case ReferenceExpression referenceExpression:
1251ReferenceExpression expression)
1256var branch = string.Equals(condition, expression.MatchValue, StringComparison.OrdinalIgnoreCase)
1290internal static bool TryResolveEndpointReferenceValue(EndpointReference endpointReference, IComputeEnvironmentResource? currentComputeEnvironment, [NotNullWhen(true)] out ReferenceExpression? expression)
1295internal static bool TryResolveEndpointReferenceValue(EndpointReferenceExpression endpointReferenceExpression, IComputeEnvironmentResource? currentComputeEnvironment, [NotNullWhen(true)] out ReferenceExpression? expression)
Aspire.Hosting.Azure.Search (5)
Aspire.Hosting.Azure.ServiceBus (22)
Aspire.Hosting.Azure.SignalR (7)
Aspire.Hosting.Azure.Sql (26)
Aspire.Hosting.Azure.Storage (49)
Aspire.Hosting.Azure.Tests (128)
Aspire.Hosting.Azure.WebPubSub (20)
Aspire.Hosting.Blazor (2)
Aspire.Hosting.CodeGeneration.Go.Tests (3)
Aspire.Hosting.CodeGeneration.Java.Tests (3)
Aspire.Hosting.CodeGeneration.Python.Tests (3)
Aspire.Hosting.CodeGeneration.Rust.Tests (3)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (3)
Aspire.Hosting.Containers.Tests (2)
Aspire.Hosting.Docker (9)
Aspire.Hosting.Docker.Tests (15)
DockerComposePublisherTests.cs (14)
34var cs = builder.AddConnectionString("cs", ReferenceExpression.Create($"Url={param0}, Secret={param1}"));
116var connection = builder.AddConnectionString("my-db", ReferenceExpression.Create($"Host=example"));
1241var conditional = ReferenceExpression.CreateConditional(
1244ReferenceExpression.Create($",ssl=true"),
1245ReferenceExpression.Empty);
1249var conditionalFalse = ReferenceExpression.CreateConditional(
1252ReferenceExpression.Create($",ssl=true"),
1253ReferenceExpression.Create($",ssl=false"));
1283var conditional = ReferenceExpression.CreateConditional(
1286ReferenceExpression.Create($",ssl=true"),
1287ReferenceExpression.Create($",ssl=false"));
Aspire.Hosting.EntityFrameworkCore.Tests (6)
Aspire.Hosting.Foundry (63)
Toolbox\FoundryToolboxBuilderExtensions.cs (6)
235return builder.WithMcpTool(name, ReferenceExpression.Create($"{endpointUri.AbsoluteUri}"), options);
262return builder.WithMcpTool(name, ReferenceExpression.Create($"{endpoint}"), options);
271/// pointing at a resource endpoint, or a <see cref="ReferenceExpression"/> for cases where the
281[AspireUnion(typeof(string), typeof(EndpointReference), typeof(ReferenceExpression))] object endpoint,
293ReferenceExpression endpointExpression => builder.WithMcpTool(name, endpointExpression, options),
374ReferenceExpression endpointExpression,
Aspire.Hosting.Foundry.Tests (16)
Aspire.Hosting.Garnet (7)
Aspire.Hosting.Go.Tests (2)
Aspire.Hosting.Java (8)
Aspire.Hosting.Java.Tests (2)
Aspire.Hosting.JavaScript (5)
Aspire.Hosting.JavaScript.Tests (51)
AddViteAppTests.cs (37)
576CertificatePath = ReferenceExpression.Create($"cert.pem"),
577KeyPath = ReferenceExpression.Create($"key.pem"),
578CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
579PfxPath = ReferenceExpression.Create($"cert.pfx"),
598Assert.IsType<ReferenceExpression>(env["TLS_CONFIG_PFX"]);
636CertificatePath = ReferenceExpression.Create($"cert.pem"),
637KeyPath = ReferenceExpression.Create($"key.pem"),
638CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
639PfxPath = ReferenceExpression.Create($"cert.pfx"),
688CertificatePath = ReferenceExpression.Create($"cert.pem"),
689KeyPath = ReferenceExpression.Create($"key.pem"),
690CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
691PfxPath = ReferenceExpression.Create($"cert.pfx"),
734CertificatePath = ReferenceExpression.Create($"cert.pem"),
735KeyPath = ReferenceExpression.Create($"key.pem"),
736CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
737PfxPath = ReferenceExpression.Create($"cert.pfx"),
786CertificatePath = ReferenceExpression.Create($"cert.pem"),
787KeyPath = ReferenceExpression.Create($"key.pem"),
788CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
789PfxPath = ReferenceExpression.Create($"cert.pfx"),
845CertificatePath = ReferenceExpression.Create($"cert.pem"),
846KeyPath = ReferenceExpression.Create($"key.pem"),
847CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
848PfxPath = ReferenceExpression.Create($"cert.pfx"),
918CertificatePath = ReferenceExpression.Create($"cert.pem"),
919KeyPath = ReferenceExpression.Create($"key.pem"),
920CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
921PfxPath = ReferenceExpression.Create($"cert.pfx"),
1023CertificatePath = ReferenceExpression.Create($"cert.pem"),
1024KeyPath = ReferenceExpression.Create($"key.pem"),
1025CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
1026PfxPath = ReferenceExpression.Create($"cert.pfx"),
1114CertificatePath = ReferenceExpression.Create($"cert.pem"),
1115KeyPath = ReferenceExpression.Create($"key.pem"),
1116CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
1117PfxPath = ReferenceExpression.Create($"cert.pfx"),
Aspire.Hosting.Kafka (11)
Aspire.Hosting.Keycloak (3)
Aspire.Hosting.Kubernetes (116)
KubernetesEnvironmentResource.cs (17)
209internal sealed record TlsSecretRequest(ReferenceExpression SecretName, ReferenceExpression Hostname, IResource Owner);
401public ReferenceExpression GetHostAddressExpression(EndpointReference endpointReference)
405return ReferenceExpression.Create($"{resource.Name.ToServiceName()}");
593/// Resolves a <see cref="ReferenceExpression"/> at deploy time. Used by pipeline steps
598private static async Task<string> ResolveExpressionAtDeployTimeAsync(ReferenceExpression expression, CancellationToken cancellationToken)
611/// Resolves a <see cref="ReferenceExpression"/> for inclusion in a Kubernetes manifest
625private async Task<string> ResolveExpressionAsync(ReferenceExpression expression, string owningResourceName, CancellationToken cancellationToken)
709IEnumerable<ReferenceExpression> hostnames,
715foreach (var hostname in hostnames)
1330foreach (var host in gateway.Hostnames)
1345foreach (var host in ingress.Hostnames)
1375private static List<(KubernetesGatewayResource Gateway, ReferenceExpression SecretName)> CollectGatewaysNeedingFqdnDiscovery(
1379var results = new List<(KubernetesGatewayResource Gateway, ReferenceExpression SecretName)>();
1433List<(KubernetesGatewayResource Gateway, ReferenceExpression SecretName)> gatewaysNeedingDiscovery)
2208var seen = new HashSet<(ReferenceExpression SecretName, ReferenceExpression Hostname)>();
KubernetesResource.cs (7)
549ep, [kubernetesEnvironmentResource, kubernetesEnvironmentResource.OwningComputeEnvironment], out var crossExpr))
592epExpr, [kubernetesEnvironmentResource, kubernetesEnvironmentResource.OwningComputeEnvironment], out var crossExpr))
609if (value is ReferenceExpression expr)
624var branch = string.Equals(conditionStr, expr.MatchValue, StringComparison.OrdinalIgnoreCase)
663private async Task<object> BuildHelmConditional(KubernetesEnvironmentContext context, DistributedApplicationExecutionContext executionContext, ReferenceExpression expr, ParameterResource conditionParam, bool embedded)
712private void AllocateBranchParameters(ReferenceExpression branch)
878ReferenceExpression expr => expr.ValueProviders.Any(IsUnresolvedAtPublishTime),
Aspire.Hosting.Kubernetes.Tests (38)
KubernetesPublisherTests.cs (32)
78var cs = builder.AddConnectionString("cs", ReferenceExpression.Create($"Url={param0}, Secret={param1}"));
309var cs = builder.AddConnectionString("api-cs", ReferenceExpression.Create($"Url={param0}, Secret={param1}"));
310var csPlain = builder.AddConnectionString("api-cs2", ReferenceExpression.Create($"host.local:80"));
311var manualAlias = builder.AddConnectionString("manual-db", ReferenceExpression.Create($"unused"));
935var output = ReferenceExpression.Create($"{new TestValueProvider("provisioned-value")}");
937repositoryOutput ? ReferenceExpression.Create($"registry.example.com") : output,
1373context.EnvironmentVariables["FIRST"] = ReferenceExpression.CreateConditional(
1376ReferenceExpression.Create($"enabled"),
1377ReferenceExpression.Create($"disabled"));
1378context.EnvironmentVariables["SECOND"] = ReferenceExpression.CreateConditional(
1381ReferenceExpression.Create($"enabled"),
1382ReferenceExpression.Create($"disabled"));
1495var conditional = ReferenceExpression.CreateConditional(
1498ReferenceExpression.Create($",ssl=true"),
1499ReferenceExpression.Empty);
1503var conditionalFalse = ReferenceExpression.CreateConditional(
1506ReferenceExpression.Create($",ssl=true"),
1507ReferenceExpression.Create($",ssl=false"));
1560context.EnvironmentVariables["OPTIONS"] = ReferenceExpression.CreateConditional(
1563ReferenceExpression.Create($"user={user};password={password}"),
1564ReferenceExpression.Create($"user={user};disabled"));
1610var conditional = ReferenceExpression.CreateConditional(
1613ReferenceExpression.Create($",ssl=true"),
1614ReferenceExpression.Create($",ssl=false"));
1675var conditional = ReferenceExpression.CreateConditional(
1678ReferenceExpression.Create($"{tlsSuffix.Resource}"),
1679ReferenceExpression.Create($",ssl=false"));
Aspire.Hosting.Milvus (14)
Aspire.Hosting.MongoDB (33)
Aspire.Hosting.MongoDB.Tests (8)
Aspire.Hosting.MySql (18)
Aspire.Hosting.Nats (10)
Aspire.Hosting.OpenAI (11)
Aspire.Hosting.Oracle (18)
Aspire.Hosting.Orleans.Tests (2)
Aspire.Hosting.PostgreSQL (21)
Aspire.Hosting.Qdrant (15)
Aspire.Hosting.RabbitMQ (9)
Aspire.Hosting.Radius (33)
Publishing\RadiusInfrastructureBuilder.cs (19)
3011/// <see cref="ReferenceExpression"/>s, with nothing in the value identifying where they came
3035/// <c>GetConnectionProperties()</c> builds a fresh <see cref="ReferenceExpression"/>, and fresh
3052rawValue is not ReferenceExpression expression)
3204var expression = FindConnectionProperty(child, "databasename");
3209while (expression is { Format: "{0}", ValueProviders: [ReferenceExpression nested] })
3301while (expression.Format == "{0}" && expression.ValueProviders is [ReferenceExpression nested])
3311private static ReferenceExpression? FindConnectionProperty(IResourceWithConnectionString resource, string key)
4176case ReferenceExpression referenceExpression:
4259/// That form reaches environment resolution as a bare <see cref="ReferenceExpression"/>: the
4274private void RecordConnectionStringExpressionConsumption(ReferenceExpression expression, IResource owner)
4341/// Splices a composite <see cref="ReferenceExpression"/> into ordered parts by interleaving
4342/// its literal <see cref="ReferenceExpression.Format"/> chunks with the recursively-resolved
4345private async Task ResolveReferenceExpressionPartsAsync(ReferenceExpression expression, IResource owner, List<EnvPart> parts, IResource referencedResource, bool allowRecipeSubstitutions = true)
4414var branch = string.Equals(conditionValue, expression.MatchValue, StringComparison.OrdinalIgnoreCase)
4507/// so <see cref="ParameterResource"/>, <see cref="ReferenceExpression"/> and
4540case ReferenceExpression { IsConditional: true } conditional:
4545case ReferenceExpression referenceExpression:
4875/// Resolves a <see cref="ReferenceExpression"/> produced by the environment's endpoint
4879private static string ResolveHostExpression(ReferenceExpression expression) =>
Aspire.Hosting.Radius.Tests (58)
Publishing\BackingResourceValueResolutionTests.cs (51)
455.WithEnvironment("MODE_URL", ReferenceExpression.CreateConditional(
458ReferenceExpression.Create($"primary"),
459ReferenceExpression.Create($"secondary")))
484.WithEnvironment("MODE_URL", ReferenceExpression.CreateConditional(
487ReferenceExpression.Create($"primary"),
488ReferenceExpression.Create($"secondary")))));
503.WithEnvironment("MODE_URL", ReferenceExpression.CreateConditional(
506ReferenceExpression.Create($"primary"),
507ReferenceExpression.Create($"secondary")))
529.WithEnvironment("MODE_URL", ReferenceExpression.CreateConditional(
532ReferenceExpression.Create($"primary"),
533ReferenceExpression.Create($"secondary")));
540/// <see cref="ReferenceExpression"/> also carries <see cref="IManifestExpressionProvider"/>, so
551.WithEnvironment("MODE_URL", ReferenceExpression.CreateConditional(
552ReferenceExpression.Create($"{mode.Resource}"),
554ReferenceExpression.Create($"primary"),
555ReferenceExpression.Create($"secondary")));
563/// <see cref="ReferenceExpression"/> is still recognised as unknowable while publishing. Without
571.WithEnvironment("MODE_URL", ReferenceExpression.CreateConditional(
572ReferenceExpression.Create($"{new ThrowingDeploymentOutput(new InvalidOperationException("not deployed yet"))}"),
574ReferenceExpression.Create($"primary"),
575ReferenceExpression.Create($"secondary")))
597.WithEnvironment("MODE_URL", ReferenceExpression.CreateConditional(
600ReferenceExpression.Create($"primary"),
601ReferenceExpression.Create($"secondary")));
624.WithEnvironment("MODE_URL", ReferenceExpression.CreateConditional(
627ReferenceExpression.Create($"primary"),
628ReferenceExpression.Create($"secondary")));
645.WithEnvironment("MODE_URL", ReferenceExpression.CreateConditional(
646ReferenceExpression.CreateConditional(
649ReferenceExpression.Create($"primary"),
650ReferenceExpression.Create($"secondary")),
652ReferenceExpression.Create($"primary"),
653ReferenceExpression.Create($"secondary")))
996/// AppHost author can build the identical <see cref="ReferenceExpression"/> themselves, because
1013.WithEnvironment("ADMIN_PASSWORD", ReferenceExpression.Create($"{shared}"));
1090.WithEnvironment("DB_PRIMARY_PASSWORD", ReferenceExpression.Create($"{shared}"));
1194.WithEnvironment("PORT_URL", ReferenceExpression.Create($"tcp://cache:{port:uri}/"));
1214var conditional = ReferenceExpression.CreateConditional(
1217ReferenceExpression.Create($"primary-{cache.GetEndpoint("tcp").Property(EndpointProperty.Host)}"),
1218ReferenceExpression.Create($"secondary-fallback"));
1355.WithEnvironment("TOKEN", ReferenceExpression.Create($"{token:json}"));
1405new("username", ReferenceExpression.Create($"app")),
1406new("password", ReferenceExpression.Create($"{unresolvable}")),
1454ConnectionStringExpression = ReferenceExpression.Create($"{inner};{new ConnectionStringReference(this, false)}");
1457public ReferenceExpression ConnectionStringExpression { get; }
1504private sealed class PostgresServerResource(string name, KeyValuePair<string, ReferenceExpression>[] connectionProperties)
1507public ReferenceExpression ConnectionStringExpression => ReferenceExpression.Create($"Host=pg");
1509public IEnumerable<KeyValuePair<string, ReferenceExpression>> GetConnectionProperties() => connectionProperties;
Aspire.Hosting.Redis (9)
Aspire.Hosting.Redis.Tests (5)
Aspire.Hosting.RemoteHost.Tests (56)
AtsMarshallerTests.cs (40)
829var reference = Assert.Single(dto.AddressPrefixReferences);
1326public List<ReferenceExpression> AddressPrefixReferences { get; init; } = [];
1335var whenTrue = ReferenceExpression.Create($",ssl=true");
1336var whenFalse = ReferenceExpression.Empty;
1337var conditional = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
1354var whenTrue = ReferenceExpression.Create($",ssl=true");
1355var whenFalse = ReferenceExpression.Empty;
1356var conditional = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
1374var whenTrue = ReferenceExpression.Create($",ssl=true");
1375var whenFalse = ReferenceExpression.Empty;
1376var conditional = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
1381var retrievedConditional = Assert.IsType<ReferenceExpression>(retrieved);
1393var whenTrue = ReferenceExpression.Create($",ssl=true");
1394var whenFalse = ReferenceExpression.Empty;
1395var conditional = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
1400var retrievedConditional = Assert.IsType<ReferenceExpression>(retrieved);
1453var result = marshaller.UnmarshalFromJson(json, typeof(ReferenceExpression), context);
1454var cre = Assert.IsType<ReferenceExpression>(result);
1494var result = marshaller.UnmarshalFromJson(json, typeof(ReferenceExpression), context);
1495var cre = Assert.IsType<ReferenceExpression>(result);
1536var result = marshaller.UnmarshalFromJson(json, typeof(ReferenceExpression), context);
1537var cre = Assert.IsType<ReferenceExpression>(result);
1576marshaller.UnmarshalFromJson(json, typeof(ReferenceExpression), context));
ReferenceExpressionRefTests.cs (7)
118var expr = exprRef.ToReferenceExpression(handles, "test/cap", "param");
143var expr = exprRef.ToReferenceExpression(handles, "test/cap", "param");
180var expr = exprRef.ToReferenceExpression(handles, "test/cap", "param");
203var expr = exprRef.ToReferenceExpression(handles, "test/cap", "param");
224var expr = exprRef.ToReferenceExpression(handles, "test/cap", "param");
252public ReferenceExpression ToReferenceExpression(HandleRegistry handles, string capabilityId, string paramName)
274return (ReferenceExpression)exprRef!.ToReferenceExpression(handles, capabilityId, paramName);
Aspire.Hosting.Seq (7)
Aspire.Hosting.SqlServer (22)
Aspire.Hosting.Tests (237)
ComputeEnvironmentEndpointResolverTests.cs (8)
24endpoint.Property(EndpointProperty.Url), [currentEnv.Resource], out var expression);
45endpoint, [currentEnv.Resource], out var expression);
63endpoint.Property(EndpointProperty.Url), [currentEnv.Resource], out var expression);
82endpoint.Property(EndpointProperty.Url), [currentEnv.Resource], out var expression);
99endpoint.Property(EndpointProperty.Url), [currentEnv.Resource], out var expression);
122endpoint.Property(EndpointProperty.Url), [currentEnv.Resource], out var expression);
160public ReferenceExpression GetHostAddressExpression(EndpointReference endpointReference) =>
161ReferenceExpression.Create($"{endpointReference.Resource.Name}.example.com");
ConditionalReferenceExpressionTests.cs (35)
14var whenTrue = ReferenceExpression.Create($",ssl=true");
15var whenFalse = ReferenceExpression.Empty;
17var expr = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
27var whenTrue = ReferenceExpression.Create($",ssl=true");
28var whenFalse = ReferenceExpression.Empty;
30var expr = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
40var whenTrue = ReferenceExpression.Create($",ssl=true");
41var whenFalse = ReferenceExpression.Empty;
43var expr = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
53var whenTrue = ReferenceExpression.Create($",ssl=true");
54var whenFalse = ReferenceExpression.Empty;
56var conditional = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
61var expression = builder.Build();
82var whenTrue = ReferenceExpression.Create($",ssl=true");
83var whenFalse = ReferenceExpression.Empty;
85var expr = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
94var expr = ReferenceExpression.CreateConditional(new TestValueProvider(bool.TrueString), bool.TrueString, ReferenceExpression.Empty, ReferenceExpression.Empty);
ConnectionPropertiesExtensionsTests.cs (14)
16new KeyValuePair<string, ReferenceExpression>("Host", ReferenceExpression.Create($"resourceHost")),
17new KeyValuePair<string, ReferenceExpression>("Port", ReferenceExpression.Create($"8080")),
22new KeyValuePair<string, ReferenceExpression>("Port", ReferenceExpression.Create($"9090")),
23new KeyValuePair<string, ReferenceExpression>("Username", ReferenceExpression.Create($"user")),
39private sealed class TestResource(string name, IEnumerable<KeyValuePair<string, ReferenceExpression>> properties)
42private readonly IReadOnlyList<KeyValuePair<string, ReferenceExpression>> _properties = new List<KeyValuePair<string, ReferenceExpression>>(properties);
44public ReferenceExpression ConnectionStringExpression { get; } = ReferenceExpression.Create($"{name}.connectionString");
46IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties() => _properties;
ExpressionResolverTests.cs (17)
326public ReferenceExpression ConnectionStringExpression =>
327ReferenceExpression.Create($"{PrimaryEndpoint.Property(EndpointProperty.Url)}");
344Dictionary<string, ReferenceExpression> Expressions { get; }
351{ "TwoFullEndpoints", ReferenceExpression.Create($"Test1={Endpoint1.Property(EndpointProperty.Scheme)}://{Endpoint1.Property(EndpointProperty.IPV4Host)}:{Endpoint1.Property(EndpointProperty.Port)}/;Test2={Endpoint2.Property(EndpointProperty.Scheme)}://{Endpoint2.Property(EndpointProperty.Host)}:{Endpoint2.Property(EndpointProperty.Port)}/;") },
352{ "Url", ReferenceExpression.Create($"Url={Endpoint1.Property(EndpointProperty.Url)};") },
353{ "Url2", ReferenceExpression.Create($"Url={Endpoint1};") },
354{ "OnlyHost", ReferenceExpression.Create($"Host={Endpoint1.Property(EndpointProperty.Host)};") },
355{ "OnlyPort", ReferenceExpression.Create($"Port={Endpoint1.Property(EndpointProperty.Port)};") },
356{ "HostAndPort", ReferenceExpression.Create($"HostPort={Endpoint1.Property(EndpointProperty.HostAndPort)}") },
357{ "PortBeforeHost", ReferenceExpression.Create($"Port={Endpoint1.Property(EndpointProperty.Port)};Host={Endpoint1.Property(EndpointProperty.Host)};") },
358{ "FullAndPartial", ReferenceExpression.Create($"Test1={Endpoint1.Property(EndpointProperty.Scheme)}://{Endpoint1.Property(EndpointProperty.IPV4Host)}:{Endpoint1.Property(EndpointProperty.Port)}/;Test2={Endpoint2.Property(EndpointProperty.Scheme)}://localhost:{Endpoint2.Property(EndpointProperty.Port)}/;") },
359{ "Empty", ReferenceExpression.Empty },
360{ "String", ReferenceExpression.Create($"String") },
361{ "SecretParameter", ReferenceExpression.Create("SecretParameter", [new ParameterResource("SecretParameter", _ => "SecretParameter", secret: true)], [], [null]) },
362{ "NonSecretParameter", ReferenceExpression.Create("NonSecretParameter", [new ParameterResource("NonSecretParameter", _ => "NonSecretParameter", secret: false)], [], [null]) },
363{ "UrlEncodedHost", ReferenceExpression.Create($"Host={Endpoint3.Property(EndpointProperty.Host):uri};") },
367public ReferenceExpression ConnectionStringExpression => Expressions[_exprName];
ReferenceExpressionTests.cs (56)
19var refExpression = ReferenceExpression.Create($"Hello {input}");
37var expr = ReferenceExpression.Create($"{input}").ValueExpression;
48var expr = ReferenceExpression.Create($"{input}", [new HostUrl("test")], parameters, []).ValueExpression;
62var expr = ReferenceExpression.Create($"{input}", [new HostUrl("test")], [parameterValue], []).ValueExpression;
70var expr = ReferenceExpression.Create($"{s}").ValueExpression;
79var expr = ReferenceExpression.Create($"[{{\"api_uri\":\"{v}\"}}]");
90var expr = ReferenceExpression.Create($"[{{{{\"api_uri\":\"{v}\"}}}}]");
101var expr = ReferenceExpression.Create($"Text: {v:uri}");
136var refExpression = builder.Build();
149var refExpression = builder.Build();
162var refExpression = builder.Build();
174var expr = builder.Build();
207var whenTrue = ReferenceExpression.Create($"prefix-{param1}-{param2}");
208var whenFalse = ReferenceExpression.Create($"fallback-{param3}");
210var conditional = ReferenceExpression.CreateConditional(condition, "True", whenTrue, whenFalse);
224var whenTrue = ReferenceExpression.Create($"literal-a");
225var whenFalse = ReferenceExpression.Create($"literal-b");
227var conditional = ReferenceExpression.CreateConditional(condition, "True", whenTrue, whenFalse);
240var whenTrue = ReferenceExpression.Create($"{param1}");
241var whenFalse = ReferenceExpression.Create($"{param2}");
243var conditional = ReferenceExpression.CreateConditional(condition, "True", whenTrue, whenFalse);
263var innerConditional = ReferenceExpression.CreateConditional(
265ReferenceExpression.Create($"{param1}"),
266ReferenceExpression.Create($"{param2}"));
269var outerConditional = ReferenceExpression.CreateConditional(
272ReferenceExpression.Create($"{param3}"));
291var innerConditional = ReferenceExpression.CreateConditional(
293ReferenceExpression.Create($"{param1}"),
294ReferenceExpression.Create($"{param2}"));
296var outerConditional = ReferenceExpression.CreateConditional(
299ReferenceExpression.Create($"{param3}"));
320var conditional1 = ReferenceExpression.CreateConditional(
322ReferenceExpression.Create($"{param1}"),
323ReferenceExpression.Create($"{param2}"));
325var conditional2 = ReferenceExpression.CreateConditional(
327ReferenceExpression.Create($"{param1}"),
328ReferenceExpression.Create($"{param2}"));
Aspire.Hosting.Valkey (7)
Aspire.Hosting.Yarp.Tests (2)
ParameterEndToEnd.AppHost (1)
TestingAppHost1.AppHost (1)