Compiler Error ASPIREEXPORT001
Version introduced: 13.2
C# — Integration.cs
C# — Integration.cs
Method '0' marked with [AspireExport] must be static.
This diagnostic error is reported when a method decorated with the [AspireExport] attribute is not declared as static. Methods exported to other language runtimes via the Aspire Type Specification (ATS) must be static because they are invoked by the ATS runtime without an object instance.
Example
Section titled “Example”The following code generates ASPIREEXPORT001:
[AspireExport("addRedis")]public IResourceBuilder<RedisResource> AddRedis( IResourceBuilder<IResourceWithEnvironment> builder){ return builder.WithReference(...);}To correct this error
Section titled “To correct this error”Add the static modifier to the method:
[AspireExport("addRedis")]public static IResourceBuilder<RedisResource> AddRedis( IResourceBuilder<IResourceWithEnvironment> builder){ return builder.WithReference(...);}