Skip to content
Docs Try Aspire

Compiler Warning ASPIREEXPORT006

Version introduced: 13.2

Type '0' in [AspireUnion] is not ATS-compatible. Use primitive types, enums, or supported Aspire types.

This diagnostic warning is reported when one or more types specified in an [AspireUnion] attribute cannot be represented across language boundaries by the Aspire Type Specification (ATS). All types in a union must be ATS-compatible (primitive types, enums, or supported Aspire types) so that they can be expressed in generated code for other language runtimes.

The following code generates ASPIREEXPORT006:

C# — Integration.cs
[AspireExport("addResource")]
public static IResourceBuilder<ContainerResource> AddResource(
IDistributedApplicationBuilder builder,
[AspireUnion(typeof(string), typeof(Func<string>))] object name) // Func<string> is not ATS-compatible
{
return builder.AddContainer(name.ToString()!, "myimage");
}

Replace the incompatible type in the union with an ATS-compatible type:

C# — Integration.cs
[AspireExport("addResource")]
public static IResourceBuilder<ContainerResource> AddResource(
IDistributedApplicationBuilder builder,
[AspireUnion(typeof(string), typeof(int))] object name)
{
return builder.AddContainer(name.ToString()!, "myimage");
}

Suppress the warning with either of the following methods:

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

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