Compiler Warning ASPIREEXPORT007
Export ID '0' is already defined for target type '1'. Each export ID must be unique per target type.
This diagnostic warning is reported when two or more [AspireExport] methods in the same assembly use the same export ID for the same target type. Because the export ID becomes the method name in generated code for other language runtimes, duplicate export IDs for the same target type would result in ambiguous or overwritten API members.
Example
Section titled “Example”The following code generates ASPIREEXPORT007:
[AspireExport("withCache")]public static IResourceBuilder<RedisResource> WithCache( IResourceBuilder<RedisResource> builder){ return builder;}
[AspireExport("withCache")] // Duplicate ID for the same target typepublic static IResourceBuilder<RedisResource> WithCacheAndPersistence( IResourceBuilder<RedisResource> builder){ return builder.WithPersistence();}To correct this warning
Section titled “To correct this warning”Use a unique export ID for each method targeting the same type:
[AspireExport("withCache")]public static IResourceBuilder<RedisResource> WithCache( IResourceBuilder<RedisResource> builder){ return builder;}
[AspireExport("withCacheAndPersistence")]public static IResourceBuilder<RedisResource> WithCacheAndPersistence( IResourceBuilder<RedisResource> builder){ return builder.WithPersistence();}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.ASPIREEXPORT007.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);ASPIREEXPORT007</NoWarn></PropertyGroup>