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
...
這樣,靜態成員查詢中就不會說明該成員所屬的類型。