Friday, January 11, 2013

Generated Type Provider API Changes

Erased type provider is not a new idea for many F# users, but the problem I am facing is to generate a really DLL which can be consumed by C# project. I use type provider as a code generation tool. If you are thinking about the same thing. Here is how to make your erased type provider to be a generated type provider. The MSDN document does not reflect the recent change in the type provider API's.

  • you need to declare the ProvidedAssembly.

let providedAssembly = new ProvidedAssembly(System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), ".dll"))

  • For the generated type, for example the regexTy, invoke the following statements (you have to remove the space between < and -)
        regexTy.IsErased < - false
        regexTy.SuppressRelocation < - false

Hopefully this can save you 10 minutes.. :-)

No comments: