Compiler Warning ASPIREEXPORT008
Extension method '0' on exported type is missing [AspireExport] or [AspireExportIgnore]: 1
This diagnostic warning is reported when a public static extension method extends a type that participates in ATS (Aspire Type Specification) exports but the extension method itself is not annotated with [AspireExport] or [AspireExportIgnore]. Every public extension method on an exported type should be explicitly marked so that the ATS code generator knows whether to include or exclude it from the generated API surface.
Example
Section titled “Example”The following code generates ASPIREEXPORT008:
// RedisResource participates in ATS exports, but this extension method// is missing [AspireExport] or [AspireExportIgnore]public static IResourceBuilder<RedisResource> WithCustomConfig( this IResourceBuilder<RedisResource> builder, string configPath){ return builder.WithBindMount(configPath, "/usr/local/etc/redis/redis.conf");}To correct this warning
Section titled “To correct this warning”Annotate the extension method with [AspireExport] if it should be available to other language runtimes, or with [AspireExportIgnore] (with a justification) if it should be excluded:
// Export the method to other language runtimes[AspireExport("withCustomConfig")]public static IResourceBuilder<RedisResource> WithCustomConfig( this IResourceBuilder<RedisResource> builder, string configPath){ return builder.WithBindMount(configPath, "/usr/local/etc/redis/redis.conf");}// Or explicitly exclude it from ATS exports[AspireExportIgnore("This method uses C#-specific binding patterns not representable in ATS.")]public static IResourceBuilder<RedisResource> WithCustomConfig( this IResourceBuilder<RedisResource> builder, string configPath){ return builder.WithBindMount(configPath, "/usr/local/etc/redis/redis.conf");}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.ASPIREEXPORT008.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);ASPIREEXPORT008</NoWarn></PropertyGroup>