Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/frontend/config/sidebar/reference.topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,10 @@ export const referenceTopics: StarlightSidebarTopicsUserConfig[number] = {
label: 'ASPIRECOMPUTE003',
link: '/diagnostics/aspirecompute003',
},
{
label: 'ASPIRECONNECTIONSTRINGS001',
link: '/diagnostics/aspireconnectionstrings001',
},
{
label: 'ASPIRECONTAINERRUNTIME001',
link: '/diagnostics/aspirecontainerruntime001',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Compiler Error ASPIRECONNECTIONSTRINGS001
seoTitle: 'ASPIRECONNECTIONSTRINGS001: Connection-string naming metadata'
description: Learn why Aspire 17.0 retired ASPIRECONNECTIONSTRINGS001 now that the connection-string naming metadata APIs are stable.
---

import { Badge } from '@astrojs/starlight/components';

<Badge
text="Version introduced: 13.6"
variant="note"
size="large"
class:list={'mb-1'}
/>

:::note[Removed in Aspire 17.0]
Starting with Aspire 17.0, `ConnectionStringEnvironmentVariableNames` and `ConnectionStringReference.EnvironmentVariableNames` are stable and no longer emit `ASPIRECONNECTIONSTRINGS001`. You can remove suppressions for these APIs after upgrading.
:::

> 'Aspire.Hosting.ApplicationModel.ConnectionStringEnvironmentVariableNames' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

In Aspire 13.6, this diagnostic is reported when you use the following experimental APIs from `Aspire.Hosting`:

- `ConnectionStringEnvironmentVariableNames`, the record that describes a connection-string reference's logical name and its original and portable environment-variable names
- `ConnectionStringReference.EnvironmentVariableNames`, which exposes that record for generated connection-string injections

Ordinary `WithReference` usage never reported this diagnostic. It only applies to custom publishers and integrations that inspect the naming metadata. For more information, see [Custom publishers and integrations](/fundamentals/environment-variables/#custom-publishers-and-integrations).

## Example in Aspire 13.6

In Aspire 13.6, the following code generates `ASPIRECONNECTIONSTRINGS001`:

```csharp title="Publisher.cs"
if (value is ConnectionStringReference { EnvironmentVariableNames: { } names })
{
foreach (var name in names.GetPhysicalNames())
{
Console.WriteLine(name);
}
}
```

## To correct this error

Upgrade to Aspire 17.0 or later. After upgrading, remove `ASPIRECONNECTIONSTRINGS001` suppressions from _.editorconfig_ files, project `NoWarn` properties, and `#pragma warning` directives.

For Aspire 13.6, suppress the error with one of the following methods:

- Set the severity of the rule in the _.editorconfig_ file.

```ini title=".editorconfig"
[*.{cs,vb}]
dotnet_diagnostic.ASPIRECONNECTIONSTRINGS001.severity = none
```

For more information about editor config files, see [Configuration files for code analysis rules](/diagnostics/overview/#suppress-in-the-editorconfig-file).

- Add the following `PropertyGroup` to your project file:

```xml title="C# project file"
<PropertyGroup>
<NoWarn>$(NoWarn);ASPIRECONNECTIONSTRINGS001</NoWarn>
</PropertyGroup>
```

- Suppress in code with the `#pragma warning disable ASPIRECONNECTIONSTRINGS001` directive:

```csharp title="Suppressing the error"
#pragma warning disable ASPIRECONNECTIONSTRINGS001
var names = reference.EnvironmentVariableNames;
#pragma warning restore ASPIRECONNECTIONSTRINGS001
```

## See also

- [Environment variables: Connection strings](/fundamentals/environment-variables/#connection-strings)
1 change: 1 addition & 0 deletions src/frontend/src/content/docs/diagnostics/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The following table lists the possible MSBuild and analyzer warnings and errors
| [ASPIRECOMPUTE001](/diagnostics/aspirecompute001/) | (Experimental) Error | Compute related types and members are for evaluation purposes only and is subject to change or removal in future updates. |
| [ASPIRECOMPUTE002](/diagnostics/aspirecompute002/) | (Experimental) Warning | The GetHostAddressExpression method is for evaluation purposes only and is subject to change or removal in future updates. |
| [ASPIRECOMPUTE003](/diagnostics/aspirecompute003/) | (Experimental) Warning | The ContainerRegistryResource type is for evaluation purposes only and is subject to change or removal in future updates. |
| [ASPIRECONNECTIONSTRINGS001](/diagnostics/aspireconnectionstrings001/) | (Experimental) Error | Removed in Aspire 17.0. Connection-string naming metadata APIs are stable; remove existing suppressions after upgrading. |
| [ASPIRECONTAINERRUNTIME001](/diagnostics/aspirecontainerruntime001/) | (Experimental) Warning | Type is for evaluation purposes only and is subject to change or removal in future updates. |
| [ASPIRECONTAINERSHELLEXECUTION001](/diagnostics/aspirecontainershellexecution001/) | (Experimental) Warning | Container shell execution property is for evaluation purposes only and is subject to change or removal in future updates. |
| [ASPIRECOSMOSDB001](/diagnostics/aspirecosmosdb001/) | (Experimental) Error | <ApiReference name="Aspire.Hosting.AzureCosmosExtensions.RunAsPreviewEmulator" /> is for evaluation purposes only and is subject to change or removal in future updates. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ If you must keep an older client integration, set the reference's `connectionNam

For generated injections, inspect `ConnectionStringReference` values in the environment-variable dictionary, not resource annotations. Their `EnvironmentVariableNames` property exposes a `ConnectionStringEnvironmentVariableNames` record with `LogicalName`, `OriginalName`, `PortableName`, and `IsExplicit`. Its `Create` factory derives names from a resource and logical name; `GetPhysicalNames` enumerates the distinct physical aliases.

:::caution[Experimental naming metadata]
`ConnectionStringEnvironmentVariableNames` and `ConnectionStringReference.EnvironmentVariableNames` are experimental under `ASPIRECONNECTIONSTRINGS001` and may change. This doesn't make ordinary `WithReference` usage experimental.
:::
Starting with Aspire 17.0, `ConnectionStringEnvironmentVariableNames` and `ConnectionStringReference.EnvironmentVariableNames` are stable and no longer emit [`ASPIRECONNECTIONSTRINGS001`](/diagnostics/aspireconnectionstrings001/). After upgrading, remove any suppressions of that diagnostic. Aspire 13.6 still reports it for these APIs.

The record's properties have public `init` accessors, so you can make a modified copy with a `with` expression. A `with` copy doesn't recompute the other properties: changing `LogicalName` leaves `OriginalName` and `PortableName` unchanged. To derive a consistent set of names for another logical name, call `Create` instead.

A standalone reference created with the existing two-argument constructor has no naming metadata. Don't infer that it's a generated alias. Resolve the reference's `ConnectionStringExpression`, not `Resource.ConnectionStringExpression`, because a reference can select another value on the same resource, such as Qdrant's HTTP connection.

Expand Down
Loading