gpt4 book ai didi

f# - 使用生成类型提供程序创建多个根类型

转载 作者:行者123 更新时间:2023-12-04 02:16:43 24 4
gpt4 key购买 nike

生成类型提供者似乎在拥有多个根类型时遇到了问题。完整的复制品可在此处获得: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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com