-
Notifications
You must be signed in to change notification settings - Fork 90
Description
Description
I ran into the following problems while trying to generate interfaces in the generative SwaggerProvider:
- Cannot generate an interface using
ProvidedTypeDefinitionthat will load at runtime. - Cannot generate valid interface methods on a
ProvidedTypeDefinition.ProvidedMethodrequiresinvokeCode, which appears to be converting the generated method into apublic extern method.
Repro steps
Please provide the steps required to reproduce the problem
-
Clone https://github.com/panesofglass/SwaggerProvider and switch to the
api-interfacesbranch. -
Run
git reset --hard bb2a984101f767b689e49ed63ee38bfd607ffe89to get to the interfaces implementation. -
Run
build.cmdto run the FAKE build. -
Observe that, just after starting
RunUnitTests, the program breaks with the following error:
-
Comment out generation of the interfaces to observe that the type provider runs tests successfully: https://github.com/panesofglass/SwaggerProvider/blob/api-interfaces/src/SwaggerProvider.DesignTime/SwaggerProviderConfig.fs#L89
-
To see the
ProvidedMethodissue, roll back to this commit and run the build, then inspect the generatedSwaggerProvider.ProvidedTestsassembly for theSwagger.PetStore.Tests.PetStore.Contracttype.
Expected behavior
-
ProvidedTypeDefinitionwithTypeAttributes.Public ||| TypeAttributes.Interface ||| TypeAttributes.Abstractattributes should generate an interface that can be loaded at runtime. -
Generated interfaces should be able to contain generated methods.
-
Generated interfaces should be implementable by user types.
-
Generated interfaces should be implementable on generated types within the type provider.
Actual behavior
-
Runtime fails to load the generated interface type, causing, in this case a test assembly, to crash even when the generated interface is not used.
-
Generated interface methods are not
public abstract methodbutpublic extern method.
Known workarounds
None.
Additional information
- This PR shows the sequence of steps I've tried and includes a fork of
ProvidedTypes.fsandProvidedTypes.fsithat attempted to make theinvokeCodeparameter onProvidedMethodoptional.
