Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 22, 2025

Overview

This PR implements support for the new connection string formatting introduced in dotnet/aspire#11938. All CommunityToolkit resources that implement IResourceWithConnectionString now expose connection metadata as individual properties through the new GetConnectionProperties() method.

Changes

The upstream Aspire PR introduces a new structure for handling connection strings, where resources expose connection information as a collection of key-value pairs rather than just a constructed connection string. This enables:

  • Fine-grained access to individual connection components (host, port, username, etc.)
  • Environment variable splatting with configurable prefixes
  • Better integration with different client libraries that may need specific connection formats

Implementation Details

For each resource implementing IResourceWithConnectionString, this PR adds:

  1. Connection property accessors - Host, Port, and other relevant properties exposed as EndpointReferenceExpression
  2. URI expressions - A UriExpression property that provides URI-formatted connection strings
  3. GetConnectionProperties() implementation - Returns connection metadata as key-value pairs

Example for server resources:

public EndpointReferenceExpression Host => PrimaryEndpoint.Property(EndpointProperty.Host);
public EndpointReferenceExpression Port => PrimaryEndpoint.Property(EndpointProperty.Port);
public ReferenceExpression UriExpression => ReferenceExpression.Create($"http://{Host}:{Port}");

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties()
{
    yield return new("Host", ReferenceExpression.Create($"{Host}"));
    yield return new("Port", ReferenceExpression.Create($"{Port}"));
    yield return new("Uri", UriExpression);
}

For child resources (databases, namespaces, models), the implementation uses CombineProperties() to merge parent connection properties with child-specific ones:

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties() =>
    Parent.CombineProperties([
        new("Database", ReferenceExpression.Create($"{DatabaseName}"))
    ]);

Updated Resources

The following integration packages have been updated:

  • ActiveMQ - ActiveMQServerResourceBase (base class for Classic and Artemis)
  • EventStore - EventStoreResource
  • Flagd - FlagdResource
  • GoFeatureFlag - GoFeatureFlagResource
  • MailPit - MailPitContainerResource
  • Meilisearch - MeilisearchResource
  • Ollama - OllamaResource, OllamaModelResource, OpenWebUIResource
  • PapercutSmtp - PapercutSmtpContainerResource
  • RavenDB - RavenDBServerResource, RavenDBDatabaseResource
  • Solr - SolrResource
  • Sqlite - SqliteResource, SqliteWebResource
  • SurrealDb - SurrealDbServerResource, SurrealDbNamespaceResource, SurrealDbDatabaseResource

Compatibility

This is a breaking change that aligns with the Aspire 13.0 major version release. All implementations follow the same patterns established in the upstream Aspire resources (PostgreSQL, MySQL, Redis, MongoDB, etc.).

Fixes #889

cc @sebastienros

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dnceng.pkgs.visualstudio.com
    • Triggering command: dotnet build --no-restore /p:TargetFramework=net9.0 src/CommunityToolkit.Aspire.Hosting.EventStore/CommunityToolkit.Aspire.Hosting.EventStore.csproj (dns block)
    • Triggering command: dotnet restore (dns block)
    • Triggering command: dotnet workload restore (dns block)
  • https://api.github.com/repos/dotnet/aspire/pulls/11938
    • Triggering command: curl -s -H Accept: application/vnd.github.v3&#43;json REDACTED (http block)
  • ofvvsblobprodcus315.vsblob.vsassets.io
    • Triggering command: dotnet restore (dns block)
    • Triggering command: dotnet workload restore (dns block)
    • Triggering command: dotnet build --no-restore (dns block)
  • u6ovsblobprodcus377.vsblob.vsassets.io
    • Triggering command: dotnet restore CommunityToolkit.Aspire.Hosting.EventStore/CommunityToolkit.Aspire.Hosting.EventStore.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Adapt connection string generation to support new formatting</issue_title>
<issue_description>dotnet/aspire#11938 is going to introduce a new structure on how Aspire resources handle connection strings, so there's going to be a bit of work in the community toolkit to support this.

We will need to update all resources that generate connection strings to implement the new member from the interface, and return out the collection of parts rather than a constructed .NET-esq connection string.</issue_description>

Comments on the Issue (you are @copilot in this section)

@aaronpowell cc @sebastienros @aaronpowell > They're finally doing it, eh. Good stuff -- will you rev a major version for this? i.e. 10.x ?

Yep, it's coming as part of the next major release, and we'll have to rev to match it.</comment_new>

