F# API 搜索引擎是一个搜索引擎,允许您通过签名或名称搜索 F# API。
项目名称 | 概述 |
---|---|
FSharpApi搜索 | 搜索引擎本体 |
FSharpApiSearch.数据库 | 搜索引擎数据库创建工具 |
FSharpApiSearch.Console | 搜索引擎前端(控制台应用程序) |
从发布页面下载 zip 文件并解压。
首先,运行 FSharpApiSearch.Database.exe 创建数据库。
FSharpApiSearch.Database.exe
默认情况下可以搜索的程序集有FSharp.Core
、 mscorlib
、 System
和System.Core
。 您可以在创建数据库时通过指定程序集来添加搜索目标。您可以使用--lib
选项指定搜索程序集的目录。 另请指定指定程序集所依赖的程序集。
FSharpApiSearch.Database.exe --lib:TargetAssemblyDirectory TargetAssembly1 TargetAssembly2 DependentAssembly
如果运行 FSharpApiSearch.Console.exe 而不向其提供查询,它将以交互模式启动。 键入#q
退出交互模式。
FSharpApiSearch.Console.exe
如果您将查询作为参数传递,则搜索将仅执行一次。
FSharpApiSearch.Console.exe "int -> int"
使用--target
选项实际使用创建的数据库进行搜索。
FSharpApiSearch.Console.exe --target:TargetAssembly1 --target:TargetAssembly2
如果使用--target
选项,则默认的FSharp.Core
、 mscorlib
、 System
和System.Core
将不会包含在搜索目标中,因此如果要将它们包含在搜索目标中,请显式指定它们。
FSharpApiSearch.Console.exe --target:TargetAssembly1 --target:TargetAssembly2 --target:FSharp.Core --target:mscorlib --target:System --target:System.Core
respect-name-difference
选项如果启用respect-name-difference
选项,则搜索会考虑查询中不同类型变量和命名通配符的名称差异。 不同的名称不匹配相同的类型。 例如,查询?a -> ?a
与签名int -> int
匹配,但查询?a -> ?b
int -> int
不匹配。
如果禁用此选项,查询?a -> ?b
将匹配int -> int
。
greedy-matching
选项如果启用greedy-matching
选项,则类型变量和其他类型将单独匹配,并且结果将按照匹配的降序排序并显示。 此外,现在在搜索中考虑了类型约束。
ignore-param-style
选项函数和方法有两种类型的参数格式:柯里化格式 ( arg1 -> arg2 -> returnType
) 和元组格式 ( arg1 * arg2 -> returnType
)。如果启用了ignore-param-style
选项,则匹配将忽略柯里化和元组格式。
ignore-case
选项如果启用了ignore-case
选项,则在匹配API名称和类型名称时将忽略大小写。
substring
选项如果启用substring
选项,则按子字符串搜索。
swap-order
选项如果启用swap-order
选项,搜索将交换参数和元组的顺序。 例如,查询a -> b -> c
匹配b -> a -> c
。
complement
选项如果启用complement
选项,则补全并搜索缺失的参数和元组元素。 例如,查询a * c
匹配a * b * c
。
single-letter-as-variable
选项如果启用single-letter-as-variable
选项,则单字母类型名称将被视为类型变量名称。 例如,查询t list
与't list
相同。
language
选项将查询、搜索和结果显示切换为language
选项指定的编程语言。 此选项接受 F# 和 C#。
xmldoc
选项如果启用xmldoc
选项,则在搜索结果中显示 XML 文档。
F# 查询与 F# 签名基本相同。仅对FSharpApiSearch的扩展进行详细说明。
>
是以交互模式启动 FSharpApiSearch.Console.exe 时的提示符。
应用程序编程接口 | 查询示例 |
---|---|
模块功能和值 | int -> string |
记录、结构字段 | Ref<'a> -> 'a |
受歧视联盟 | 'a -> Option<'a> |
成员 | 'a list -> int |
构造函数 | Uri : _ Uri.new : _ Uri..ctor : _ |
名称(函数名称、成员名称等) | head : 'a list -> 'a head |
活跃模式 | (||) : ... -> Expr -> ? |
类型、类型缩写、模块 | List<'T> |
计算表达式 | { let! } : Async<'T> |
子类型搜索 | #seq<'a> -> 'a |
要按名称搜索,请输入name : signature
或name
。如果不指定签名,请在签名部分指定_
。
> id : 'a -> 'a
Microsoft.FSharp.Core.Operators.id: 'T -> 'T, module value, FSharp.Core
> choose
Microsoft.FSharp.Collections.Array.Parallel.choose: ('T -> option<'U>) -> 'T[] -> 'U[], module value, FSharp.Core
Microsoft.FSharp.Collections.Array.choose: ('T -> option<'U>) -> 'T[] -> 'U[], module value, FSharp.Core
Microsoft.FSharp.Collections.List.choose: ('T -> option<'U>) -> list<'T> -> list<'U>, module value, FSharp.Core
Microsoft.FSharp.Collections.Seq.choose: ('T -> option<'U>) -> seq<'T> -> seq<'U>, module value, FSharp.Core
Microsoft.FSharp.Control.Event.choose: ('T -> option<'U>) -> IEvent<'Del, 'T> -> IEvent<'U>, module value, FSharp.Core
when 'Del : delegate and 'Del :> Delegate
Microsoft.FSharp.Control.Observable.choose: ('T -> option<'U>) -> IObservable<'T> -> IObservable<'U>, module value, FSharp.Core
> choose : _
Microsoft.FSharp.Collections.Array.Parallel.choose: ('T -> option<'U>) -> 'T[] -> 'U[], module value, FSharp.Core
Microsoft.FSharp.Collections.Array.choose: ('T -> option<'U>) -> 'T[] -> 'U[], module value, FSharp.Core
Microsoft.FSharp.Collections.List.choose: ('T -> option<'U>) -> list<'T> -> list<'U>, module value, FSharp.Core
Microsoft.FSharp.Collections.Seq.choose: ('T -> option<'U>) -> seq<'T> -> seq<'U>, module value, FSharp.Core
Microsoft.FSharp.Control.Event.choose: ('T -> option<'U>) -> IEvent<'Del, 'T> -> IEvent<'U>, module value, FSharp.Core
when 'Del : delegate and 'Del :> Delegate
Microsoft.FSharp.Control.Observable.choose: ('T -> option<'U>) -> IObservable<'T> -> IObservable<'U>, module value, FSharp.Core
使用星号 ( *
) 搜索部分匹配项。 例如, FSharp.Core.String.* : _
显示FSharp.Core.String
模块的所有 API。
> FSharp.Core.String.* : _
Microsoft.FSharp.Core.String.collect: (char -> string) -> string -> string, module value, FSharp.Core
Microsoft.FSharp.Core.String.concat: string -> seq<string> -> string, module value, FSharp.Core
Microsoft.FSharp.Core.String.exists: (char -> bool) -> string -> bool, module value, FSharp.Core
Microsoft.FSharp.Core.String.filter: (char -> bool) -> string -> string, module value, FSharp.Core
...
通常,类型变量(例如'a
和类型名称(例如int
不匹配。 但是,您可能想同时搜索这两种情况。 在这种情况下,您可以使用通配符?
或_
。
> ? -> list<?> -> ?
Microsoft.FSharp.Collections.List.append: list<'T> -> list<'T> -> list<'T>, module value, FSharp.Core
Microsoft.FSharp.Collections.List.averageBy: ('T -> 'U) -> list<'T> -> 'U, module value, FSharp.Core
when 'U : (static member op_Addition : 'U * 'U -> 'U) and 'U : (static member DivideByInt : 'U * int -> 'U) and 'U : (static member get_Zero : unit -> 'U)
Microsoft.FSharp.Collections.List.choose: ('T -> option<'U>) -> list<'T> -> list<'U>, module value, FSharp.Core
Microsoft.FSharp.Collections.List.chunkBySize: int -> list<'T> -> list<list<'T>>, module value, FSharp.Core
...
另外,通过命名通配符,您可以添加一个条件,即相同类型名称将出现在具有相同名称的通配符位置。 例如, ? -> ?
匹配以下所有函数:
'a -> 'a
int -> int
'a -> int
int -> string
但是,如果您将其命名为?a -> ?a
,则上面的示例将不匹配'a -> int
或int -> string
。
子类型搜索是指定与指定基类型或接口兼容的类型的约束。
要在查询中使用子类型搜索,请编写#type
。您可以在type
部分指定类型名称和接口名称。类型名称中不能指定类型参数和通配符。
例如, ? -> #seq<'T>
可以搜索从seq<'T>
返回类型(例如List<'T>
、 IList<'T>
和'T[]
的函数。
要搜索实例成员,请编写receiver -> signature
。
搜索方法时,写入receiver -> arg -> returnType
。
要搜索多参数方法,请编写receiver -> arg1 -> arg2 -> returnType
或receiver -> arg1 * arg2 -> returnType
。 通常,方法参数以元组格式 ( arg1 * arg2
) 和柯里化格式 ( arg1 -> arg2
) 进行搜索,而不区分它们。 如果要按参数格式搜索,请禁用ignore-param-style
选项。
要搜索属性,请编写receiver -> propertyType
。 索引属性写为receiver -> index -> propertyType
。
可以使用与模块中的值和函数相同的查询来搜索静态成员。多参数方法的编写方式类似于实例方法arg1 -> arg2 -> returnType
或arg1 * arg2 -> returnType
。
要搜索活动模式,请编写(||) : (args ->) inputType -> returnType
。 要搜索部分活动的模式,请编写(|_|) : (args ->) inputType -> returnType
。
在inputType
部分中,指定活动模式处理的类型。例如,如果要搜索Expr
请编写(||) : ... -> Expr -> ?
在args
部分指定活动模式参数。 如果要搜索带参数的活动模式,请编写(||) : arg1 -> arg2 -> inputType -> returnType
。 如果要搜索不带参数的活动模式,请编写(||) : inputType -> returnType
。 如果要在不区分参数存在或不存在的情况下进行搜索,请在参数部分使用关键字...
并写入(||) : ... -> inputType -> returnType
。
retyrnType
部分指定函数返回的类型,这是实际的活动模式。 对于单个、多个和部分活动模式,活动模式函数的返回值是不同的。 请指定任何相应的类型, option<_>
, Choice<_,...,_>
。 一般建议使用通配符( ?
)。
要搜索计算表达式,请编写{ syntax } : type
。查找可以处理指定语法和类型的构建器。
syntax
可以包括let!
、 yield
、 return
yield!
、 return!
、 use
use!
for
if/then
while
、 try/with
try/finally
和任何自定义操作名称。如果要指定多个syntax
,请用;
分隔,并写成{ s1; s2 } : type
。
C# 查询的语法与 C# 签名不同。
应用程序编程接口 | 查询示例 |
---|---|
成员 | object -> () -> string string -> int |
构造函数 | Uri : _ Uri..ctor : _ |
类型参数 | List<T> -> int Dictionary<tkey, tvalue> <TKey, TValue> : Dictionary<TKey, TValue> |
姓名(会员姓名等) | Length : string -> int Length |
模具 | List |
子类型搜索 | <T> : #IEnumerable<T> -> T |
要搜索成员或按姓名键入,请写name : signature
或name
。如果不指定签名,请在签名部分指定_
。
> Length : string -> int
System.String.Length : int, instance property with get, mscorlib
> Length
int Array.Length { get; }, instance property, mscorlib
int BitArray.Length { get; set; }, instance property, mscorlib
long BufferedStream.Length { get; }, instance property, mscorlib
long FileInfo.Length { get; }, instance property, mscorlib
...
> Length : _
int Array.Length { get; }, instance property, mscorlib
int BitArray.Length { get; set; }, instance property, mscorlib
long BufferedStream.Length { get; }, instance property, mscorlib
long FileInfo.Length { get; }, instance property, mscorlib
...
使用星号 ( *
) 搜索部分匹配项。 例如, System.String.* : _
显示System.String
类型的所有 API。
> System.String.* : _
System.Array.Length : int, instance property with get, mscorlib
System.Collections.BitArray.Length : int, instance property with get set, mscorlib
System.ComponentModel.DataObjectFieldAttribute.Length : int, instance property with get, System
System.ComponentModel.MaskedTextProvider.Length : int, instance property with get, System
...
类型参数描述有以下三种类型:
格式 | 例子 | 类型参数 | 评论 |
---|---|---|---|
<t> : signature | <TKey, TValue> : Dictionary<TKey, TValue> | TKey , TValue | 大写字母可以在详细形式的类型参数中使用 |
全部小写 | Dictionary<tkey, tvalue> | tkey , tvalue | 如果所有字母都是小写,则可以省略<T> 部分。 |
一个字符 | List<T> -> int | T | 如果是单个字符, <T> 部分可以省略。 |
但是,即使它们都是小写,int 和 string 等内置类型也不会被视为类型参数。
查询中的类型参数名称不必与正在搜索的类型参数名称匹配。 例如,查询List<A>
与类型System.Collections.Generics.List<T>
匹配。
通常,类型参数(例如T
和类型名称(例如int
不匹配。 但是,您可能想同时搜索这两种情况。 在这种情况下,您可以使用?
。
> <T> : List<T> -> ? -> int
System.Collections.Generic.List<T>.BinarySearch(T item) : int, instance method, mscorlib
System.Collections.Generic.List<T>.FindIndex(Predicate<T> match) : int, instance method, mscorlib
System.Collections.Generic.List<T>.FindLastIndex(Predicate<T> match) : int, instance method, mscorlib
System.Collections.Generic.List<T>.IndexOf(T item) : int, instance method, mscorlib
...
另外,通过命名通配符,您可以添加一个条件,即相同类型名称将出现在具有相同名称的通配符位置。 例如, ? -> ?
匹配以下所有内容:
static T F1<T>(T x)
static int F2 (int x)
static T F3<T>(int x)
static int F4 (string x)
但是,如果您将其命名为?a -> ?a
,则上面的示例将不匹配F2
或F4
。
子类型搜索是指定与指定基类型或接口兼容的类型的约束。
要在查询中使用子类型搜索,请编写#type
。您可以在type
部分指定类型名称和接口名称。类型名称中不能指定类型参数和通配符。
例如, <T> : ? -> #IEnumerable<T>
可以搜索从IEnumerable<T>
继承并返回类型(例如List<T>
、 IList<T>
和T[]
的方法。
要搜索方法,请编写receiver -> (arg) -> returnType
。 多参数方法写为receiver -> (arg1, arg2) -> returnType
。 参数部分的括号可以省略。如果要搜索没有参数或返回值的 API,请使用()
和void
。
> <T> : List<T> -> T -> int
System.Collections.Generic.List<T>.BinarySearch(T item) : int, instance method, mscorlib
System.Collections.Generic.List<T>.IndexOf(T item) : int, instance method, mscorlib
...
要搜索属性,请编写receiver -> propertyType
。 索引属性写为receiver -> index -> propertyType
。
> <T> : List<T> -> int
System.Collections.Generic.List<T>.Capacity : int, instance property with get set, mscorlib
System.Collections.Generic.List<T>.Count : int, instance property with get, mscorlib
...
要搜索方法,请编写(arg) -> returnType
。 搜索属性时,请写入propertyType
。
> string -> int
System.Convert.ToInt32(string value) : int, static method, mscorlib
System.Int32.Parse(string s) : int, static method, mscorlib
...
这样,静态成员查询中就不会说明该成员所属的类型。