Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
8c6bc982
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,发现更多精彩内容 >>
提交
8c6bc982
编写于
8月 05, 2016
作者:
C
CyrusNajmabadi
提交者:
Kevin Pilch-Bisson
8月 06, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix crash in symbolkeywriting.
上级
5578d615
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
92 addition
and
3 deletion
+92
-3
src/EditorFeatures/CSharpTest/SymbolId/SymbolKeyCompilationsTests.cs
...eatures/CSharpTest/SymbolId/SymbolKeyCompilationsTests.cs
+33
-0
src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb
...Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb
+24
-1
src/Workspaces/Core/Portable/SymbolId/SymbolKey.SymbolKeyWriter.cs
...paces/Core/Portable/SymbolId/SymbolKey.SymbolKeyWriter.cs
+35
-2
未找到文件。
src/EditorFeatures/CSharpTest/SymbolId/SymbolKeyCompilationsTests.cs
浏览文件 @
8c6bc982
...
...
@@ -176,6 +176,39 @@ class C<T> : I<T>, I
Assert
.
Equal
(
indexer2
,
ResolveSymbol
(
indexer2
,
compilation
,
SymbolKeyComparison
.
None
));
}
[
Fact
]
public
void
RecursiveReferenceToConstructedGeneric
()
{
var
src1
=
@"using System.Collections.Generic;
class C
{
public void M<Z>(List<Z> list)
{
var v = list.Add(default(Z));
}
}"
;
var
comp1
=
CreateCompilationWithMscorlib
(
src1
);
var
comp2
=
CreateCompilationWithMscorlib
(
src1
);
var
symbols1
=
GetSourceSymbols
(
comp1
,
includeLocal
:
true
).
ToList
();
var
symbols2
=
GetSourceSymbols
(
comp1
,
includeLocal
:
true
).
ToList
();
// First, make sure that all the symbols in this file resolve properly
// to themselves.
ResolveAndVerifySymbolList
(
symbols1
,
symbols2
,
comp1
);
// Now do this for the members of types we see. We want this
// so we hit things like the members of the constructed type
// List<Z>
var
members1
=
symbols1
.
OfType
<
INamespaceOrTypeSymbol
>().
SelectMany
(
n
=>
n
.
GetMembers
()).
ToList
();
var
members2
=
symbols2
.
OfType
<
INamespaceOrTypeSymbol
>().
SelectMany
(
n
=>
n
.
GetMembers
()).
ToList
();
ResolveAndVerifySymbolList
(
members1
,
members2
,
comp1
);
}
#
endregion
#
region
"Change to symbol"
...
...
src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb
浏览文件 @
8c6bc982
...
...
@@ -1682,5 +1682,28 @@ class C
End
Using
End
Function
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)
>
Public
Async
Function
TestRecursiveGenericSymbolKey
()
As
Task
Using
state
=
TestState
.
CreateCSharpTestState
(
<
Document
><
!
[
CDATA
[
using
System
.
Collections
.
Generic
;
class
Program
{
static
void
ReplaceInList
<
T
>
(
List
<
T
>
list
,
T
oldItem
,
T
newItem
)
{
$$
}
}
]]
></
Document
>
,
extraExportedTypes
:
=
{
GetType
(
CSharpEditorFormattingService
)}.
ToList
())
state
.
SendTypeChars
(
"list"
)
state
.
SendTypeChars
(
"."
)
Await
state
.
AssertCompletionSession
()
state
.
SendTypeChars
(
"Add"
)
Await
state
.
AssertSelectedCompletionItem
(
"Add"
,
description
:
=
"void List<T>.Add(T item)"
)
End
Using
End
Function
End
Class
End
Namespace
End
Namespace
\ No newline at end of file
src/Workspaces/Core/Portable/SymbolId/SymbolKey.SymbolKeyWriter.cs
浏览文件 @
8c6bc982
...
...
@@ -160,13 +160,46 @@ private void WriteSymbolKey(ISymbol symbol, bool first)
StartKey
();
symbol
.
Accept
(
this
);
WriteInteger
(
id
);
if
(!
shouldWriteOrdinal
)
{
_symbolToId
.
Add
(
symbol
,
id
);
// Note: it is possible in some situations to hit the same symbol
// multiple times. For example, if you have:
//
// Foo<Z>(List<Z> list)
//
// If we start with the symbol for "list" then we'll see the following
// chain of symbols hit:
//
// List<Z>
// Z
// Foo<Z>(List<Z>)
// List<Z>
//
// The recursion is prevented because when we hit 'Foo' we mark that
// we're writing out a signature. And, in signature mode we only write
// out the ordinal for 'Z' without recursing. However, even though
// we prevent the recursion, we still hit List<Z> twice. After writing
// the innermost one out, we'll give it a reference ID. When we
// then hit the outermost one, we want to just reuse that one.
int
existingId
;
if
(
_symbolToId
.
TryGetValue
(
symbol
,
out
existingId
))
{
// While we recursed, we already hit this symbol. Use its ID as our
// ID.
id
=
existingId
;
}
else
{
// Haven't hit this symbol before, write out its fresh ID.
_symbolToId
.
Add
(
symbol
,
id
);
}
}
// Now write out the ID for this symbol so that any future hits of it can
// write out a reference to it instead.
WriteInteger
(
id
);
EndKey
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录