Compiler Warning ASPIREEXPORT006
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.
Example
Section titled “Example”The following code generates ASPIREEXPORT006:
[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");}To correct this warning
Section titled “To correct this warning”Replace the incompatible type in the union with an ATS-compatible type:
[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
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.ASPIREEXPORT006.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);ASPIREEXPORT006</NoWarn></PropertyGroup>