Compiler Error ASPIREEXPORT002
Version introduced: 13.2
C# — Integration.cs
C# — Integration.cs
Export ID '0' is not a valid method name. Use a valid identifier (e.g., ‘addRedis’, ‘withEnvironment’).
This diagnostic error is reported when the export ID specified in an [AspireExport] attribute is not a valid identifier. Export IDs are used as method names in generated TypeScript (or other language) code, so they must follow the naming rules for those languages. Specifically, the ID must match the pattern [a-zA-Z][a-zA-Z0-9.]*.
Example
Section titled “Example”The following code generates ASPIREEXPORT002:
[AspireExport("add-redis")] // Hyphens are not allowedpublic static IResourceBuilder<RedisResource> AddRedis( IResourceBuilder<IResourceWithEnvironment> builder){ return builder.WithReference(...);}To correct this error
Section titled “To correct this error”Use a valid camelCase or dot-separated identifier as the export ID:
[AspireExport("addRedis")]public static IResourceBuilder<RedisResource> AddRedis( IResourceBuilder<IResourceWithEnvironment> builder){ return builder.WithReference(...);}