Skip to content
Docs Try Aspire

Compiler Warning ASPIREEXPORT008

Version introduced: 13.2

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.

The following code generates ASPIREEXPORT008:

C# — Integration.cs
// 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");
}

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:

C# — Integration.cs
// 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");
}
C# — Integration.cs
// 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 with either of the following methods:

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

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