Fixes #889


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Update connection string generation for new formatting Implement GetConnectionProperties for new connection string formatting Oct 22, 2025
Copilot finished work on behalf of aaronpowell October 22, 2025 05:21
Copilot AI requested a review from aaronpowell October 22, 2025 05:21
@davidfowl
Copy link
Contributor

cc @sebastienros

/// <inheritdoc />
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create(
$"{scheme}://{UserNameReference}:{PasswordParameter}@{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");
Copy link

@sebastienros sebastienros Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At what point will it be able to use the encoding from 13.0 (Password:uri)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastienros sorry, I'm not sure I'm following

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add :uri formatter suffix on values that need to be url-encoded:

ReferenceExpression.Create(
            $"{scheme}://{UserNameReference}:{PasswordParameter:uri}@{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, TIL.

@copilot can you do this

@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
CommunityToolkit.Aspire.EventStore 100% 100% 46
CommunityToolkit.Aspire.GoFeatureFlag 100% 97% 74
CommunityToolkit.Aspire.Hosting.ActiveMQ 78% 40% 108
CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.Adminer 73% 50% 20
CommunityToolkit.Aspire.Hosting.Azure.Dapr 29% 7% 124
CommunityToolkit.Aspire.Hosting.Azure.Dapr.Redis 61% 34% 76
CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder 100% 100% 22
CommunityToolkit.Aspire.Hosting.Bun 96% 83% 28
CommunityToolkit.Aspire.Hosting.Dapr 60% 36% 836
CommunityToolkit.Aspire.Hosting.DbGate 94% 50% 18
CommunityToolkit.Aspire.Hosting.Deno 98% 85% 44
CommunityToolkit.Aspire.Hosting.EventStore 88% 100% 26
CommunityToolkit.Aspire.Hosting.Flagd 79% 100% 32
CommunityToolkit.Aspire.Hosting.GoFeatureFlag 87% 73% 36
CommunityToolkit.Aspire.Hosting.Golang 87% 70% 28
CommunityToolkit.Aspire.Hosting.Java 70% 75% 130
CommunityToolkit.Aspire.Hosting.k6 58% 12% 20
CommunityToolkit.Aspire.Hosting.LavinMQ 78% 50% 18
CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.MailPit 85% 50% 22
CommunityToolkit.Aspire.Hosting.McpInspector 89% 55% 150
CommunityToolkit.Aspire.Hosting.Meilisearch 71% 57% 58
CommunityToolkit.Aspire.Hosting.Minio 93% 75% 48
CommunityToolkit.Aspire.Hosting.MongoDB.Extensions 96% 83% 36
CommunityToolkit.Aspire.Hosting.MySql.Extensions 100% 88% 78
CommunityToolkit.Aspire.Hosting.Ngrok 52% 35% 82
CommunityToolkit.Aspire.Hosting.NodeJS.Extensions 97% 78% 286
CommunityToolkit.Aspire.Hosting.Ollama 64% 70% 192
CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector 78% 61% 77
CommunityToolkit.Aspire.Hosting.PapercutSmtp 81% 50% 18
CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions 99% 89% 84
CommunityToolkit.Aspire.Hosting.Python.Extensions 68% 55% 90
CommunityToolkit.Aspire.Hosting.RavenDB 62% 48% 148
CommunityToolkit.Aspire.Hosting.Redis.Extensions 100% 71% 48
CommunityToolkit.Aspire.Hosting.Rust 94% 83% 16
CommunityToolkit.Aspire.Hosting.Solr 72% 100% 22
CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects 76% 63% 154
CommunityToolkit.Aspire.Hosting.Sqlite 89% 89% 52
CommunityToolkit.Aspire.Hosting.SqlServer.Extensions 100% 87% 78
CommunityToolkit.Aspire.Hosting.SurrealDb 55% 40% 256
CommunityToolkit.Aspire.MassTransit.RabbitMQ 100% 100% 30
CommunityToolkit.Aspire.Meilisearch 97% 92% 68
CommunityToolkit.Aspire.Microsoft.Data.Sqlite 89% 85% 52
CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite 61% 58% 114
CommunityToolkit.Aspire.Minio.Client 73% 59% 88
CommunityToolkit.Aspire.OllamaSharp 77% 71% 132
CommunityToolkit.Aspire.RavenDB.Client 60% 53% 237
CommunityToolkit.Aspire.SurrealDb 79% 63% 78
Summary 71% (7165 / 10082) 57% (2041 / 3578) 4508

Minimum allowed line rate is 60%

@github-actions github-actions bot added the Stale label Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants