生成类型提供者似乎在拥有多个根类型时遇到了问题。 完整的复制品可在此处获得:https://gist.github.com/dsevastianov/46d1a8495c4af46a9875 .下面的例子
#r @"SampleProvider.dll"
type Birch = Sample.Sample<"birch">
type Elm = Sample.Sample<"elm">
let birch = Birch.birch()
let elm = Elm.elm()
elm.Branches <- ([|Elm.elm()|])
在编译时失败(而不是在设计时):
FSC: error FS2014: A problem occurred writing the binary 'obj\Debug\Tests.dll':
Error in pass3 for type Schema, error: Error in GetMethodRefAsMethodDefIdx for
mref = (".ctor", "ZipLookup"), error: Exception of type Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter+MethodDefNotFound' was thrown.
最佳答案
事实证明,有必要为每个根类型创建单独的临时程序集。我修改了 Gist 以反射(reflect)解决方案:https://gist.github.com/dsevastianov/46d1a8495c4af46a9875
关于f# - 使用生成类型提供程序创建多个根类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24185357/