Generated Types Provider working example [closed]

孤者浪人 提交于 2019-12-21 14:03:43

问题


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

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

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.

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


回答1:


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)



来源:https://stackoverflow.com/questions/16401541/generated-types-provider-working-example

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