Перейти до вмісту
Docs Try Aspire
Docs Try

Compiler Warning ASPIREEXPORT013

Цей контент ще не доступний вашою мовою.

Version introduced: 13.3

Polyglot capability ID '0' is defined by multiple exports in this assembly: 1. Use unique AspireExport IDs for overloaded or colliding members.

This diagnostic warning is reported when two or more Aspire Type System (ATS) exports in the same assembly generate the same runtime capability ID. The capability ID is used to dispatch calls from TypeScript, Python, Java, and other AppHost runtimes back to the hosting integration. Unlike C# method signatures, a capability ID doesn’t include the receiver type, parameter list, or overload signature, so exports that are distinct in C# can still collide at runtime.

The following code generates ASPIREEXPORT013:

C# — Integration.cs
[AspireExport("configure")]
public static void ConfigureBuilder(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
[AspireExport("configure")]
public static IResourceBuilder<MyResource> ConfigureResource(
this IResourceBuilder<MyResource> builder,
string value)
{
return builder;
}

Both exports generate the same capability ID, such as MyCompany.Hosting.MyIntegration/configure, even though they target different C# receiver types.

The diagnostic can also be reported for public instance members exposed through [AspireExport(ExposeMethods = true)]:

C# — Context.cs
[AspireExport(ExposeMethods = true)]
public sealed class HelmChartOptions
{
public void WithNamespace(string namespaceName)
{
// ...
}
public void WithNamespace(int namespaceNumber)
{
// ...
}
}

Both overloads generate the same default member capability ID because the overload signature isn’t part of the capability ID.

Use unique export IDs for members that would otherwise generate the same capability ID:

C# — Integration.cs
[AspireExport("configureBuilder", MethodName = "configure")]
public static void ConfigureBuilder(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
[AspireExport("configureResource", MethodName = "configure")]
public static IResourceBuilder<MyResource> ConfigureResource(
this IResourceBuilder<MyResource> builder,
string value)
{
return builder;
}

Use MethodName when separate target types can still expose the same friendly method name in the generated SDK while keeping the underlying capability IDs unique. For overloads on the same context type, prefer a single ATS-friendly overload, mark unsupported overloads with [AspireExportIgnore], or give each exported overload a unique SDK method name.

Suppress the warning with either of the following methods:

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

    .editorconfig
    [*.{cs,vb}]
    dotnet_diagnostic.ASPIREEXPORT013.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);ASPIREEXPORT013</NoWarn>
    </PropertyGroup>