3 instantiations of ReferenceExpression
Aspire.Hosting (3)
1656 references to ReferenceExpression
Aspire.Hosting (179)
ApplicationModel\ReferenceExpression.cs (31)
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.
561public void AppendFormatted(ReferenceExpression valueProvider, string format)
616/// Builds the <see cref="ReferenceExpression"/>.
620public ReferenceExpression Build() =>
621ReferenceExpression.Create(_builder.ToString(), [.. _valueProviders], [.. _manifestExpressions], [.. _stringFormats]);
629/// <param name="builder">The builder that will be used to create the <see cref="ReferenceExpression"/>.</param>
670public 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)
246typeof(ReferenceExpression),
262ReferenceExpression expression => builder.WithEnvironment(name, expression),
285public static IResourceBuilder<T> WithEnvironment<T>(this IResourceBuilder<T> builder, string name, in ReferenceExpression.ExpressionInterpolatedStringHandler value)
291var expression = value.GetExpression();
325public static IResourceBuilder<T> WithEnvironment<T>(this IResourceBuilder<T> builder, string name, ReferenceExpression value)
602public static IResourceBuilder<T> WithConnectionProperty<T>(this IResourceBuilder<T> builder, string name, ReferenceExpression value) where T : IResourceWithConnectionString
625return builder.WithAnnotation(new ConnectionPropertyAnnotation(name, ReferenceExpression.Create($"{value}")));
640[AspireUnion(typeof(string), typeof(ReferenceExpression))] object value) where T : IResourceWithConnectionString
649ReferenceExpression referenceExpression => builder.WithConnectionProperty(name, referenceExpression),
1231public static ReferenceExpression GetConnectionProperty(this IResourceWithConnectionString resource, string key)
1241return ReferenceExpression.Empty;
2135[AspireUnion(typeof(string), typeof(ReferenceExpression))] object url,
2145ReferenceExpression expression => builder.WithUrl(expression, displayText),
2164public static IResourceBuilder<T> WithUrl<T>(this IResourceBuilder<T> builder, in ReferenceExpression.ExpressionInterpolatedStringHandler url, string? displayText = null)
2169var expression = url.GetExpression();
2179/// <param name="url">A <see cref="ReferenceExpression"/> that will produce the URL.</param>
2187public static IResourceBuilder<T> WithUrl<T>(this IResourceBuilder<T> builder, ReferenceExpression url, string? displayText = null)
4626ReferenceExpression 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.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)
1194when TryResolveEndpointReferenceValue(endpointReference, currentComputeEnvironment, out var endpointExpression):
1201when TryResolveEndpointReferenceValue(endpointReferenceExpression, currentComputeEnvironment, out var endpointExpression):
1207case ReferenceExpression referenceExpression:
1254ReferenceExpression expression)
1259var branch = string.Equals(condition, expression.MatchValue, StringComparison.OrdinalIgnoreCase)
1293internal static bool TryResolveEndpointReferenceValue(EndpointReference endpointReference, IComputeEnvironmentResource? currentComputeEnvironment, [NotNullWhen(true)] out ReferenceExpression? expression)
1298internal 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 (122)
Aspire.Hosting.Azure.WebPubSub (14)
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)
233return builder.WithMcpTool(name, ReferenceExpression.Create($"{endpointUri.AbsoluteUri}"), options);
260return builder.WithMcpTool(name, ReferenceExpression.Create($"{endpoint}"), options);
269/// pointing at a resource endpoint, or a <see cref="ReferenceExpression"/> for cases where the
279[AspireUnion(typeof(string), typeof(EndpointReference), typeof(ReferenceExpression))] object endpoint,
291ReferenceExpression endpointExpression => builder.WithMcpTool(name, endpointExpression, options),
372ReferenceExpression endpointExpression,
Aspire.Hosting.Foundry.Tests (16)
Aspire.Hosting.Garnet (7)
Aspire.Hosting.Java (8)
Aspire.Hosting.Java.Tests (2)
Aspire.Hosting.JavaScript (5)
Aspire.Hosting.JavaScript.Tests (51)
AddViteAppTests.cs (37)
578CertificatePath = ReferenceExpression.Create($"cert.pem"),
579KeyPath = ReferenceExpression.Create($"key.pem"),
580CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
581PfxPath = ReferenceExpression.Create($"cert.pfx"),
600Assert.IsType<ReferenceExpression>(env["TLS_CONFIG_PFX"]);
638CertificatePath = ReferenceExpression.Create($"cert.pem"),
639KeyPath = ReferenceExpression.Create($"key.pem"),
640CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
641PfxPath = ReferenceExpression.Create($"cert.pfx"),
690CertificatePath = ReferenceExpression.Create($"cert.pem"),
691KeyPath = ReferenceExpression.Create($"key.pem"),
692CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
693PfxPath = ReferenceExpression.Create($"cert.pfx"),
736CertificatePath = ReferenceExpression.Create($"cert.pem"),
737KeyPath = ReferenceExpression.Create($"key.pem"),
738CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
739PfxPath = ReferenceExpression.Create($"cert.pfx"),
788CertificatePath = ReferenceExpression.Create($"cert.pem"),
789KeyPath = ReferenceExpression.Create($"key.pem"),
790CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
791PfxPath = ReferenceExpression.Create($"cert.pfx"),
847CertificatePath = ReferenceExpression.Create($"cert.pem"),
848KeyPath = ReferenceExpression.Create($"key.pem"),
849CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
850PfxPath = ReferenceExpression.Create($"cert.pfx"),
920CertificatePath = ReferenceExpression.Create($"cert.pem"),
921KeyPath = ReferenceExpression.Create($"key.pem"),
922CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
923PfxPath = ReferenceExpression.Create($"cert.pfx"),
1025CertificatePath = ReferenceExpression.Create($"cert.pem"),
1026KeyPath = ReferenceExpression.Create($"key.pem"),
1027CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
1028PfxPath = ReferenceExpression.Create($"cert.pfx"),
1116CertificatePath = ReferenceExpression.Create($"cert.pem"),
1117KeyPath = ReferenceExpression.Create($"key.pem"),
1118CertificateWithKeyPath = ReferenceExpression.Create($"cert-with-key.pem"),
1119PfxPath = ReferenceExpression.Create($"cert.pfx"),
Aspire.Hosting.Kafka (11)
Aspire.Hosting.Keycloak (3)
Aspire.Hosting.Kubernetes (112)
KubernetesEnvironmentResource.cs (17)
210internal sealed record TlsSecretRequest(ReferenceExpression SecretName, ReferenceExpression Hostname, IResource Owner);
402public ReferenceExpression GetHostAddressExpression(EndpointReference endpointReference)
406return ReferenceExpression.Create($"{resource.Name.ToServiceName()}");
594/// Resolves a <see cref="ReferenceExpression"/> at deploy time. Used by pipeline steps
599private static async Task<string> ResolveExpressionAtDeployTimeAsync(ReferenceExpression expression, CancellationToken cancellationToken)
612/// Resolves a <see cref="ReferenceExpression"/> for inclusion in a Kubernetes manifest
626private async Task<string> ResolveExpressionAsync(ReferenceExpression expression, string owningResourceName, CancellationToken cancellationToken)
710IEnumerable<ReferenceExpression> hostnames,
716foreach (var hostname in hostnames)
1331foreach (var host in gateway.Hostnames)
1346foreach (var host in ingress.Hostnames)
1376private static List<(KubernetesGatewayResource Gateway, ReferenceExpression SecretName)> CollectGatewaysNeedingFqdnDiscovery(
1380var results = new List<(KubernetesGatewayResource Gateway, ReferenceExpression SecretName)>();
1434List<(KubernetesGatewayResource Gateway, ReferenceExpression SecretName)> gatewaysNeedingDiscovery)
2209var seen = new HashSet<(ReferenceExpression SecretName, ReferenceExpression Hostname)>();
KubernetesResource.cs (7)
554ep, [kubernetesEnvironmentResource, kubernetesEnvironmentResource.OwningComputeEnvironment], out var crossExpr))
597epExpr, [kubernetesEnvironmentResource, kubernetesEnvironmentResource.OwningComputeEnvironment], out var crossExpr))
614if (value is ReferenceExpression expr)
629var branch = string.Equals(conditionStr, expr.MatchValue, StringComparison.OrdinalIgnoreCase)
668private async Task<object> BuildHelmConditional(KubernetesEnvironmentContext context, DistributedApplicationExecutionContext executionContext, ReferenceExpression expr, ParameterResource conditionParam, bool embedded)
717private void AllocateBranchParameters(ReferenceExpression branch)
883ReferenceExpression expr => expr.ValueProviders.Any(IsUnresolvedAtPublishTime),
Aspire.Hosting.Kubernetes.Tests (35)
KubernetesPublisherTests.cs (29)
31var cs = builder.AddConnectionString("cs", ReferenceExpression.Create($"Url={param0}, Secret={param1}"));
261var cs = builder.AddConnectionString("api-cs", ReferenceExpression.Create($"Url={param0}, Secret={param1}"));
262var csPlain = builder.AddConnectionString("api-cs2", ReferenceExpression.Create($"host.local:80"));
263var manualAlias = builder.AddConnectionString("manual-db", ReferenceExpression.Create($"unused"));
1150context.EnvironmentVariables["FIRST"] = ReferenceExpression.CreateConditional(
1153ReferenceExpression.Create($"enabled"),
1154ReferenceExpression.Create($"disabled"));
1155context.EnvironmentVariables["SECOND"] = ReferenceExpression.CreateConditional(
1158ReferenceExpression.Create($"enabled"),
1159ReferenceExpression.Create($"disabled"));
1272var conditional = ReferenceExpression.CreateConditional(
1275ReferenceExpression.Create($",ssl=true"),
1276ReferenceExpression.Empty);
1280var conditionalFalse = ReferenceExpression.CreateConditional(
1283ReferenceExpression.Create($",ssl=true"),
1284ReferenceExpression.Create($",ssl=false"));
1337context.EnvironmentVariables["OPTIONS"] = ReferenceExpression.CreateConditional(
1340ReferenceExpression.Create($"user={user};password={password}"),
1341ReferenceExpression.Create($"user={user};disabled"));
1387var conditional = ReferenceExpression.CreateConditional(
1390ReferenceExpression.Create($",ssl=true"),
1391ReferenceExpression.Create($",ssl=false"));
1452var conditional = ReferenceExpression.CreateConditional(
1455ReferenceExpression.Create($"{tlsSuffix.Resource}"),
1456ReferenceExpression.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 (55)
AtsMarshallerTests.cs (40)
829var reference = Assert.Single(dto.AddressPrefixReferences);
1297public List<ReferenceExpression> AddressPrefixReferences { get; init; } = [];
1306var whenTrue = ReferenceExpression.Create($",ssl=true");
1307var whenFalse = ReferenceExpression.Empty;
1308var conditional = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
1325var whenTrue = ReferenceExpression.Create($",ssl=true");
1326var whenFalse = ReferenceExpression.Empty;
1327var conditional = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
1345var whenTrue = ReferenceExpression.Create($",ssl=true");
1346var whenFalse = ReferenceExpression.Empty;
1347var conditional = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
1352var retrievedConditional = Assert.IsType<ReferenceExpression>(retrieved);
1364var whenTrue = ReferenceExpression.Create($",ssl=true");
1365var whenFalse = ReferenceExpression.Empty;
1366var conditional = ReferenceExpression.CreateConditional(condition, bool.TrueString, whenTrue, whenFalse);
1371var retrievedConditional = Assert.IsType<ReferenceExpression>(retrieved);
1424var result = marshaller.UnmarshalFromJson(json, typeof(ReferenceExpression), context);
1425var cre = Assert.IsType<ReferenceExpression>(result);
1465var result = marshaller.UnmarshalFromJson(json, typeof(ReferenceExpression), context);
1466var cre = Assert.IsType<ReferenceExpression>(result);
1507var result = marshaller.UnmarshalFromJson(json, typeof(ReferenceExpression), context);
1508var cre = Assert.IsType<ReferenceExpression>(result);
1547marshaller.UnmarshalFromJson(json, typeof(ReferenceExpression), context));
ReferenceExpressionRefTests.cs (6)
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");
233public ReferenceExpression ToReferenceExpression(HandleRegistry handles, string capabilityId, string paramName)
255return (ReferenceExpression)exprRef!.ToReferenceExpression(handles, capabilityId, paramName);
Aspire.Hosting.Seq (7)
Aspire.Hosting.SqlServer (22)
Aspire.Hosting.Tests (233)
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 (52)
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}");
143var whenTrue = ReferenceExpression.Create($"prefix-{param1}-{param2}");
144var whenFalse = ReferenceExpression.Create($"fallback-{param3}");
146var conditional = ReferenceExpression.CreateConditional(condition, "True", whenTrue, whenFalse);
160var whenTrue = ReferenceExpression.Create($"literal-a");
161var whenFalse = ReferenceExpression.Create($"literal-b");
163var conditional = ReferenceExpression.CreateConditional(condition, "True", whenTrue, whenFalse);
176var whenTrue = ReferenceExpression.Create($"{param1}");
177var whenFalse = ReferenceExpression.Create($"{param2}");
179var conditional = ReferenceExpression.CreateConditional(condition, "True", whenTrue, whenFalse);
199var innerConditional = ReferenceExpression.CreateConditional(
201ReferenceExpression.Create($"{param1}"),
202ReferenceExpression.Create($"{param2}"));
205var outerConditional = ReferenceExpression.CreateConditional(
208ReferenceExpression.Create($"{param3}"));
227var innerConditional = ReferenceExpression.CreateConditional(
229ReferenceExpression.Create($"{param1}"),
230ReferenceExpression.Create($"{param2}"));
232var outerConditional = ReferenceExpression.CreateConditional(
235ReferenceExpression.Create($"{param3}"));
256var conditional1 = ReferenceExpression.CreateConditional(
258ReferenceExpression.Create($"{param1}"),
259ReferenceExpression.Create($"{param2}"));
261var conditional2 = ReferenceExpression.CreateConditional(
263ReferenceExpression.Create($"{param1}"),
264ReferenceExpression.Create($"{param2}"));
Aspire.Hosting.Valkey (7)
Aspire.Hosting.Yarp.Tests (2)
ParameterEndToEnd.AppHost (1)
TestingAppHost1.AppHost (1)