Creating more than one root type with generative type provider

半世苍凉 提交于 2019-12-12 15:03:30

问题


Generative type providers seem to have an issue with having more than one root type. Complete repro is available here: https://gist.github.com/dsevastianov/46d1a8495c4af46a9875. Following example

#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()|])

fails at compile time (not at design time):

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.

回答1:


Turns out that it is necessary to create separate temp assembly for each root type. I amended Gist to reflect the solution: https://gist.github.com/dsevastianov/46d1a8495c4af46a9875



来源:https://stackoverflow.com/questions/24185357/creating-more-than-one-root-type-with-generative-type-provider

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