Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
8b6c0cef
F
fsharp
项目概览
dotNET Platform
/
fsharp
11 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8b6c0cef
编写于
6月 20, 2022
作者:
P
Petr Semkin
提交者:
GitHub
6月 20, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Resurrecting quick info provider tests (#13323)
上级
70ad2e5f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
54 addition
and
61 deletion
+54
-61
.gitignore
.gitignore
+4
-1
vsintegration/tests/UnitTests/QuickInfoProviderTests.fs
vsintegration/tests/UnitTests/QuickInfoProviderTests.fs
+50
-58
vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj
vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj
+0
-2
未找到文件。
.gitignore
浏览文件 @
8b6c0cef
...
...
@@ -118,4 +118,7 @@ nCrunchTemp_*
.fake
*.pdb
*.dll
\ No newline at end of file
*.dll
/test.fs
/test.fsx
vsintegration/tests/UnitTests/QuickInfoProviderTests.fs
浏览文件 @
8b6c0cef
...
...
@@ -11,6 +11,10 @@ namespace Microsoft.VisualStudio.FSharp.Editor.Tests.Roslyn
open
System
open
NUnit
.
Framework
open
Microsoft
.
VisualStudio
.
FSharp
open
FSharp
.
Compiler
.
EditorServices
open
FSharp
.
Compiler
.
CodeAnalysis
open
Microsoft
.
CodeAnalysis
open
Microsoft
.
VisualStudio
.
FSharp
.
Editor
[<
SetUpFixture
>]
type
public
AssemblyResolverTestFixture
()
=
...
...
@@ -21,11 +25,6 @@ type public AssemblyResolverTestFixture () =
[<
NUnit
.
Framework
.
Category
"Roslyn Services"
>]
module
QuickInfoProviderTests
=
open
Microsoft
.
CodeAnalysis
open
Microsoft
.
CodeAnalysis
.
Text
open
Microsoft
.
VisualStudio
.
FSharp
.
Editor
open
FSharp
.
Compiler
.
SourceCodeServices
open
UnitTests
.
TestLib
.
LanguageService
let
filePath
=
"C:
\\
test.fs"
let
internal
projectOptions
=
{
...
...
@@ -39,24 +38,30 @@ let internal projectOptions = {
LoadTime
=
DateTime
.
MaxValue
OriginalLoadReferences
=
[]
UnresolvedReferences
=
None
ExtraProjectInfo
=
None
Stamp
=
None
}
let
private
normalizeLineEnds
(
s
:
string
)
=
s
.
Replace
(
"
\r\n
"
,
"
\n
"
).
Replace
(
"
\n\n
"
,
"
\n
"
)
let
private
getQuickInfoText
(
FSharp
ToolTipText
elements
)
:
string
=
let
private
getQuickInfoText
(
ToolTipText
elements
)
:
string
=
let
rec
parseElement
=
function
|
FSharpToolTipElement
.
None
->
""
|
FSharpToolTipElement
.
Group
(
xs
)
->
let
text
=
xs
|>
List
.
map
(
fun
item
->
item
.
MainDescription
)
|>
String
.
concat
"
\n
"
let
tps
=
xs
|>
List
.
collect
(
fun
item
->
item
.
TypeMapping
)
|
ToolTipElement
.
None
->
""
|
ToolTipElement
.
Group
(
xs
)
->
let
descriptions
=
xs
|>
List
.
map
(
fun
item
->
item
.
MainDescription
)
let
descriptionTexts
=
descriptions
|>
List
.
map
(
fun
taggedTexts
->
taggedTexts
|>
Array
.
map
(
fun
taggedText
->
taggedText
.
Text
))
let
descriptionText
=
descriptionTexts
|>
Array
.
concat
|>
String
.
concat
""
let
remarks
=
xs
|>
List
.
choose
(
fun
item
->
item
.
Remarks
)
let
tpText
=
(
match
tps
with
[]
->
""
|
_
->
"
\n
"
+
String
.
concat
"
\n
"
tps
)
let
remarksText
=
(
match
remarks
with
[]
->
""
|
_
->
"
\n
"
+
String
.
concat
"
\n
"
remarks
)
text
+
remarksText
+
tpText
|
FSharpToolTipElement
.
CompositionError
(
error
)
->
error
elements
|>
List
.
map
(
FSharpToolTip
.
ToFSharpToolTipElement
>>
parseElement
)
|>
String
.
concat
"
\n
"
|>
normalizeLineEnds
let
remarkTexts
=
remarks
|>
Array
.
concat
|>
Array
.
map
(
fun
taggedText
->
taggedText
.
Text
)
let
remarkText
=
(
match
remarks
with
[]
->
""
|
_
->
"
\n
"
+
String
.
concat
""
remarkTexts
)
let
tps
=
xs
|>
List
.
collect
(
fun
item
->
item
.
TypeMapping
)
let
tpTexts
=
tps
|>
List
.
map
(
fun
x
->
x
|>
Array
.
map
(
fun
y
->
y
.
Text
)
|>
String
.
concat
""
)
let
tpText
=
(
match
tps
with
[]
->
""
|
_
->
"
\n
"
+
String
.
concat
"
\n
"
tpTexts
)
descriptionText
+
remarkText
+
tpText
|
ToolTipElement
.
CompositionError
(
error
)
->
error
elements
|>
List
.
map
parseElement
|>
String
.
concat
"
\n
"
|>
normalizeLineEnds
[<
Test
>]
let
ShouldShowQuickInfoAtCorrectPositions
()
=
...
...
@@ -67,19 +72,6 @@ let ShouldShowQuickInfoAtCorrectPositions() =
"2"
,
None
"x +"
,
Some
"val x: int
\n
Full name: Test.x"
"System"
,
Some
"namespace System"
"Console"
,
Some
"type Console =
static member BackgroundColor: ConsoleColor with get, set
static member Beep: unit -> unit + 1 overload
static member BufferHeight: int with get, set
static member BufferWidth: int with get, set
static member CapsLock: bool
static member Clear: unit -> unit
static member CursorLeft: int with get, set
static member CursorSize: int with get, set
static member CursorTop: int with get, set
static member CursorVisible: bool with get, set
...
Full name: System.Console"
"WriteLine"
,
Some
"System.Console.WriteLine(value: int) : unit"
]
for
(
symbol
:
string
,
expected
:
string
option
)
in
testCases
do
...
...
@@ -90,14 +82,13 @@ Full name: System.Console"
System.Console.WriteLine(x + y)
"""
let
caretPosition
=
fileContents
.
IndexOf
(
symbol
)
let
documentId
=
DocumentId
.
CreateNewId
(
ProjectId
.
CreateNewId
()
)
let
parsingOptions
,
_
=
checker
.
GetParsingOptionsFromProjectOptions
projectOptions
let
document
,
_
=
RoslynTestHelpers
.
CreateDocument
(
filePath
,
fileContents
)
let
quickInfo
=
FSharpAsyncQuickInfoSource
.
ProvideQuickInfo
(
checker
,
documentId
,
SourceText
.
From
(
fileContents
),
filePath
,
caretPosition
,
parsingOptions
,
projectOptions
,
0
)
FSharpAsyncQuickInfoSource
.
ProvideQuickInfo
(
document
,
caretPosition
)
|>
Async
.
RunSynchronously
let
actual
=
quickInfo
|>
Option
.
map
(
fun
(
text
,
_,
_,
_)
->
getQuickInfoText
t
ext
)
let
actual
=
quickInfo
|>
Option
.
map
(
fun
qi
->
getQuickInfoText
qi
.
StructuredT
ext
)
Assert
.
AreEqual
(
expected
,
actual
)
[<
Test
>]
...
...
@@ -109,39 +100,39 @@ let ShouldShowQuickInfoForGenericParameters() =
"(extension) System.Collections.Generic.IEnumerable.GroupBy<'TSource,'TKey>(keySelector: System.Func<'TSource,'TKey>) : System.Collections.Generic.IEnumerable<IGrouping<'TKey,'TSource>>
'TSource is int * string
'TKey is int"
);
(
"Sort"
,
Some
"System.Array.Sort<'T>(array: 'T
[]) : unit
(
"Sort"
,
Some
"System.Array.Sort<'T>(array: 'T[]) : unit
'T is int"
);
(
"let test4 x = C().FSharpGenericMethodExplitTypeParams"
,
Some
"member C.FSharpGenericMethodExplitTypeParams
: a:'T0 * y:
'T0 -> 'T0 * 'T0
"member C.FSharpGenericMethodExplitTypeParams
: a: 'T0 * y:
'T0 -> 'T0 * 'T0
'T is 'a list"
);
(
"let test5<'U> (x: 'U) = C().FSharpGenericMethodExplitTypeParams"
,
Some
"member C.FSharpGenericMethodExplitTypeParams
: a:'T0 * y:
'T0 -> 'T0 * 'T0
"member C.FSharpGenericMethodExplitTypeParams
: a: 'T0 * y:
'T0 -> 'T0 * 'T0
'T is 'U list"
);
(
"let test6 = C().FSharpGenericMethodExplitTypeParams"
,
Some
"member C.FSharpGenericMethodExplitTypeParams
: a:'T0 * y:
'T0 -> 'T0 * 'T0
"member C.FSharpGenericMethodExplitTypeParams
: a: 'T0 * y:
'T0 -> 'T0 * 'T0
'T is int"
);
(
"let test7 x = C().FSharpGenericMethodInferredTypeParams"
,
Some
"member C.FSharpGenericMethodInferredTypeParams
: a:'a1 * y:
'b2 -> 'a1 * 'b2
"member C.FSharpGenericMethodInferredTypeParams
: a: 'a1 * y:
'b2 -> 'a1 * 'b2
'a is 'a0 list
'b is 'a0 list"
);
(
"let test8 = C().FSharpGenericMethodInferredTypeParams"
,
Some
"member C.FSharpGenericMethodInferredTypeParams
: a:'a0 * y:
'b1 -> 'a0 * 'b1
"member C.FSharpGenericMethodInferredTypeParams
: a: 'a0 * y:
'b1 -> 'a0 * 'b1
'a is int
'b is int"
);
(
"let test9<'U> (x: 'U) = C().FSharpGenericMethodInferredTypeParams"
,
Some
"member C.FSharpGenericMethodInferredTypeParams
: a:'a0 * y:
'b1 -> 'a0 * 'b1
"member C.FSharpGenericMethodInferredTypeParams
: a: 'a0 * y:
'b1 -> 'a0 * 'b1
'a is 'U list
'b is 'U list"
);
(
"let res3 = [1] |>"
,
Some
"val (
|> ) : arg:'T1 -> func:
('T1 -> 'U) -> 'U
Full name: Microsoft.FSharp.Core.Operators.(
|>
)
"val (
|>) : arg: 'T1 -> func:
('T1 -> 'U) -> 'U
Full name: Microsoft.FSharp.Core.Operators.(
|>
)
'T1 is int list
'U is int list"
);
(
"let res3 = [1] |> List.map id"
,
...
...
@@ -151,8 +142,8 @@ Full name: Microsoft.FSharp.Core.Operators.id
'T is int"
);
(
"let res4 = (1.0,[1]) ||>"
,
Some
"val (
||> )
: arg1: 'T1 * arg2: 'T2 -> func: ('T1 -> 'T2 -> 'U) -> 'U
Full name: Microsoft.FSharp.Core.Operators.(
||>
)
"val (
||>)
: arg1: 'T1 * arg2: 'T2 -> func: ('T1 -> 'T2 -> 'U) -> 'U
Full name: Microsoft.FSharp.Core.Operators.(
||>
)
'T1 is float
'T2 is int list
'U is float"
);
...
...
@@ -164,22 +155,22 @@ Full name: Microsoft.FSharp.Collections.List.fold
'State is float"
);
(
"let res4 = (1.0,[1]) ||> List.fold (fun s x -> string s +"
,
Some
"val (
+ ) : x:'T1 -> y:'T2 -> 'T3 (requires member ( +
))
Full name: Microsoft.FSharp.Core.Operators.(
+
)
"val (
+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+
))
Full name: Microsoft.FSharp.Core.Operators.(
+
)
'T1 is string
'T2 is string
'T3 is float"
);
(
"let res5 = 1 +"
,
Some
"val (
+ ) : x:'T1 -> y:'T2 -> 'T3 (requires member ( +
))
Full name: Microsoft.FSharp.Core.Operators.(
+
)
"val (
+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+
))
Full name: Microsoft.FSharp.Core.Operators.(
+
)
'T1 is int
'T2 is int
'T3 is int"
);
(
"let res6 = System.DateTime.Now +"
,
Some
"val (
+ ) : x:'T1 -> y:'T2 -> 'T3 (requires member ( +
))
Full name: Microsoft.FSharp.Core.Operators.(
+
)
"val (
+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+
))
Full name: Microsoft.FSharp.Core.Operators.(
+
)
'T1 is System.DateTime
'T2 is System.TimeSpan
'T3 is System.DateTime"
);
...
...
@@ -221,15 +212,16 @@ let res7 = sin 5.0
let res8 = abs 5.0<kg>
"""
let
caretPosition
=
fileContents
.
IndexOf
(
symbol
)
+
symbol
.
Length
-
1
let
document
Id
=
DocumentId
.
CreateNewId
(
ProjectId
.
CreateNewId
()
)
let
document
,
_
=
RoslynTestHelpers
.
CreateDocument
(
filePath
,
fileContents
)
let
parsingOptions
,
_
=
checker
.
GetParsingOptionsFromProjectOptions
projectOptions
let
quickInfo
=
FSharpAsyncQuickInfoSource
.
ProvideQuickInfo
(
checker
,
documentId
,
SourceText
.
From
(
fileContents
),
filePath
,
caretPosition
,
parsingOptions
,
projectOptions
,
0
)
FSharpAsyncQuickInfoSource
.
ProvideQuickInfo
(
document
,
caretPosition
)
|>
Async
.
RunSynchronously
let
actual
=
quickInfo
|>
Option
.
map
(
fun
(
text
,
_,
_,
_)
->
getQuickInfoText
t
ext
)
let
actual
=
quickInfo
|>
Option
.
map
(
fun
qi
->
getQuickInfoText
qi
.
StructuredT
ext
)
yield
symbol
,
actual
]
printfn
"results:
\n
%A"
actualForAllTests
for
((
symbol
,
expected
),(_,
actual
))
in
List
.
zip
testCases
actualForAllTests
do
Assert
.
AreEqual
(
Option
.
map
normalizeLineEnds
expected
,
Option
.
map
normalizeLineEnds
actual
)
\ No newline at end of file
for
((_,
expected
),(_,
actual
))
in
List
.
zip
testCases
actualForAllTests
do
let
normalizedExpected
=
Option
.
map
normalizeLineEnds
expected
let
normalizedActual
=
Option
.
map
normalizeLineEnds
actual
Assert
.
AreEqual
(
normalizedExpected
,
normalizedActual
)
vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj
浏览文件 @
8b6c0cef
...
...
@@ -107,11 +107,9 @@
<Compile
Include=
"GoToDefinitionServiceTests.fs"
>
<Link>
Roslyn\GoToDefinitionServiceTests.fs
</Link>
</Compile>
<!--
<Compile
Include=
"QuickInfoProviderTests.fs"
>
<Link>
Roslyn\QuickInfoProviderTests.fs
</Link>
</Compile>
-->
<Compile
Include=
"DocumentHighlightsServiceTests.fs"
>
<Link>
Roslyn\DocumentHighlightsServiceTests.fs
</Link>
</Compile>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录