Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
6f719541
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,发现更多精彩内容 >>
提交
6f719541
编写于
9月 28, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/master'
上级
9d9008d0
94ef59bc
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
213 addition
and
157 deletion
+213
-157
Roslyn.sln
Roslyn.sln
+0
-6
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
+1
-1
src/Compilers/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs
...s/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs
+1
-1
src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs
src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs
+69
-1
src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SearchScope.cs
...AddImport/AbstractAddImportCodeFixProvider.SearchScope.cs
+2
-2
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs
...es/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs
+74
-44
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
...es/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
+3
-4
src/Workspaces/CoreTest/FindAllDeclarationsTests.cs
src/Workspaces/CoreTest/FindAllDeclarationsTests.cs
+63
-98
未找到文件。
Roslyn.sln
浏览文件 @
6f719541
...
...
@@ -61,12 +61,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspaces", "Workspaces",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Workspaces", "src\Workspaces\Core\Portable\Workspaces.csproj", "{5F8D2414-064A-4B3A-9B42-8E2A04246BE5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{C41FAB9A-D1D7-4253-B639-D72395B6BA37}"
ProjectSection(SolutionItems) = preProject
NuGet.Config = NuGet.Config
nuget.exe = nuget.exe
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Visualizers", "Visualizers", "{64BDF58B-41BA-A19E-0D34-B5FA598403B6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}"
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
浏览文件 @
6f719541
...
...
@@ -5664,7 +5664,7 @@ private static void CombineExtensionMethodArguments(BoundExpression receiver, An
hasError
=
this
.
CheckInstanceOrStatic
(
node
,
receiver
,
fieldSymbol
,
ref
resultKind
,
diagnostics
);
}
if
(!
hasError
&&
fieldSymbol
.
IsFixed
)
if
(!
hasError
&&
fieldSymbol
.
IsFixed
&&
EnclosingNameofArgument
==
null
)
{
TypeSymbol
receiverType
=
receiver
.
Type
;
hasError
=
...
...
src/Compilers/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs
浏览文件 @
6f719541
...
...
@@ -501,7 +501,7 @@ protected void SetUnreachable()
protected
void
VisitLvalue
(
BoundExpression
node
)
{
if
(
_trackRegions
&&
node
==
this
.
firstInRegion
&&
this
.
regionPlace
==
RegionPlace
.
Before
)
EnterRegion
();
switch
(
node
.
Kind
)
switch
(
node
?
.
Kind
)
{
case
BoundKind
.
Parameter
:
VisitLvalueParameter
((
BoundParameter
)
node
);
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs
浏览文件 @
6f719541
...
...
@@ -1209,7 +1209,7 @@ class Other {
}
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
null
,
new
CSharpCompilationOptions
(
OutputKind
.
ConsoleApplication
).
WithAllowUnsafe
(
true
));
CompileAndVerify
(
compilation
,
expectedOutput
:
CompileAndVerify
(
compilation
,
expectedOutput
:
"MessageType x MessageType"
).
VerifyDiagnostics
();
}
...
...
@@ -1258,5 +1258,73 @@ class Other {
// return nameof(myStruct.MessageType);
Diagnostic
(
ErrorCode
.
ERR_BadArgType
,
"myStruct.MessageType"
).
WithArguments
(
"1"
,
"char*"
,
"char[]"
).
WithLocation
(
26
,
23
));
}
[
Fact
,
WorkItem
(
12696
,
"https://github.com/dotnet/roslyn/issues/12696"
)]
public
void
FixedFieldAccessInsideNameOf
()
{
var
source
=
@"
using System;
struct MyType
{
public static string a = nameof(MyType.normalField);
public static string b = nameof(MyType.fixedField);
public static string c = nameof(fixedField);
public int normalField;
public unsafe fixed short fixedField[6];
public MyType(int i) {
this.normalField = i;
}
}
class EntryPoint
{
public static void Main(string[] args)
{
Console.Write(MyType.a + "" "");
Console.Write(MyType.b + "" "");
Console.Write(MyType.c);
}
}
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
null
,
new
CSharpCompilationOptions
(
OutputKind
.
ConsoleApplication
).
WithAllowUnsafe
(
true
));
CompileAndVerify
(
compilation
,
expectedOutput
:
"normalField fixedField fixedField"
).
VerifyDiagnostics
();
}
[
Fact
,
WorkItem
(
12696
,
"https://github.com/dotnet/roslyn/issues/12696"
)]
public
void
FixedFieldAccessFromInnerClass
()
{
var
source
=
@"
using System;
public struct MyType
{
public static class Inner
{
public static string a = nameof(normalField);
public static string b = nameof(fixedField);
}
public int normalField;
public unsafe fixed short fixedField[6];
}
class EntryPoint
{
public static void Main(string[] args)
{
Console.Write(MyType.Inner.a + "" "");
Console.Write(MyType.Inner.b);
}
}
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
null
,
new
CSharpCompilationOptions
(
OutputKind
.
ConsoleApplication
).
WithAllowUnsafe
(
true
));
CompileAndVerify
(
compilation
,
expectedOutput
:
"normalField fixedField"
).
VerifyDiagnostics
();
}
}
}
src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SearchScope.cs
浏览文件 @
6f719541
...
...
@@ -192,14 +192,14 @@ public override SymbolReference CreateReference<T>(SymbolResult<T> searchResult)
_metadataReference
);
}
protected
override
async
Task
<
I
Enumerable
<
ISymbol
>>
FindDeclarationsAsync
(
protected
override
async
Task
<
I
mmutableArray
<
ISymbol
>>
FindDeclarationsAsync
(
string
name
,
SymbolFilter
filter
,
SearchQuery
searchQuery
)
{
var
service
=
_solution
.
Workspace
.
Services
.
GetService
<
ISymbolTreeInfoCacheService
>();
var
info
=
await
service
.
TryGetMetadataSymbolTreeInfoAsync
(
_solution
,
_metadataReference
,
CancellationToken
).
ConfigureAwait
(
false
);
if
(
info
==
null
)
{
return
SpecializedCollections
.
EmptyEnumerable
<
ISymbol
>()
;
return
ImmutableArray
<
ISymbol
>.
Empty
;
}
return
await
info
.
FindAsync
(
searchQuery
,
_assembly
,
filter
,
CancellationToken
).
ConfigureAwait
(
false
);
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs
浏览文件 @
6f719541
...
...
@@ -187,7 +187,7 @@ public static partial class SymbolFinder
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
list
=
new
List
<
ISymbol
>
();
var
list
=
ArrayBuilder
<
ISymbol
>.
GetInstance
();
// get declarations from the compilation's assembly
await
AddDeclarationsAsync
(
project
,
query
,
criteria
,
list
,
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -208,7 +208,7 @@ public static partial class SymbolFinder
}
}
return
TranslateNamespaces
(
list
,
compilation
);
return
TranslateNamespaces
(
list
.
ToImmutableAndFree
()
,
compilation
);
}
private
static
string
GetMetadataReferenceFilePath
(
MetadataReference
metadataReference
)
...
...
@@ -219,70 +219,92 @@ private static string GetMetadataReferenceFilePath(MetadataReference metadataRef
/// <summary>
/// Makes certain all namespace symbols returned by API are from the compilation.
/// </summary>
private
static
ImmutableArray
<
ISymbol
>
TranslateNamespaces
(
List
<
ISymbol
>
symbols
,
Compilation
compilation
)
private
static
ImmutableArray
<
ISymbol
>
TranslateNamespaces
(
ImmutableArray
<
ISymbol
>
symbols
,
Compilation
compilation
)
{
var
result
=
ArrayBuilder
<
ISymbol
>.
GetInstance
();
var
builder
=
ArrayBuilder
<
ISymbol
>.
GetInstance
();
foreach
(
var
symbol
in
symbols
)
{
var
ns
=
symbol
as
INamespaceSymbol
;
if
(
ns
!=
null
)
{
result
.
Add
(
compilation
.
GetCompilationNamespace
(
ns
));
builder
.
Add
(
compilation
.
GetCompilationNamespace
(
ns
));
}
else
{
result
.
Add
(
symbol
);
builder
.
Add
(
symbol
);
}
}
return
result
.
ToImmutableAndFree
();
var
result
=
builder
.
Count
==
symbols
.
Length
?
symbols
:
builder
.
ToImmutable
();
builder
.
Free
();
return
result
;
}
private
static
async
Task
AddDeclarationsAsync
(
Project
project
,
SearchQuery
query
,
SymbolFilter
filter
,
List
<
ISymbol
>
list
,
CancellationToken
cancellationToken
)
private
static
Task
AddDeclarationsAsync
(
Project
project
,
SearchQuery
query
,
SymbolFilter
filter
,
ArrayBuilder
<
ISymbol
>
list
,
CancellationToken
cancellationToken
)
{
await
AddDeclarationsAsync
(
return
AddDeclarationsAsync
(
project
,
query
,
filter
,
list
,
startingCompilation
:
null
,
startingAssembly
:
null
,
cancellationToken
:
cancellationToken
)
.
ConfigureAwait
(
false
)
;
cancellationToken
:
cancellationToken
);
}
private
static
async
Task
AddDeclarationsAsync
(
Project
project
,
SearchQuery
query
,
SymbolFilter
filter
,
List
<
ISymbol
>
list
,
ArrayBuilder
<
ISymbol
>
list
,
Compilation
startingCompilation
,
IAssemblySymbol
startingAssembly
,
CancellationToken
cancellationToken
)
{
using
(
Logger
.
LogBlock
(
FunctionId
.
SymbolFinder_Project_AddDeclarationsAsync
,
cancellationToken
))
using
(
var
set
=
SharedPools
.
Default
<
HashSet
<
ISymbol
>>().
GetPooledObject
())
{
if
(!
await
project
.
ContainsSymbolsWithNameAsync
(
query
.
GetPredicate
(),
filter
,
cancellationToken
).
ConfigureAwait
(
false
))
{
return
;
}
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
if
(
startingCompilation
!=
null
&&
startingAssembly
!=
null
&&
compilation
.
Assembly
!=
startingAssembly
)
{
// Return symbols from skeleton assembly in this case so that symbols have the same language as startingCompilation.
list
.
AddRange
(
FilterByCriteria
(
compilation
.
GetSymbolsWithName
(
query
.
GetPredicate
(),
filter
,
cancellationToken
),
filter
)
.
Select
(
s
=>
s
.
GetSymbolKey
().
Resolve
(
startingCompilation
,
cancellationToken
:
cancellationToken
).
Symbol
).
WhereNotNull
());
}
else
{
list
.
AddRange
(
FilterByCriteria
(
compilation
.
GetSymbolsWithName
(
query
.
GetPredicate
(),
filter
,
cancellationToken
),
filter
));
}
var
unfilteredSymbols
=
await
GetUnfilteredSymbolsAsync
(
project
,
query
,
filter
,
startingCompilation
,
startingAssembly
,
cancellationToken
).
ConfigureAwait
(
false
);
list
.
AddRange
(
FilterByCriteria
(
unfilteredSymbols
,
filter
));
}
}
private
static
async
Task
<
ImmutableArray
<
ISymbol
>>
GetUnfilteredSymbolsAsync
(
Project
project
,
SearchQuery
query
,
SymbolFilter
filter
,
Compilation
startingCompilation
,
IAssemblySymbol
startingAssembly
,
CancellationToken
cancellationToken
)
{
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
if
(
startingCompilation
!=
null
&&
startingAssembly
!=
null
&&
compilation
.
Assembly
!=
startingAssembly
)
{
// Return symbols from skeleton assembly in this case so that symbols have the same language as startingCompilation.
return
compilation
.
GetSymbolsWithName
(
query
.
GetPredicate
(),
filter
,
cancellationToken
)
.
Select
(
s
=>
s
.
GetSymbolKey
().
Resolve
(
startingCompilation
,
cancellationToken
:
cancellationToken
).
Symbol
)
.
WhereNotNull
()
.
ToImmutableArray
();
}
else
{
return
compilation
.
GetSymbolsWithName
(
query
.
GetPredicate
(),
filter
,
cancellationToken
)
.
ToImmutableArray
();
}
}
private
static
async
Task
AddDeclarationsAsync
(
Solution
solution
,
IAssemblySymbol
assembly
,
PortableExecutableReference
referenceOpt
,
SearchQuery
query
,
SymbolFilter
filter
,
List
<
ISymbol
>
list
,
CancellationToken
cancellationToken
)
SearchQuery
query
,
SymbolFilter
filter
,
ArrayBuilder
<
ISymbol
>
list
,
CancellationToken
cancellationToken
)
{
// All entrypoints to this function are Find functions that are only searching
// for specific strings (i.e. they never do a custom search).
...
...
@@ -367,7 +389,8 @@ public static Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(Project pro
/// <summary>
/// Find the symbols for declarations made in source with the specified name.
/// </summary>
public
static
Task
<
IEnumerable
<
ISymbol
>>
FindSourceDeclarationsAsync
(
Project
project
,
string
name
,
bool
ignoreCase
,
SymbolFilter
filter
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
public
static
async
Task
<
IEnumerable
<
ISymbol
>>
FindSourceDeclarationsAsync
(
Project
project
,
string
name
,
bool
ignoreCase
,
SymbolFilter
filter
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
{
if
(
project
==
null
)
{
...
...
@@ -381,21 +404,22 @@ public static Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(Project pro
if
(
string
.
IsNullOrWhiteSpace
(
name
))
{
return
Specialized
Task
s
.
EmptyEnumerable
<
ISymbol
>();
return
Specialized
Collection
s
.
EmptyEnumerable
<
ISymbol
>();
}
using
(
Logger
.
LogBlock
(
FunctionId
.
SymbolFinder_Project_Name_FindSourceDeclarationsAsync
,
cancellationToken
))
{
return
FindSourceDeclarationsAsyncImpl
(
project
,
SearchQuery
.
Create
(
name
,
ignoreCase
),
filter
,
cancellationToken
);
return
await
FindSourceDeclarationsAsyncImpl
(
project
,
SearchQuery
.
Create
(
name
,
ignoreCase
),
filter
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
private
static
async
Task
<
I
Enumerable
<
ISymbol
>>
FindSourceDeclarationsAsyncImpl
(
private
static
async
Task
<
I
mmutableArray
<
ISymbol
>>
FindSourceDeclarationsAsyncImpl
(
Project
project
,
SearchQuery
query
,
SymbolFilter
filter
,
CancellationToken
cancellationToken
)
{
var
list
=
new
List
<
ISymbol
>
();
var
list
=
ArrayBuilder
<
ISymbol
>.
GetInstance
();
await
AddDeclarationsAsync
(
project
,
query
,
filter
,
list
,
cancellationToken
).
ConfigureAwait
(
false
);
return
list
;
return
list
.
ToImmutableAndFree
()
;
}
/// <summary>
...
...
@@ -452,13 +476,15 @@ public static Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(Project pro
/// <summary>
/// Find the symbols for declarations made in source with a matching name.
/// </summary>
public
static
Task
<
IEnumerable
<
ISymbol
>>
FindSourceDeclarationsAsync
(
public
static
async
Task
<
IEnumerable
<
ISymbol
>>
FindSourceDeclarationsAsync
(
Project
project
,
Func
<
string
,
bool
>
predicate
,
SymbolFilter
filter
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
{
return
FindSourceDeclarationsAsync
(
project
,
SearchQuery
.
CreateCustom
(
predicate
),
filter
,
cancellationToken
);
return
await
FindSourceDeclarationsAsync
(
project
,
SearchQuery
.
CreateCustom
(
predicate
),
filter
,
cancellationToken
).
ConfigureAwait
(
false
);
}
internal
static
async
Task
<
IEnumerable
<
ISymbol
>>
FindSourceDeclarationsAsync
(
Project
project
,
SearchQuery
query
,
SymbolFilter
filter
,
CancellationToken
cancellationToken
)
internal
static
async
Task
<
ImmutableArray
<
ISymbol
>>
FindSourceDeclarationsAsync
(
Project
project
,
SearchQuery
query
,
SymbolFilter
filter
,
CancellationToken
cancellationToken
)
{
if
(
project
==
null
)
{
...
...
@@ -467,28 +493,27 @@ internal static async Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(Pro
if
(
query
.
Name
!=
null
&&
string
.
IsNullOrWhiteSpace
(
query
.
Name
))
{
return
SpecializedCollections
.
EmptyEnumerable
<
ISymbol
>()
;
return
ImmutableArray
<
ISymbol
>.
Empty
;
}
using
(
Logger
.
LogBlock
(
FunctionId
.
SymbolFinder_Project_Predicate_FindSourceDeclarationsAsync
,
cancellationToken
))
{
var
result
=
new
List
<
ISymbol
>();
if
(!
await
project
.
ContainsSymbolsWithNameAsync
(
query
.
GetPredicate
(),
filter
,
cancellationToken
).
ConfigureAwait
(
false
))
{
return
result
;
return
ImmutableArray
<
ISymbol
>.
Empty
;
}
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
result
.
AddRange
(
FilterByCriteria
(
compilation
.
GetSymbolsWithName
(
query
.
GetPredicate
(),
filter
,
cancellationToken
),
filter
)
);
return
result
;
var
unfiltered
=
compilation
.
GetSymbolsWithName
(
query
.
GetPredicate
(),
filter
,
cancellationToken
).
ToImmutableArray
(
);
return
FilterByCriteria
(
unfiltered
,
filter
)
;
}
}
internal
static
ImmutableArray
<
ISymbol
>
FilterByCriteria
(
I
Enumerable
<
ISymbol
>
symbols
,
SymbolFilter
criteria
)
I
mmutableArray
<
ISymbol
>
symbols
,
SymbolFilter
criteria
)
{
var
result
=
ArrayBuilder
<
ISymbol
>.
GetInstance
();
var
builder
=
ArrayBuilder
<
ISymbol
>.
GetInstance
();
foreach
(
var
symbol
in
symbols
)
{
if
(
symbol
.
IsImplicitlyDeclared
||
symbol
.
IsAccessor
())
...
...
@@ -498,11 +523,16 @@ internal static async Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(Pro
if
(
MeetCriteria
(
symbol
,
criteria
))
{
result
.
Add
(
symbol
);
builder
.
Add
(
symbol
);
}
}
return
result
.
ToImmutableAndFree
();
var
result
=
builder
.
Count
==
symbols
.
Length
?
symbols
:
builder
.
ToImmutable
();
builder
.
Free
();
return
result
;
}
private
static
bool
MeetCriteria
(
ISymbol
symbol
,
SymbolFilter
filter
)
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
浏览文件 @
6f719541
...
...
@@ -435,10 +435,10 @@ private int BinarySearch(string name)
{
cancellationToken
.
ThrowIfCancellationRequested
();
var
n
amedType
=
containerSymbol
as
INamed
TypeSymbol
;
if
(
n
amed
Type
!=
null
)
var
n
sOrType
=
containerSymbol
as
INamespaceOr
TypeSymbol
;
if
(
n
sOr
Type
!=
null
)
{
results
.
AddRange
(
n
amed
Type
.
GetMembers
(
GetName
(
node
)));
results
.
AddRange
(
n
sOr
Type
.
GetMembers
(
GetName
(
node
)));
}
}
}
...
...
@@ -554,7 +554,6 @@ internal void AssertEquivalentTo(SymbolTreeInfo other)
builder
.
Add
(
namedType
);
}
}
}
finally
{
...
...
src/Workspaces/CoreTest/FindAllDeclarationsTests.cs
浏览文件 @
6f719541
...
...
@@ -82,7 +82,8 @@ public partial class FindAllDeclarationsTests : TestBase
InlineData
(
"TestCase"
,
true
,
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
[]
{
"TestCase1.TestCase"
,
"TestCase2.TestCase"
}),
InlineData
(
"TestCase"
,
false
,
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
[]
{
"TestCase1.TestCase"
,
"TestCase2.TestCase"
}),
InlineData
(
"TestCase1.TestCase"
,
true
,
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
string
[
0
]),]
public
static
async
Task
FindDeclarationsAsync_Test
(
string
searchTerm
,
bool
ignoreCase
,
WorkspaceKind
workspaceKind
,
string
[]
expectedResults
)
public
async
Task
FindDeclarationsAsync_Test
(
string
searchTerm
,
bool
ignoreCase
,
WorkspaceKind
workspaceKind
,
string
[]
expectedResults
)
{
var
project
=
GetProject
(
workspaceKind
);
var
declarations
=
await
SymbolFinder
.
FindDeclarationsAsync
(
project
,
searchTerm
,
ignoreCase
).
ConfigureAwait
(
false
);
...
...
@@ -90,18 +91,18 @@ public static async Task FindDeclarationsAsync_Test(string searchTerm, bool igno
}
[
Fact
]
public
static
async
Task
FindDeclarationsAsync_Test_NullProject
()
public
async
Task
FindDeclarationsAsync_Test_NullProject
()
{
await
Assert
.
ThrowsAsync
<
ArgumentNullException
>(
async
()
=>
await
Assert
.
ThrowsA
nyA
sync
<
ArgumentNullException
>(
async
()
=>
{
var
declarations
=
await
SymbolFinder
.
FindDeclarationsAsync
(
null
,
"Test"
,
true
);
});
}
[
Fact
]
public
static
async
Task
FindDeclarationsAsync_Test_NullString
()
public
async
Task
FindDeclarationsAsync_Test_NullString
()
{
await
Assert
.
ThrowsAsync
<
ArgumentNullException
>(
async
()
=>
await
Assert
.
ThrowsA
nyA
sync
<
ArgumentNullException
>(
async
()
=>
{
var
project
=
GetProject
(
WorkspaceKind
.
SingleClass
);
var
declarations
=
await
SymbolFinder
.
FindDeclarationsAsync
(
project
,
null
,
true
);
...
...
@@ -109,9 +110,9 @@ public static async Task FindDeclarationsAsync_Test_NullString()
}
[
Fact
]
public
static
async
Task
FindDeclarationsAsync_Test_Cancellation
()
public
async
Task
FindDeclarationsAsync_Test_Cancellation
()
{
await
Assert
.
ThrowsAsync
<
TaskCanceledException
>(
async
()
=>
await
Assert
.
ThrowsA
nyA
sync
<
TaskCanceledException
>(
async
()
=>
{
var
cts
=
new
CancellationTokenSource
();
cts
.
Cancel
();
...
...
@@ -121,7 +122,7 @@ public static async Task FindDeclarationsAsync_Test_Cancellation()
}
[
Fact
,
WorkItem
(
1094411
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1094411"
)]
public
static
async
Task
FindDeclarationsAsync_Metadata
()
public
async
Task
FindDeclarationsAsync_Metadata
()
{
var
solution
=
CreateSolution
();
var
csharpId
=
ProjectId
.
CreateNewId
();
...
...
@@ -142,7 +143,7 @@ public static async Task FindDeclarationsAsync_Metadata()
}
[
Fact
,
WorkItem
(
6616
,
"https://github.com/dotnet/roslyn/issues/6616"
)]
public
static
async
Task
FindDeclarationsAsync_PreviousSubmission
()
public
async
Task
FindDeclarationsAsync_PreviousSubmission
()
{
var
solution
=
CreateSolution
();
...
...
@@ -246,7 +247,8 @@ public class Inner
InlineData
(
"TestCase"
,
true
,
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
[]
{
"TestCase1.TestCase"
,
"TestCase2.TestCase"
}),
InlineData
(
"TestCase"
,
false
,
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
[]
{
"TestCase1.TestCase"
,
"TestCase2.TestCase"
}),
InlineData
(
"TestCase1.TestCase"
,
true
,
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
string
[
0
]),]
public
static
async
Task
FindSourceDeclarationsAsync_Project_Test
(
string
searchTerm
,
bool
ignoreCase
,
WorkspaceKind
workspaceKind
,
string
[]
expectedResults
)
public
async
Task
FindSourceDeclarationsAsync_Project_Test
(
string
searchTerm
,
bool
ignoreCase
,
WorkspaceKind
workspaceKind
,
string
[]
expectedResults
)
{
var
project
=
GetProject
(
workspaceKind
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
project
,
searchTerm
,
ignoreCase
).
ConfigureAwait
(
false
);
...
...
@@ -254,18 +256,18 @@ public static async Task FindSourceDeclarationsAsync_Project_Test(string searchT
}
[
Fact
]
public
static
async
Task
FindSourceDeclarationsAsync_Project_Test_NullProject
()
public
async
Task
FindSourceDeclarationsAsync_Project_Test_NullProject
()
{
await
Assert
.
ThrowsAsync
<
ArgumentNullException
>(
async
()
=>
await
Assert
.
ThrowsA
nyA
sync
<
ArgumentNullException
>(
async
()
=>
{
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
((
Project
)
null
,
"Test"
,
true
);
});
}
[
Fact
]
public
static
async
Task
FindSourceDeclarationsAsync_Project_Test_NullString
()
public
async
Task
FindSourceDeclarationsAsync_Project_Test_NullString
()
{
await
Assert
.
ThrowsAsync
<
ArgumentNullException
>(
async
()
=>
await
Assert
.
ThrowsA
nyA
sync
<
ArgumentNullException
>(
async
()
=>
{
var
project
=
GetProject
(
WorkspaceKind
.
SingleClass
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
project
,
null
,
true
);
...
...
@@ -273,9 +275,9 @@ public static async Task FindSourceDeclarationsAsync_Project_Test_NullString()
}
[
Fact
]
public
static
async
Task
FindSourceDeclarationsAsync_Project_Test_Cancellation
()
public
async
Task
FindSourceDeclarationsAsync_Project_Test_Cancellation
()
{
await
Assert
.
ThrowsAsync
<
TaskCanceledException
>(
async
()
=>
await
Assert
.
ThrowsA
nyA
sync
<
TaskCanceledException
>(
async
()
=>
{
var
cts
=
new
CancellationTokenSource
();
var
project
=
GetProject
(
WorkspaceKind
.
SingleClass
);
...
...
@@ -353,7 +355,8 @@ public static async Task FindSourceDeclarationsAsync_Project_Test_Cancellation()
InlineData
(
"TestCase"
,
true
,
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
[]
{
"TestCase1.TestCase"
,
"TestCase2.TestCase"
}),
InlineData
(
"TestCase"
,
false
,
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
[]
{
"TestCase1.TestCase"
,
"TestCase2.TestCase"
}),
InlineData
(
"TestCase1.TestCase"
,
true
,
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
string
[
0
]),]
public
static
async
Task
FindSourceDeclarationsAsync_Solution_Test
(
string
searchTerm
,
bool
ignoreCase
,
WorkspaceKind
workspaceKind
,
string
[]
expectedResults
)
public
async
Task
FindSourceDeclarationsAsync_Solution_Test
(
string
searchTerm
,
bool
ignoreCase
,
WorkspaceKind
workspaceKind
,
string
[]
expectedResults
)
{
var
solution
=
GetSolution
(
workspaceKind
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
searchTerm
,
ignoreCase
).
ConfigureAwait
(
false
);
...
...
@@ -361,18 +364,18 @@ public static async Task FindSourceDeclarationsAsync_Solution_Test(string search
}
[
Fact
]
public
static
async
Task
FindSourceDeclarationsAsync_Solution_Test_NullProject
()
public
async
Task
FindSourceDeclarationsAsync_Solution_Test_NullProject
()
{
await
Assert
.
ThrowsAsync
<
ArgumentNullException
>(
async
()
=>
await
Assert
.
ThrowsA
nyA
sync
<
ArgumentNullException
>(
async
()
=>
{
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
((
Solution
)
null
,
"Test"
,
true
);
});
}
[
Fact
]
public
static
async
Task
FindSourceDeclarationsAsync_Solution_Test_NullString
()
public
async
Task
FindSourceDeclarationsAsync_Solution_Test_NullString
()
{
await
Assert
.
ThrowsAsync
<
ArgumentNullException
>(
async
()
=>
await
Assert
.
ThrowsA
nyA
sync
<
ArgumentNullException
>(
async
()
=>
{
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
null
,
true
);
...
...
@@ -380,22 +383,14 @@ public static async Task FindSourceDeclarationsAsync_Solution_Test_NullString()
}
[
Fact
]
public
static
void
FindSourceDeclarationsAsync_Solution_Test_Cancellation
()
public
async
Task
FindSourceDeclarationsAsync_Solution_Test_Cancellation
()
{
Assert
.
Throws
<
AggregateException
>(
()
=>
await
Assert
.
ThrowsAnyAsync
<
OperationCanceledException
>(
async
()
=>
{
try
{
var
cts
=
new
CancellationTokenSource
();
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
cts
.
Cancel
();
var
declarations
=
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
"Test"
,
true
,
SymbolFilter
.
All
,
cts
.
Token
).
Result
;
}
catch
(
AggregateException
ex
)
{
VerifyInnerExceptionIsType
<
OperationCanceledException
>(
ex
);
throw
;
}
var
cts
=
new
CancellationTokenSource
();
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
cts
.
Cancel
();
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
"Test"
,
true
,
SymbolFilter
.
All
,
cts
.
Token
);
});
}
...
...
@@ -413,7 +408,8 @@ public static void FindSourceDeclarationsAsync_Solution_Test_Cancellation()
InlineData
(
WorkspaceKind
.
TwoProjectsEachWithASingleClassWithSingleField
,
new
[]
{
"TestCases"
,
"TestCases.TestCase"
,
"TestCases.TestCase.TestField"
}),
InlineData
(
WorkspaceKind
.
NestedClass
,
new
[]
{
"TestCases"
,
"TestCases.TestCase"
,
"TestCases.TestCase.InnerTestCase"
}),
InlineData
(
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
[]
{
"TestCase1"
,
"TestCase1.TestCase"
,
"TestCase2.TestCase"
,
"TestCase2"
}),]
public
static
async
Task
FindSourceDeclarationsAsync_Project_Func_Test
(
WorkspaceKind
workspaceKind
,
string
[]
expectedResults
)
public
async
Task
FindSourceDeclarationsAsync_Project_Func_Test
(
WorkspaceKind
workspaceKind
,
string
[]
expectedResults
)
{
var
project
=
GetProject
(
workspaceKind
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
project
,
str
=>
str
.
Contains
(
"Test"
)).
ConfigureAwait
(
false
);
...
...
@@ -421,7 +417,7 @@ public static async Task FindSourceDeclarationsAsync_Project_Func_Test(Workspace
}
[
Fact
]
public
static
async
Task
FindSourceDeclarationsAsync_Project_Func_Test_AlwaysTruePredicate
()
public
async
Task
FindSourceDeclarationsAsync_Project_Func_Test_AlwaysTruePredicate
()
{
var
project
=
GetProject
(
WorkspaceKind
.
SingleClass
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
project
,
str
=>
true
).
ConfigureAwait
(
false
);
...
...
@@ -429,7 +425,7 @@ public static async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysTru
}
[
Fact
]
public
static
async
Task
FindSourceDeclarationsAsync_Project_Func_Test_AlwaysFalsePredicate
()
public
async
Task
FindSourceDeclarationsAsync_Project_Func_Test_AlwaysFalsePredicate
()
{
var
project
=
GetProject
(
WorkspaceKind
.
SingleClass
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
project
,
str
=>
false
).
ConfigureAwait
(
false
);
...
...
@@ -437,49 +433,33 @@ public static async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysFal
}
[
Fact
]
public
static
void
FindSourceDeclarationsAsync_Project_Func_Test_NullProject
()
public
async
Task
FindSourceDeclarationsAsync_Project_Func_Test_NullProject
()
{
Assert
.
Throws
<
AggregateException
>(
()
=>
await
Assert
.
ThrowsAnyAsync
<
ArgumentNullException
>(
async
()
=>
{
try
{
var
declarations
=
SymbolFinder
.
FindSourceDeclarationsAsync
((
Project
)
null
,
str
=>
str
.
Contains
(
"Test"
)).
Result
;
}
catch
(
AggregateException
ex
)
{
VerifyInnerExceptionArgumentNull
(
ex
,
"project"
);
throw
;
}
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
((
Project
)
null
,
str
=>
str
.
Contains
(
"Test"
));
});
}
[
Fact
]
public
static
void
FindSourceDeclarationsAsync_Project_Func_Test_NullPredicate
()
public
async
Task
FindSourceDeclarationsAsync_Project_Func_Test_NullPredicate
()
{
Assert
.
Throws
<
ArgumentNullException
>(
()
=>
await
Assert
.
ThrowsAnyAsync
<
ArgumentNullException
>(
async
()
=>
{
var
project
=
GetProject
(
WorkspaceKind
.
SingleClass
);
var
declarations
=
SymbolFinder
.
FindSourceDeclarationsAsync
(
project
,
null
).
Result
;
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
project
,
null
)
;
});
}
[
Fact
]
public
static
void
FindSourceDeclarationsAsync_Project_Func_Test_Cancellation
()
public
async
Task
FindSourceDeclarationsAsync_Project_Func_Test_Cancellation
()
{
Assert
.
Throws
<
AggregateException
>(
()
=>
await
Assert
.
ThrowsAnyAsync
<
OperationCanceledException
>(
async
()
=>
{
try
{
var
cts
=
new
CancellationTokenSource
();
var
project
=
GetProject
(
WorkspaceKind
.
SingleClass
);
cts
.
Cancel
();
var
declarations
=
SymbolFinder
.
FindSourceDeclarationsAsync
(
project
,
str
=>
str
.
Contains
(
"Test"
),
SymbolFilter
.
All
,
cts
.
Token
).
Result
;
}
catch
(
AggregateException
ex
)
{
VerifyInnerExceptionIsType
<
OperationCanceledException
>(
ex
);
throw
;
}
var
cts
=
new
CancellationTokenSource
();
var
project
=
GetProject
(
WorkspaceKind
.
SingleClass
);
cts
.
Cancel
();
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
project
,
str
=>
str
.
Contains
(
"Test"
),
SymbolFilter
.
All
,
cts
.
Token
);
});
}
...
...
@@ -497,7 +477,8 @@ public static void FindSourceDeclarationsAsync_Project_Func_Test_Cancellation()
InlineData
(
WorkspaceKind
.
TwoProjectsEachWithASingleClassWithSingleField
,
new
[]
{
"TestCases"
,
"TestCases.TestCase"
,
"TestCases.TestCase.TestField"
,
"TestCases"
,
"TestCases.TestCase"
,
"TestCases.TestCase.TestField"
}),
InlineData
(
WorkspaceKind
.
NestedClass
,
new
[]
{
"TestCases"
,
"TestCases.TestCase"
,
"TestCases.TestCase.InnerTestCase"
}),
InlineData
(
WorkspaceKind
.
TwoNamespacesWithIdenticalClasses
,
new
[]
{
"TestCase1"
,
"TestCase1.TestCase"
,
"TestCase2.TestCase"
,
"TestCase2"
}),]
public
static
async
Task
FindSourceDeclarationsAsync_Solution_Func_Test
(
WorkspaceKind
workspaceKind
,
string
[]
expectedResult
)
public
async
Task
FindSourceDeclarationsAsync_Solution_Func_Test
(
WorkspaceKind
workspaceKind
,
string
[]
expectedResult
)
{
var
solution
=
GetSolution
(
workspaceKind
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
str
=>
str
.
Contains
(
"Test"
)).
ConfigureAwait
(
false
);
...
...
@@ -505,7 +486,7 @@ public static async Task FindSourceDeclarationsAsync_Solution_Func_Test(Workspac
}
[
Fact
]
public
static
async
Task
FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysTruePredicate
()
public
async
Task
FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysTruePredicate
()
{
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
str
=>
true
).
ConfigureAwait
(
false
);
...
...
@@ -513,7 +494,7 @@ public static async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysTr
}
[
Fact
]
public
static
async
Task
FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysFalsePredicate
()
public
async
Task
FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysFalsePredicate
()
{
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
var
declarations
=
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
str
=>
false
).
ConfigureAwait
(
false
);
...
...
@@ -521,54 +502,38 @@ public static async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysFa
}
[
Fact
]
public
static
void
FindSourceDeclarationsAsync_Solution_Func_Test_NullSolution
()
public
async
Task
FindSourceDeclarationsAsync_Solution_Func_Test_NullSolution
()
{
Assert
.
Throws
<
AggregateException
>(
()
=>
await
Assert
.
ThrowsAnyAsync
<
ArgumentNullException
>(
async
()
=>
{
try
{
var
declarations
=
SymbolFinder
.
FindSourceDeclarationsAsync
((
Solution
)
null
,
str
=>
str
.
Contains
(
"Test"
)).
Result
;
}
catch
(
AggregateException
ex
)
{
VerifyInnerExceptionArgumentNull
(
ex
,
"solution"
);
throw
;
}
await
SymbolFinder
.
FindSourceDeclarationsAsync
((
Solution
)
null
,
str
=>
str
.
Contains
(
"Test"
));
});
}
[
Fact
]
public
static
void
FindSourceDeclarationsAsync_Solution_Func_Test_NullPredicate
()
public
async
Task
FindSourceDeclarationsAsync_Solution_Func_Test_NullPredicate
()
{
Assert
.
Throws
<
ArgumentNullException
>(
()
=>
await
Assert
.
ThrowsAnyAsync
<
ArgumentNullException
>(
async
()
=>
{
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
var
declarations
=
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
null
).
Result
;
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
null
)
;
});
}
[
Fact
]
public
static
void
FindSourceDeclarationsAsync_Solution_Func_Test_Cancellation
()
public
async
Task
FindSourceDeclarationsAsync_Solution_Func_Test_Cancellation
()
{
Assert
.
Throws
<
AggregateException
>(
()
=>
await
Assert
.
ThrowsAnyAsync
<
OperationCanceledException
>(
async
()
=>
{
try
{
var
cts
=
new
CancellationTokenSource
();
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
cts
.
Cancel
();
var
declarations
=
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
str
=>
str
.
Contains
(
"Test"
),
SymbolFilter
.
All
,
cts
.
Token
).
Result
;
}
catch
(
AggregateException
ex
)
{
VerifyInnerExceptionIsType
<
OperationCanceledException
>(
ex
);
throw
;
}
var
cts
=
new
CancellationTokenSource
();
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
cts
.
Cancel
();
await
SymbolFinder
.
FindSourceDeclarationsAsync
(
solution
,
str
=>
str
.
Contains
(
"Test"
),
SymbolFilter
.
All
,
cts
.
Token
);
});
}
[
Fact
]
public
static
async
Task
TestSymbolTreeInfoSerialization
()
public
async
Task
TestSymbolTreeInfoSerialization
()
{
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
var
compilation
=
await
solution
.
Projects
.
First
().
GetCompilationAsync
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录