Compiler Error ASPIREEXPORT003

Version introduced: 13.2

Method '{0}' has return type '{1}' which is not ATS-compatible. Use void, Task, Task<T>, or a supported Aspire type.

This diagnostic error is reported when a method decorated with [AspireExport] has a return type that cannot be represented across language boundaries by the Aspire Type Specification (ATS). ATS-compatible return types include void, Task, Task<T> where T is ATS-compatible, and supported Aspire types such as IResourceBuilder<T>.

Example

The following code generates ASPIREEXPORT003:

[AspireExport("getConnectionString")]
public static Func<string> GetConnectionString(
    IResourceBuilder<IResourceWithConnectionString> builder)
{
    return () => builder.Resource.ConnectionStringExpression.ValueExpression;
}

To correct this error

Change the return type to an ATS-compatible type. Use void, Task, Task<T>, or a supported Aspire type such as IResourceBuilder<T>:

[AspireExport("withEnvironment")]
public static IResourceBuilder<IResourceWithEnvironment> WithEnvironment(
    IResourceBuilder<IResourceWithEnvironment> builder,
    string name,
    string value)
{
    return builder.WithEnvironment(name, value);
}