Skip to content

Generative TP raises error in F# Interactive when using new SDK #152

@dsyme

Description

@dsyme

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

  1. An Assembly.Load after generation can't be used since the assembly must support GetType/GetNestedType queries during the process of generation itself

  2. 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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions