Compiler Warning ASPIREEXPORT009
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.
Example
Section titled “Example”The following code generates ASPIREEXPORT009:
[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);}To correct this warning
Section titled “To correct this warning”Use a more specific name that includes your integration name or a qualifying prefix to avoid collisions across integrations:
[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
Section titled “Suppress the warning”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 = noneFor more information about editor config files, see Configuration files for code analysis rules.
-
Add the following
PropertyGroupto your project file:C# project file <PropertyGroup><NoWarn>$(NoWarn);ASPIREEXPORT009</NoWarn></PropertyGroup>