-
Notifications
You must be signed in to change notification settings - Fork 90
Description
F# interactive is placing strong requirements on the Assembly object returned for generative type providers, in particular effectively demanding that it be either the result of an Assembly.Load or a reflection emit assembly. However, with the new TPSDK it is a remapped ProvidedAssembly.
This was done for two reasons
-
An Assembly.Load after generation can't be used since the assembly must support GetType/GetNestedType queries during the process of generation itself
-
The Assembly can't be a reflection emit assembly since we no longer want the TPSDK to have dependency on reflection emit
F# interactive is placing overly stringent requirements on the type provider here - ideally it should be doing an Assembly.Load(bytes) over the bytes returned by provider.GetGeneratedAssemblyContents. We do call this function, but only to set up the Abstract IL metadata here. I believe the F# compiler should be adjusted at this point.
Repro
Clone SwaggerProvider and build
Source
module TestModule
open SwaggerProvider
type ProvidedSwagger = SwaggerProvider<"https://api.apis.guru/v2/specs/azure.com/arm-iothub/2016-02-03/swagger.json">
let instance = ProvidedSwagger()
Run F# Interactive with this as source:
c:\github\dsyme\visualfsharp\debug\net40\bin\fsi.exe --noframework -r:C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll -r:"C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\FSharp.Core.dll" -r:"C:\GitHub\misc\SwaggerProvider\packages\test\FSharp.Data\lib\net45\FSharp.Data.dll" -r:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" -r:"C:\GitHub\misc\SwaggerProvider\tests\SwaggerProvider.ProviderTests\..\..\bin\SwaggerProvider\SwaggerProvider.Runtime.dll" -r:"C:\GitHub\misc\SwaggerProvider\tests\SwaggerProvider.ProviderTests\..\..\bin\SwaggerProvider\SwaggerProvider.dll" b.fs