我已經創建了我要揭露在裝配一些預先生成的類型簡單型供應商,具體如下:智能感知不工作的F#類型提供
[<TypeProvider>]
type TestProvider() as this =
inherit TypeProviderForNamespaces()
let providedType = ProvidedTypeDefinition(Assembly.GetExecutingAssembly(), "Test", "TypeLib", None)
do let assembly = Assembly.LoadFrom @"C:\Some\Long\Path\TestTypes.dll"
// Get same problem with providedType.AddAssemblyTypesAsNestedTypesDelayed(),
// which is what I really want to use
providedType.AddMember(assembly.GetType("TestTypes.Circle"))
this.AddNamespace("Test", [providedType])
我使用來自另一個項目,因爲這提供如下:
// Circle member not showing up under TypeLib
type Circle = Test.TypeLib.Circle
let c = Circle()
c.Radius <- 4.
printfn "%f" c.Radius
System.Console.ReadKey() |> ignore
它編譯,運行和正常工作,但由於某種原因,Circle
沒有出現在智能感知列表Test.TypeLib顯示出來。當我懸停在Circle
它說A reference to type 'TestType.Circle' in assembly 'TestTypes' was found, but the type could not be found in that assembly.
我做錯了什麼?
UPDATE:作爲由梅德建議,我看到了related question並下載正在試圖做類似於礦山做事情的associated type provider。不幸的是,在我的機器上,提供者的行爲與我的相同,即它爲名稱空間提供Intellisense,但不提供類型。所以我不知道它可能是什麼特定於我的配置或什麼。
您是否在Reflector或您最喜愛的拆卸工具中打開了裝配體?也許值得一瞧。 –
這裏是對類似問題的回答 http://stackoverflow.com/questions/15078419/emitting-generated-types-in-f-type-providers/15079605#15079605 –
更新的問題與其他信息。 – luksan