Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b6ed1896
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,体验更适合开发者的 AI 搜索 >>
提交
b6ed1896
编写于
7月 14, 2016
作者:
J
Jonathon Marolf
提交者:
GitHub
7月 14, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12489 from vslsnap/merge-microupdate-into-dev15-preview-420160713-175309
Merge microupdate into dev15-preview-4
上级
36dd3b04
aef0e791
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
103 addition
and
3 deletion
+103
-3
src/Workspaces/CoreTest/SymbolKeyTests.cs
src/Workspaces/CoreTest/SymbolKeyTests.cs
+103
-3
未找到文件。
src/Workspaces/CoreTest/SymbolKeyTests.cs
浏览文件 @
b6ed1896
...
...
@@ -305,11 +305,11 @@ public class C
Assert
.
True
(
symbols
.
Count
>
0
);
TestRoundTrip
(
symbols
,
compilation
);
}
[
Fact
]
public
void
TestExtensionMethodReferences
()
{
var
source
=
@"
using System;
using System.Collections.Generic;
public static class E
...
...
@@ -319,6 +319,7 @@ public static class E
public static void Z<T>(this T t, string y) { }
public static void Z<T>(this T t, T t2) { }
public static void Y<T, S>(this T t, S other) { }
public static TResult Select<TSource, TResult>(this IEnumerable<TSource> collection, Func<TSource, TResult> selector) { return null;}
}
public class C
...
...
@@ -329,13 +330,14 @@ public class C
this.Z(""test"");
this.Z(this);
this.Y(1.0);
new[] { 1, 2, 3 }.Select(
}
}
"
;
var
compilation
=
GetCompilation
(
source
);
var
tree
=
compilation
.
SyntaxTrees
.
First
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
var
symbols
=
tree
.
GetRoot
().
DescendantNodes
().
OfType
<
InvocationExpressionSyntax
>().
Select
(
s
=>
model
.
GetSymbolInfo
(
s
).
Symbol
).
ToList
();
var
symbols
=
tree
.
GetRoot
().
DescendantNodes
().
OfType
<
InvocationExpressionSyntax
>().
Select
(
s
=>
model
.
GetSymbolInfo
(
s
).
GetAnySymbol
()
).
ToList
();
Assert
.
True
(
symbols
.
Count
>
0
);
Assert
.
True
(
symbols
.
All
(
s
=>
s
.
IsReducedExtension
()));
TestRoundTrip
(
symbols
,
compilation
);
...
...
@@ -425,6 +427,104 @@ public class C<S, T>
TestRoundTrip
(
constructed
,
compilation
);
}
[
Fact
,
WorkItem
(
235912
,
"https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?id=235912&_a=edit"
)]
public
void
TestNestedGenericType
()
{
var
source
=
@"
public class A<TOuter>
{
public class B<TInner>
{
}
}"
;
var
compilation
=
GetCompilation
(
source
);
var
tree
=
compilation
.
SyntaxTrees
.
First
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
var
outer
=
GetDeclaredSymbols
(
compilation
).
OfType
<
INamedTypeSymbol
>().
First
(
s
=>
s
.
Name
==
"A"
);
var
constructed
=
outer
.
Construct
(
compilation
.
GetSpecialType
(
SpecialType
.
System_String
));
var
inner
=
constructed
.
GetTypeMembers
().
Single
();
TestRoundTrip
(
inner
,
compilation
);
}
[
Fact
,
WorkItem
(
235912
,
"https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?id=235912&_a=edit"
)]
public
void
TestNestedGenericType1
()
{
var
source
=
@"
using System.Collections.Generic;
public class A<T1>
{
public class B<T2>
{
void M<T3>(T1 t1, T2, T3 t3, List<int> l1, List<T3> l2) { }
}
}"
;
var
compilation
=
GetCompilation
(
source
);
var
tree
=
compilation
.
SyntaxTrees
.
First
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
var
a
=
GetDeclaredSymbols
(
compilation
).
OfType
<
INamedTypeSymbol
>().
Single
(
s
=>
s
.
Name
==
"A"
);
var
a_b
=
a
.
GetTypeMembers
().
Single
();
var
a_b_m
=
a_b
.
GetMembers
().
Single
(
s
=>
s
.
Name
==
"M"
);
TestRoundTrip
(
a
,
compilation
);
TestRoundTrip
(
a_b
,
compilation
);
TestRoundTrip
(
a_b_m
,
compilation
);
var
a_string
=
a
.
Construct
(
compilation
.
GetSpecialType
(
SpecialType
.
System_String
));
var
a_string_b
=
a_string
.
GetTypeMembers
().
Single
();
var
a_string_b_m
=
a_string_b
.
GetMembers
().
Single
(
s
=>
s
.
Name
==
"M"
);
TestRoundTrip
(
a_string
,
compilation
);
TestRoundTrip
(
a_string_b
,
compilation
);
TestRoundTrip
(
a_string_b_m
,
compilation
);
var
a_string_b_int
=
a_string_b
.
Construct
(
compilation
.
GetSpecialType
(
SpecialType
.
System_Int32
));
var
a_string_b_int_m
=
a_string_b_int
.
GetMembers
().
Single
(
s
=>
s
.
Name
==
"M"
);
TestRoundTrip
(
a_string_b_int
,
compilation
);
TestRoundTrip
(
a_string_b_int_m
,
compilation
);
var
a_string_b_int_m_datetime
=
((
IMethodSymbol
)
a_string_b_int_m
).
Construct
(
compilation
.
GetSpecialType
(
SpecialType
.
System_DateTime
));
TestRoundTrip
(
a_string_b_int_m_datetime
,
compilation
);
var
a_b_int
=
a_b
.
Construct
(
compilation
.
GetSpecialType
(
SpecialType
.
System_Int32
));
var
a_b_int_m
=
a_b_int
.
GetMembers
().
Single
(
s
=>
s
.
Name
==
"M"
);
var
a_b_int_m_datetime
=
((
IMethodSymbol
)
a_b_int_m
).
Construct
(
compilation
.
GetSpecialType
(
SpecialType
.
System_DateTime
));
TestRoundTrip
(
a_b_int
,
compilation
);
TestRoundTrip
(
a_b_int_m
,
compilation
);
TestRoundTrip
(
a_b_int_m_datetime
,
compilation
);
var
a_b_m_datetime
=
((
IMethodSymbol
)
a_b_m
).
Construct
(
compilation
.
GetSpecialType
(
SpecialType
.
System_DateTime
));
TestRoundTrip
(
a_b_m_datetime
,
compilation
);
}
[
Fact
,
WorkItem
(
235912
,
"https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?id=235912&_a=edit"
)]
public
void
TestGenericTypeTypeParameter
()
{
var
source
=
@"class C<T> { }"
;
var
compilation
=
GetCompilation
(
source
);
var
tree
=
compilation
.
SyntaxTrees
.
First
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
var
typeParameter
=
GetDeclaredSymbols
(
compilation
).
OfType
<
INamedTypeSymbol
>().
Single
().
TypeParameters
.
Single
();
TestRoundTrip
(
typeParameter
,
compilation
);
}
[
Fact
,
WorkItem
(
235912
,
"https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?id=235912&_a=edit"
)]
public
void
TestGenericMethodTypeParameter
()
{
var
source
=
@"class C { void M<T>() { } }"
;
var
compilation
=
GetCompilation
(
source
);
var
tree
=
compilation
.
SyntaxTrees
.
First
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
var
typeParameter
=
GetDeclaredSymbols
(
compilation
).
OfType
<
INamedTypeSymbol
>().
Single
().
GetMembers
(
"M"
).
OfType
<
IMethodSymbol
>().
Single
().
TypeParameters
.
Single
();
TestRoundTrip
(
typeParameter
,
compilation
);
}
[
Fact
,
WorkItem
(
11193
,
"https://github.com/dotnet/roslyn/issues/11193"
)]
public
async
Task
TestGetInteriorSymbolsDoesNotCrashOnSpeculativeSemanticModel
()
{
...
...
@@ -475,7 +575,7 @@ private void TestRoundTrip(IEnumerable<ISymbol> symbols, Compilation compilation
{
foreach
(
var
symbol
in
symbols
)
{
TestRoundTrip
(
symbol
,
compilation
,
fnId
);
TestRoundTrip
(
symbol
,
compilation
,
fnId
:
fnId
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录