使用生成类型提供程序创建多个根类型 [英] Creating more than one root type with generative type provider

查看:82
本文介绍了使用生成类型提供程序创建多个根类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

生成类型提供程序似乎存在多个根类型的问题. 完整的repro可以在这里找到: https://gist.github.com/dsevastianov/46d1a8495c4af46a9875 .以下示例

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.

推荐答案

事实证明,有必要为每种根类型创建单独的临时程​​序集.我修改了Gist以反映解决方案: https://gist.github.com/dsevastianov/46d1a8495c4af46a9875

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

这篇关于使用生成类型提供程序创建多个根类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