fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

Long term aim: Remove binary writer from TPSDK #299

Open dsyme opened 5 years ago

dsyme commented 5 years ago

The TPSDK includes a 2000 line internalized optional binary writer incorporated into each generative type provider. This is because generative type providers communicate their generated code to the F# compiler by giving an actual .NET binary which is then statically linked into the target output. The type definitions for the generated binary is specified by ProvidedTypeDefinition etc. and the code by quotations.

While there are no known bugs in the binary writer, we would like to eventually remove the writer from the TPSDK. This could be done in two ways

  1. We could use an existing binary writer. The main problem here is that it causes TPDTC components to have dependencies and TPDTC are not loaded in isolation.

  2. We could modify the TP-compiler API so that no binary writer is needed.

On (2), the use of generated assemblies itself is a clumsy way to communicate code to the F# compiler. The F# compiler could be modified so that this is deprecated and that it directly takes quotations and translates them using its own binary writer, rather than using any static linking. This would make it harder or impossible for generative type providers to host C#-code generators, and we would deprecate that

NinoFloris commented 5 years ago

Upside to that approach of using quotations instead is that it opens up new avenues like using TPs for JS where that 'just works'