Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
21316855
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
21316855
编写于
5月 13, 2020
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add FindReferences tests for Kind column/SymbolUsageInfo for references
上级
4994a53a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
301 addition
and
10 deletion
+301
-10
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.FieldSymbols.vb
.../Test2/FindReferences/FindReferencesTests.FieldSymbols.vb
+35
-0
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.LocalSymbols.vb
.../Test2/FindReferences/FindReferencesTests.LocalSymbols.vb
+33
-0
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.NamedTypeSymbols.vb
...t2/FindReferences/FindReferencesTests.NamedTypeSymbols.vb
+43
-0
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.NamespaceSymbols.vb
...t2/FindReferences/FindReferencesTests.NamespaceSymbols.vb
+30
-0
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.ParameterSymbol.vb
...st2/FindReferences/FindReferencesTests.ParameterSymbol.vb
+33
-0
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.PropertySymbols.vb
...st2/FindReferences/FindReferencesTests.PropertySymbols.vb
+36
-0
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.vb
...ditorFeatures/Test2/FindReferences/FindReferencesTests.vb
+91
-10
未找到文件。
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.FieldSymbols.vb
浏览文件 @
21316855
...
@@ -411,6 +411,41 @@ class Definition:Program
...
@@ -411,6 +411,41 @@ class Definition:Program
]]
>
]]
>
</
Document
>
</
Document
>
</
Project
>
</
Project
>
</
Workspace
>
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
End
Function
<
WpfTheory
,
CombinatorialData
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
FindReferences
)
>
Public
Async
Function
TestField_ValueUsageInfo
(
kind
As
TestKind
,
host
As
TestHost
)
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
>
class
C
{
int
{
|
Definition
:
$$
i
|
}
;
void
Goo
()
{
Console
.
WriteLine
({
|
ValueUsageInfo
.
Read
:
[|
i
|]|
})
;
{
|
ValueUsageInfo
.
Write
:
[|
i
|]|
}
=
0
;
{
|
ValueUsageInfo
.
ReadWrite
:
[|
i
|]|
}
++
;
Goo2
(
in
{
|
ValueUsageInfo
.
ReadableReference
:
[|
i
|]|
},
ref
{
|
ValueUsageInfo
.
ReadableWritableReference
:
[|
i
|]|
})
;
Goo3
(
out
{
|
ValueUsageInfo
.
WritableReference
:
[|
i
|]|
})
;
Console
.
WriteLine
(
nameof
({
|
ValueUsageInfo
.
Name
:
[|
i
|]|
}))
;
}
void
Goo2
(
in
int
j
,
ref
int
k
)
{
}
void
Goo3
(
out
int
i
)
{
i
=
0
;
}
}
</
Document
>
</
Project
>
</
Workspace
>
</
Workspace
>
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
End
Function
End
Function
...
...
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.LocalSymbols.vb
浏览文件 @
21316855
...
@@ -541,5 +541,38 @@ End Module
...
@@ -541,5 +541,38 @@ End Module
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
End
Function
End
Function
<
WpfTheory
,
CombinatorialData
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
FindReferences
)
>
Public
Async
Function
TestLocal_ValueUsageInfo
(
kind
As
TestKind
,
host
As
TestHost
)
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
>
class
C
{
void
Goo
()
{
int
{
|
Definition
:
$$
i
|
}
=
0
;
Console
.
WriteLine
({
|
ValueUsageInfo
.
Read
:
[|
i
|]|
})
;
{
|
ValueUsageInfo
.
Write
:
[|
i
|]|
}
=
0
;
{
|
ValueUsageInfo
.
ReadWrite
:
[|
i
|]|
}
++
;
Goo2
(
in
{
|
ValueUsageInfo
.
ReadableReference
:
[|
i
|]|
},
ref
{
|
ValueUsageInfo
.
ReadableWritableReference
:
[|
i
|]|
})
;
Goo3
(
out
{
|
ValueUsageInfo
.
WritableReference
:
[|
i
|]|
})
;
Console
.
WriteLine
(
nameof
({
|
ValueUsageInfo
.
Name
:
[|
i
|]|
}))
;
}
void
Goo2
(
in
int
j
,
ref
int
k
)
{
}
void
Goo3
(
out
int
i
)
{
i
=
0
;
}
}
</
Document
>
</
Project
>
</
Workspace
>
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
End
Function
End
Class
End
Class
End
Namespace
End
Namespace
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.NamedTypeSymbols.vb
浏览文件 @
21316855
...
@@ -2189,5 +2189,48 @@ public class D { }
...
@@ -2189,5 +2189,48 @@ public class D { }
End
Function
End
Function
<
WpfTheory
,
CombinatorialData
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
FindReferences
)
>
Public
Async
Function
TestNamedType_TypeOrNamespaceUsageInfo
(
kind
As
TestKind
,
host
As
TestHost
)
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
><
!
[
CDATA
[
namespace
N1
{
using
Alias1
=
N2
.
{|
TypeOrNamespaceUsageInfo
.
Import
:
[|
Class1
|]|
}
;
}
namespace
N2
{
public
interface
I
<
T
>
{
}
public
class
{
|
Definition
:
$$
Class1
|
}
{
public
static
int
Field
;
public
class
Nested
{
}
}
public
class
Class2
:
{
|
TypeOrNamespaceUsageInfo
.
Base
:
[|
Class1
|]|
},
I
<
{
|
TypeOrNamespaceUsageInfo
.
TypeArgument
:
[|
Class1
|]|
}
>
{
public
static
int
M
()
=>
{
|
TypeOrNamespaceUsageInfo
.
Qualified
:
[|
Class1
|]|
}.
Field
;
}
}
namespace
N2
.
N3
{
using
Alias2
=
N2
.
{|
TypeOrNamespaceUsageInfo
.
Qualified
,
Import
:
[|
Class1
|]|
}.
Nested
;
public
class
Class3
:
{
|
TypeOrNamespaceUsageInfo
.
Qualified
,
Base
:
[|
Class1
|]|
}.
Nested
,
I
<
{
|
TypeOrNamespaceUsageInfo
.
Qualified
,
TypeArgument
:
[|
Class1
|]|
}.
Nested
>
{
public
static
[|
Class1
|]
M2
()
=>
new
{
|
TypeOrNamespaceUsageInfo
.
ObjectCreation
:
[|
Class1
|]|
}()
;
}
}
]]
>
</
Document
>
</
Project
>
</
Workspace
>
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
End
Function
End
Class
End
Class
End
Namespace
End
Namespace
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.NamespaceSymbols.vb
浏览文件 @
21316855
...
@@ -372,5 +372,35 @@ namespace var { }
...
@@ -372,5 +372,35 @@ namespace var { }
</
Workspace
>
</
Workspace
>
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
End
Function
End
Function
<
WpfTheory
,
CombinatorialData
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
FindReferences
)
>
Public
Async
Function
TestNamespace_TypeOrNamespaceUsageInfo
(
host
As
TestHost
)
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
>
using
{
|
TypeOrNamespaceUsageInfo
.
Import
:
[|
N1
|]|
}
;
using
{
|
TypeOrNamespaceUsageInfo
.
Qualified
,
Import
:
[|
N1
|]|
}.
N2
;
namespace
{
|
Definition
:{
|
TypeOrNamespaceUsageInfo
.
NamespaceDeclaration
:
[|$$
N1
|]|
}
|
}
{
public
class
Class1
{
public
static
int
Field
;
}
}
namespace
{
|
TypeOrNamespaceUsageInfo
.
Qualified
,
NamespaceDeclaration
:
[|
N1
|]|
}.
N2
{
public
class
Class2
{
public
static
int
M
()
=>
{
|
TypeOrNamespaceUsageInfo
.
Qualified
:
[|
N1
|]|
}.
Class1
.
Field
;
}
}
</
Document
>
</
Project
>
</
Workspace
>
Await
TestAPI
(
input
,
host
)
End
Function
End
Class
End
Class
End
Namespace
End
Namespace
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.ParameterSymbol.vb
浏览文件 @
21316855
...
@@ -635,6 +635,39 @@ end class
...
@@ -635,6 +635,39 @@ end class
}
}
</
Document
>
</
Document
>
</
Project
>
</
Project
>
</
Workspace
>
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
End
Function
<
WpfTheory
,
CombinatorialData
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
FindReferences
)
>
Public
Async
Function
TestParameter_ValueUsageInfo
(
kind
As
TestKind
,
host
As
TestHost
)
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
>
class
C
{
void
Goo
(
int
{
|
Definition
:
$$
i
|
})
{
Console
.
WriteLine
({
|
ValueUsageInfo
.
Read
:
[|
i
|]|
})
;
{
|
ValueUsageInfo
.
Write
:
[|
i
|]|
}
=
0
;
{
|
ValueUsageInfo
.
ReadWrite
:
[|
i
|]|
}
++
;
Goo2
(
in
{
|
ValueUsageInfo
.
ReadableReference
:
[|
i
|]|
},
ref
{
|
ValueUsageInfo
.
ReadableWritableReference
:
[|
i
|]|
})
;
Goo3
(
out
{
|
ValueUsageInfo
.
WritableReference
:
[|
i
|]|
})
;
Console
.
WriteLine
(
nameof
({
|
ValueUsageInfo
.
Name
:
[|
i
|]|
}))
;
}
void
Goo2
(
in
int
j
,
ref
int
k
)
{
}
void
Goo3
(
out
int
i
)
{
i
=
0
;
}
}
</
Document
>
</
Project
>
</
Workspace
>
</
Workspace
>
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
End
Function
End
Function
...
...
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.PropertySymbols.vb
浏览文件 @
21316855
...
@@ -912,5 +912,41 @@ interface IC
...
@@ -912,5 +912,41 @@ interface IC
</
Workspace
>
</
Workspace
>
Await
TestStreamingFeature
(
input
,
host
)
Await
TestStreamingFeature
(
input
,
host
)
End
Function
End
Function
<
WorkItem
(
538886
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538886"
)
>
<
WpfTheory
,
CombinatorialData
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
FindReferences
)
>
Public
Async
Function
TestProperty_ValueUsageInfo
(
kind
As
TestKind
,
host
As
TestHost
)
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
>
using
System
;
namespace
ConsoleApplication22
{
class
Program
{
static
public
int
{
|
Definition
:
G
$$
oo
|
}
{
get
{
return
1
;
}
set
{
}
}
static
void
Main
(
string
[]
args
)
{
Console
.
WriteLine
(
Program
.
{|
ValueUsageInfo
.
Read
:
[|
Goo
|]|
})
;
Program
.
{|
ValueUsageInfo
.
Write
:
[|
Goo
|]|
}
=
0
;
Program
.
{|
ValueUsageInfo
.
ReadWrite
:
[|
Goo
|]|
}
+=
1
;
}
}
}
</
Document
>
</
Project
>
</
Workspace
>
Await
TestAPIAndFeature
(
input
,
kind
,
host
)
End
Function
End
Class
End
Class
End
Namespace
End
Namespace
src/EditorFeatures/Test2/FindReferences/FindReferencesTests.vb
浏览文件 @
21316855
...
@@ -19,6 +19,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
...
@@ -19,6 +19,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
<
[
UseExportProvider
]
>
<
[
UseExportProvider
]
>
Partial
Public
Class
FindReferencesTests
Partial
Public
Class
FindReferencesTests
Private
Const
DefinitionKey
As
String
=
"Definition"
Private
Const
DefinitionKey
As
String
=
"Definition"
Private
Const
ValueUsageInfoKey
As
String
=
"ValueUsageInfo."
Private
Const
TypeOrNamespaceUsageInfoKey
As
String
=
"TypeOrNamespaceUsageInfo."
Private
ReadOnly
_outputHelper
As
ITestOutputHelper
Private
ReadOnly
_outputHelper
As
ITestOutputHelper
...
@@ -96,6 +98,37 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
...
@@ -96,6 +98,37 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
context
.
References
.
Select
(
Function
(
r
)
r
.
SourceSpan
))
context
.
References
.
Select
(
Function
(
r
)
r
.
SourceSpan
))
Assert
.
Equal
(
expectedReferences
,
actualReferences
)
Assert
.
Equal
(
expectedReferences
,
actualReferences
)
Dim
valueUsageInfoKeys
=
workspace
.
Documents
.
SelectMany
(
Function
(
d
)
d
.
AnnotatedSpans
.
Keys
.
Where
(
Function
(
key
)
key
.
StartsWith
(
ValueUsageInfoKey
)))
For
Each
key
In
valueUsageInfoKeys
Dim
expected
=
workspace
.
Documents
.
Where
(
Function
(
d
)
d
.
AnnotatedSpans
.
ContainsKey
(
key
)
AndAlso
d
.
AnnotatedSpans
(
key
).
Any
()).
OrderBy
(
Function
(
d
)
d
.
Name
).
Select
(
Function
(
d
)
New
FileNameAndSpans
(
d
.
Name
,
d
.
AnnotatedSpans
(
key
).
ToList
())).
ToList
()
Dim
valueUsageInfoField
=
key
.
Substring
(
ValueUsageInfoKey
.
Length
)
Dim
actual
=
GetFileNamesAndSpans
(
context
.
References
.
Where
(
Function
(
r
)
r
.
SymbolUsageInfo
.
ValueUsageInfoOpt
?
.
ToString
()
=
valueUsageInfoField
).
Select
(
Function
(
r
)
r
.
SourceSpan
))
Assert
.
Equal
(
expected
,
actual
)
Next
Dim
typeOrNamespaceUsageInfoKeys
=
workspace
.
Documents
.
SelectMany
(
Function
(
d
)
d
.
AnnotatedSpans
.
Keys
.
Where
(
Function
(
key
)
key
.
StartsWith
(
TypeOrNamespaceUsageInfoKey
)))
For
Each
key
In
typeOrNamespaceUsageInfoKeys
Dim
expected
=
workspace
.
Documents
.
Where
(
Function
(
d
)
d
.
AnnotatedSpans
.
ContainsKey
(
key
)
AndAlso
d
.
AnnotatedSpans
(
key
).
Any
()).
OrderBy
(
Function
(
d
)
d
.
Name
).
Select
(
Function
(
d
)
New
FileNameAndSpans
(
d
.
Name
,
d
.
AnnotatedSpans
(
key
).
ToList
())).
ToList
()
Dim
typeOrNamespaceUsageInfoFieldNames
=
key
.
Substring
(
TypeOrNamespaceUsageInfoKey
.
Length
).
Split
(
","
c
).
Select
(
Function
(
s
)
s
.
Trim
)
Dim
actual
=
GetFileNamesAndSpans
(
context
.
References
.
Where
(
Function
(
r
)
Return
r
.
SymbolUsageInfo
.
TypeOrNamespaceUsageInfoOpt
IsNot
Nothing
AndAlso
r
.
SymbolUsageInfo
.
TypeOrNamespaceUsageInfoOpt
.
ToString
().
Split
(
","
c
).
Select
(
Function
(
s
)
s
.
Trim
).
SetEquals
(
typeOrNamespaceUsageInfoFieldNames
)
End
Function
).
Select
(
Function
(
r
)
r
.
SourceSpan
))
Assert
.
Equal
(
expected
,
actual
)
Next
Next
Next
End
Using
End
Using
End
Function
End
Function
...
@@ -226,7 +259,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
...
@@ -226,7 +259,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
Assert
.
Equal
(
Of
String
)(
documentsWithAnnotatedSpans
.
Select
(
Function
(
d
)
GetFilePathAndProjectLabel
(
workspace
,
d
)).
Order
(),
actualDefinitions
.
Keys
.
Order
())
Assert
.
Equal
(
Of
String
)(
documentsWithAnnotatedSpans
.
Select
(
Function
(
d
)
GetFilePathAndProjectLabel
(
workspace
,
d
)).
Order
(),
actualDefinitions
.
Keys
.
Order
())
For
Each
doc
In
documentsWithAnnotatedSpans
For
Each
doc
In
documentsWithAnnotatedSpans
Dim
expected
=
doc
.
AnnotatedSpans
(
DefinitionKe
y
).
Order
()
Dim
expected
=
If
(
doc
.
AnnotatedSpans
.
ContainsKey
(
DefinitionKey
),
doc
.
AnnotatedSpans
(
DefinitionKey
),
ImmutableArray
(
Of
TextSpan
).
Empt
y
).
Order
()
Dim
actual
=
actualDefinitions
(
GetFilePathAndProjectLabel
(
workspace
,
doc
)).
Order
()
Dim
actual
=
actualDefinitions
(
GetFilePathAndProjectLabel
(
workspace
,
doc
)).
Order
()
If
Not
TextSpansMatch
(
expected
,
actual
)
Then
If
Not
TextSpansMatch
(
expected
,
actual
)
Then
...
@@ -234,15 +267,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
...
@@ -234,15 +267,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
End
If
End
If
Next
Next
Dim
actualReferences
=
Dim
actualReferences
=
GetActualReferences
(
result
,
uiVisibleOnly
,
options
,
document
,
workspace
)
result
.
FilterToItemsToShow
(
options
).
SelectMany
(
Function
(
r
)
r
.
Locations
.
Select
(
Function
(
loc
)
loc
.
Location
)).
Where
(
Function
(
loc
)
IsInSource
(
workspace
,
loc
,
uiVisibleOnly
)).
Distinct
().
GroupBy
(
Function
(
loc
)
loc
.
SourceTree
).
ToDictionary
(
Function
(
g
)
GetFilePathAndProjectLabel
(
document
.
Project
.
Solution
,
g
.
Key
),
Function
(
g
)
g
.
Select
(
Function
(
loc
)
loc
.
SourceSpan
).
Distinct
().
ToList
())
Dim
expectedDocuments
=
workspace
.
Documents
.
Where
(
Function
(
d
)
d
.
SelectedSpans
.
Any
())
Dim
expectedDocuments
=
workspace
.
Documents
.
Where
(
Function
(
d
)
d
.
SelectedSpans
.
Any
())
Assert
.
Equal
(
expectedDocuments
.
Select
(
Function
(
d
)
GetFilePathAndProjectLabel
(
workspace
,
d
)).
Order
(),
actualReferences
.
Keys
.
Order
())
Assert
.
Equal
(
expectedDocuments
.
Select
(
Function
(
d
)
GetFilePathAndProjectLabel
(
workspace
,
d
)).
Order
(),
actualReferences
.
Keys
.
Order
())
...
@@ -254,10 +279,66 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
...
@@ -254,10 +279,66 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
AssertEx
.
Equal
(
expectedSpans
,
actualSpans
,
AssertEx
.
Equal
(
expectedSpans
,
actualSpans
,
message
:
=
PrintSpans
(
expectedSpans
,
actualSpans
,
workspace
.
CurrentSolution
.
GetDocument
(
doc
.
Id
),
"[|"
,
"|]"
,
messageOnly
:
=
True
))
message
:
=
PrintSpans
(
expectedSpans
,
actualSpans
,
workspace
.
CurrentSolution
.
GetDocument
(
doc
.
Id
),
"[|"
,
"|]"
,
messageOnly
:
=
True
))
Next
Next
Dim
valueUsageInfoKeys
=
workspace
.
Documents
.
SelectMany
(
Function
(
d
)
d
.
AnnotatedSpans
.
Keys
.
Where
(
Function
(
key
)
key
.
StartsWith
(
ValueUsageInfoKey
)))
For
Each
key
In
valueUsageInfoKeys
For
Each
doc
In
documentsWithAnnotatedSpans
.
Where
(
Function
(
d
)
d
.
AnnotatedSpans
.
ContainsKey
(
key
))
Dim
expectedSpans
=
doc
.
AnnotatedSpans
(
key
).
Order
()
Dim
valueUsageInfoField
=
key
.
Substring
(
ValueUsageInfoKey
.
Length
)
actualReferences
=
GetActualReferences
(
result
,
uiVisibleOnly
,
options
,
document
,
workspace
,
Function
(
r
)
r
.
SymbolUsageInfo
.
ValueUsageInfoOpt
?
.
ToString
()
=
valueUsageInfoField
)
Dim
actualSpans
=
actualReferences
(
GetFilePathAndProjectLabel
(
workspace
,
doc
)).
Order
()
If
Not
TextSpansMatch
(
expectedSpans
,
actualSpans
)
Then
Assert
.
True
(
False
,
PrintSpans
(
expectedSpans
,
actualSpans
,
workspace
.
CurrentSolution
.
GetDocument
(
doc
.
Id
),
$
"{{|{key}:"
,
"|}"
))
End
If
Next
Next
Dim
typeOrNamespaceUsageInfoKeys
=
workspace
.
Documents
.
SelectMany
(
Function
(
d
)
d
.
AnnotatedSpans
.
Keys
.
Where
(
Function
(
key
)
key
.
StartsWith
(
TypeOrNamespaceUsageInfoKey
)))
For
Each
key
In
typeOrNamespaceUsageInfoKeys
For
Each
doc
In
documentsWithAnnotatedSpans
.
Where
(
Function
(
d
)
d
.
AnnotatedSpans
.
ContainsKey
(
key
))
Dim
expectedSpans
=
doc
.
AnnotatedSpans
(
key
).
Order
()
Dim
typeOrNamespaceUsageInfoFieldNames
=
key
.
Substring
(
TypeOrNamespaceUsageInfoKey
.
Length
).
Split
(
","
c
).
Select
(
Function
(
s
)
s
.
Trim
)
actualReferences
=
GetActualReferences
(
result
,
uiVisibleOnly
,
options
,
document
,
workspace
,
Function
(
r
)
Return
r
.
SymbolUsageInfo
.
TypeOrNamespaceUsageInfoOpt
IsNot
Nothing
AndAlso
r
.
SymbolUsageInfo
.
TypeOrNamespaceUsageInfoOpt
.
ToString
().
Split
(
","
c
).
Select
(
Function
(
s
)
s
.
Trim
).
SetEquals
(
typeOrNamespaceUsageInfoFieldNames
)
End
Function
)
Dim
actualSpans
=
actualReferences
(
GetFilePathAndProjectLabel
(
workspace
,
doc
)).
Order
()
If
Not
TextSpansMatch
(
expectedSpans
,
actualSpans
)
Then
Assert
.
True
(
False
,
PrintSpans
(
expectedSpans
,
actualSpans
,
workspace
.
CurrentSolution
.
GetDocument
(
doc
.
Id
),
$
"{{|{key}:"
,
"|}"
))
End
If
Next
Next
Next
Next
End
Using
End
Using
End
Function
End
Function
Private
Shared
Function
GetActualReferences
(
result
As
IEnumerable
(
Of
ReferencedSymbol
),
uiVisibleOnly
As
Boolean
,
options
As
FindReferencesSearchOptions
,
document
As
Document
,
workspace
As
TestWorkspace
,
Optional
locationFilterOpt
As
Func
(
Of
ReferenceLocation
,
Boolean
)
=
Nothing
)
As
Dictionary
(
Of
String
,
List
(
Of
TextSpan
))
Dim
referenceLocations
=
result
.
FilterToItemsToShow
(
options
).
SelectMany
(
Function
(
r
)
r
.
Locations
)
If
locationFilterOpt
IsNot
Nothing
Then
referenceLocations
=
referenceLocations
.
Where
(
locationFilterOpt
)
End
If
Return
referenceLocations
.
Select
(
Function
(
loc
)
loc
.
Location
).
Where
(
Function
(
loc
)
IsInSource
(
workspace
,
loc
,
uiVisibleOnly
)).
Distinct
().
GroupBy
(
Function
(
loc
)
loc
.
SourceTree
).
ToDictionary
(
Function
(
g
)
GetFilePathAndProjectLabel
(
document
.
Project
.
Solution
,
g
.
Key
),
Function
(
g
)
g
.
Select
(
Function
(
loc
)
loc
.
SourceSpan
).
Distinct
().
ToList
())
End
Function
Private
Shared
Function
PrintSpans
(
expected
As
IOrderedEnumerable
(
Of
TextSpan
),
actual
As
IOrderedEnumerable
(
Of
TextSpan
),
doc
As
Document
,
prefix
As
String
,
suffix
As
String
,
Optional
messageOnly
As
Boolean
=
False
)
As
String
Private
Shared
Function
PrintSpans
(
expected
As
IOrderedEnumerable
(
Of
TextSpan
),
actual
As
IOrderedEnumerable
(
Of
TextSpan
),
doc
As
Document
,
prefix
As
String
,
suffix
As
String
,
Optional
messageOnly
As
Boolean
=
False
)
As
String
Debug
.
Assert
(
expected
IsNot
Nothing
)
Debug
.
Assert
(
expected
IsNot
Nothing
)
Debug
.
Assert
(
actual
IsNot
Nothing
)
Debug
.
Assert
(
actual
IsNot
Nothing
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录