我创建了一个简单的类型提供程序,我想在程序集中公开一些预生成的类型,如下所示:
[<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])
Run Code Online (Sandbox Code Playgroud)
我从另一个项目中使用此提供程序如下:
// 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
Run Code Online (Sandbox Code Playgroud)
它按预期编译,运行和工作,但由于某种原因,Circle它不会出现在Test.TypeLib的Intellisense列表中.当我将鼠标悬停在Circle 它上面时说A reference to type 'TestType.Circle' in assembly 'TestTypes' was found, but the type could not be found in that assembly.
我究竟做错了什么?
更新:正如德米特里所建议的那样,我查看了相关问题并下载了相关类型提供程序,该程序提供程序尝试执行类似于我正在执行的操作.不幸的是,在我的机器上,提供程序的行为与我的相同,即它为名称空间提供了Intellisense,但不提供类型.所以我不知道它是否可能是我的配置或什么特定的东西.