F# type providers with Portable Library

情到浓时终转凉″ 提交于 2019-12-05 14:42:18
Tomas Petricek

I don't have experience with creating a Type Provider that is useable from Portable Libraries, but you seem to be assuming that type providers emit code at runtime. This is not actually true and so using them in Portable setting might be easier.

The type provider is executed when you run the F# compiler. At this point, it may generate some types, although only one kind of type providers actually does that (there are two different kinds - see this SO answer). However, when you compile code that uses an F# type provider, the resulting assembly does not emit any code at runtime.

I think the Freebase type provider (available in FSharpX) is an example of a provider that works in Portable mode. I suspect that a part of the trick is to split the provider into two assemblies - one that contains code that is needed at runtime and another that contains design time components (which build type information, although they also do not need emit). See TypeProviderAssembly attribute in FreebaseRuntime.fs.

XmlProvider from FSharp.Data works with portable libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!