F# 如何查看程序集中的类型提供程序

F# 如何查看程序集中的类型提供程序,f#,f#-data,F#,F# Data,我正在查看对象资源管理器,并试图找出类型提供程序的定义位置/方式-我正在查看FSharp.Data.dll。它显示CsvFile和CsvRow。。但我找不到CsvProvider。这个定义在哪里?我是否应该仅依靠文档来找出给定程序集中的类型提供程序?FSharp.Data.dll是FSharp.Data的运行时组件。类型提供程序在编译时为您生成类型,之后不需要。该dll称为:FSharp.Data.DesignTime.dll 您可以反编译该dll,但我认为查看源代码更容易: 类型提供程序所做的

我正在查看对象资源管理器,并试图找出类型提供程序的定义位置/方式-我正在查看FSharp.Data.dll。它显示CsvFile和CsvRow。。但我找不到CsvProvider。这个定义在哪里?我是否应该仅依靠文档来找出给定程序集中的类型提供程序?

FSharp.Data.dll是FSharp.Data的运行时组件。类型提供程序在编译时为您生成类型,之后不需要。该dll称为:
FSharp.Data.DesignTime.dll

您可以反编译该dll,但我认为查看源代码更容易:

类型提供程序所做的是,它注入代码和类型,以方便您浏览JSON。使用像
dnSpy
这样的工具,可以了解实际发生的情况

因此,示例程序

type Simple = JsonProvider<""" { "name":"John", "age":94 } """>
let f (s: string) =
  let s = Simple.Parse s
  s.Name
因此,字符串被解析为
IJsonDocument
,然后
s.Name
被转换为

    JsonValueOptionAndPath jsonValueOptionAndPath = JsonRuntime.TryGetPropertyUnpackedWithPath(s2, "name");
    return JsonRuntime.GetNonOptionalValue<string>(jsonValueOptionAndPath.Path, JsonRuntime.ConvertString("", jsonValueOptionAndPath.JsonOpt), jsonValueOptionAndPath.JsonOpt);
JsonValueOptionAndPath JsonValueOptionAndPath=JsonRuntime.TryGetPropertyUnpackedWithPath(s2,“名称”);
返回JsonRuntime.GetNonOptionalValue(jsonValueOptionAndPath.Path,JsonRuntime.ConvertString(“,jsonValueOptionAndPath.JsonOpt),jsonValueOptionAndPath.JsonOpt);

关于的代码不需要
FSharp.Data.DesignTime.dll
,因此它不包含在构建中。

非常感谢您的详细回复。我主要使用F#interactive,并通过#r指令引用库。因此,如果我正确理解了您的解释,FSharp.Data.DesignTime.dll将不会在F#交互使用期间生成,因为没有编译操作(或者它将在后台生成,我们看不到)。我们确实需要查看源代码,检查给定程序集是否具有类型提供程序。
    JsonValueOptionAndPath jsonValueOptionAndPath = JsonRuntime.TryGetPropertyUnpackedWithPath(s2, "name");
    return JsonRuntime.GetNonOptionalValue<string>(jsonValueOptionAndPath.Path, JsonRuntime.ConvertString("", jsonValueOptionAndPath.JsonOpt), jsonValueOptionAndPath.JsonOpt);