Skip to content
Docs Try Aspire

Compiler Warning ASPIREEXPORT009

Version introduced: 13.2

Export name '0' on method '1' may collide across integrations because it targets IResourceBuilder<2>. Use a unique name like '3'.

This diagnostic warning is reported when an [AspireExport] method targets the generic IResourceBuilder<T> (where T is an open type parameter, meaning any resource type) and uses a short, generic export name that could conflict with similarly-named methods from other integrations. When multiple integrations export methods with the same name to the same generic resource builder type, name collisions can occur in the generated API surface for other language runtimes. To avoid ambiguity, use a more specific, integration-scoped name.

The following code generates ASPIREEXPORT009:

C# — Integration.cs
[AspireExport("withEnvironment")] // Generic name targeting open IResourceBuilder<T>
public static IResourceBuilder<T> WithEnvironment<T>(
IResourceBuilder<T> builder,
string name,
string value)
where T : IResourceWithEnvironment
{
return builder.WithEnvironment(name, value);
}

Use a more specific name that includes your integration name or a qualifying prefix to avoid collisions across integrations:

C# — Integration.cs
[AspireExport("redis.withEnvironment")]
public static IResourceBuilder<T> WithEnvironment<T>(
IResourceBuilder<T> builder,
string name,
string value)
where T : IResourceWithEnvironment
{
return builder.WithEnvironment(name, value);
}

Suppress the warning with either of the following methods:

  • Set the severity of the rule in the .editorconfig file.

    .editorconfig
    [*.{cs,vb}]
    dotnet_diagnostic.ASPIREEXPORT009.severity = none

    For more information about editor config files, see Configuration files for code analysis rules.

  • Add the following PropertyGroup to your project file:

    C# project file
    <PropertyGroup>
    <NoWarn>$(NoWarn);ASPIREEXPORT009</NoWarn>
    </PropertyGroup>