Closed panesofglass closed 2 years ago
This situation also appears to be true when trying to generate an abstract class with abstract methods, though it seems to only be the methods in this case. See https://github.com/panesofglass/SwaggerProvider/pull/2/commits/983b1a3dc0471cffe0c64fba6ab9b4ffab0fc091
I found a potential work-around using an abstract class with virtual methods, but the generated methods once again appear incorrect:
Based on other abstract classes such as System.IO.TextReader
, that should be a public virtual method
:
I am happy to help sort these into different bugs and work on smaller repros, if that's useful, but I'll need some help, at least for the first one.
I think I can add tests to show these are not working properly. I’ll try to get them properly failing and submit a PR, if that is useful.
I think this has been fixed by #311 We may close this
Thanks, will close.
Description
I ran into the following problems while trying to generate interfaces in the generative SwaggerProvider:
ProvidedTypeDefinition
that will load at runtime.ProvidedTypeDefinition
.ProvidedMethod
requiresinvokeCode
, 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-interfaces
branch.Run
git reset --hard bb2a984101f767b689e49ed63ee38bfd607ffe89
to get to the interfaces implementation.Run
build.cmd
to 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
ProvidedMethod
issue, roll back to this commit and run the build, then inspect the generatedSwaggerProvider.ProvidedTests
assembly for theSwagger.PetStore.Tests.PetStore.Contract
type.Expected behavior
ProvidedTypeDefinition
withTypeAttributes.Public ||| TypeAttributes.Interface ||| TypeAttributes.Abstract
attributes 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 method
butpublic extern method
.Known workarounds
None.
Additional information
ProvidedTypes.fs
andProvidedTypes.fsi
that attempted to make theinvokeCode
parameter onProvidedMethod
optional.