生成的类型提供程序的工作示例 [英] Generated Types Provider working example

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

问题描述

有人可以让我指出生成的类型F#TypeProvider的工作示例吗?理想情况下,基于F#示例包"ProvidedTypes-*.fs"库.

Can somebody point me to working example of generated types F# TypeProvider? Ideally, based on F# sample pack "ProvidedTypes-*.fs" library.

我尝试了F#3.0示例包中的"GeneratedTypeProvider",但对我不起作用.我收到"...'FSharpLib.T'不包含'F1'的定义,并且找不到扩展方法'F1'接受类型为'FSharpLib.T'的第一个参数(您是否缺少using指令或程序集参考?)"的C#项目.我不太关心C#项目(ConsoleApplication1),但是当我将ConsoleApplication2更改为调用T.F1的控制台应用程序运行时,我收到了可怕的"pass3错误,类型为FSharpLib.Program,错误:GetMethodRefAsMethodDefIdx中的错误,mref ="F1 ,错误:引发了'Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter + MethodDefNotFound'类型的异常."老实说,源代码与 http://apollo13cn.blogspot.com/2013/01 /generation-type-provider-and-code.html

I tried "GeneratedTypeProvider" from F# 3.0 Sample Pack but it doesn't work for me. I received "...'FSharpLib.T' does not contain a definition for 'F1' and no extension method 'F1' accepting a first argument of type 'FSharpLib.T' could be found (are you missing a using directive or an assembly reference?)" for C# project. I don't care much about C# project (ConsoleApplication1) but when I changed ConsoleApplication2 to run as console application that invokes T.F1 I received scary "Error in pass3 for type FSharpLib.Program, error: Error in GetMethodRefAsMethodDefIdx for mref = "F1", error: Exception of type 'Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter+MethodDefNotFound' was thrown." And honestly, it's suspicious that source code out of sync with http://apollo13cn.blogspot.com/2013/01/generated-type-provider-and-code.html

我还查看了 http://code.google. com/p/froto/source/browse/Gen/ProtoTypeProvider.fs .我没有编译/运行该项目,但它没有使用Sample Pack,后者肯定不是最佳选择.

I also looked at http://code.google.com/p/froto/source/browse/Gen/ProtoTypeProvider.fs. I didn't compile/ran the project but it doesn't use Sample Pack which is certainly sub-optimal.

不确定GitHub上colinbull的游乐场"项目,因为它似乎只是从其他程序集中复制类型.

Not sure about "Playground" project by colinbull on GitHub because it seems just to copy types from other assembly.

推荐答案

通常,示例包中的测试"项目包含针对已擦除类型生成器和生成的类型提供程序的测试.但是,当我运行测试时,我看到了与您相同的错误-似乎提供的类型" API最近被部分破坏了-现在已修复(至少对于测试项目,还没有尝试过GeneratedTypeProvider示例)

In general Tests project in sample pack contains tests for both erased and generated type providers. However when I run tests I saw the same error that you have - seems that 'provided types' API was partially broken recently - now fixed (at least for the tests project, have not tried GeneratedTypeProvider sample)

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

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