Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
7ce07336
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,发现更多精彩内容 >>
提交
7ce07336
编写于
5月 11, 2016
作者:
J
Jonathon Marolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Get compilation from symbol instead of having it passed into SymbolKey.Create (#11238)
Fixes #11092
上级
e3b91b6f
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
112 addition
and
121 deletion
+112
-121
src/EditorFeatures/CSharpTest/SymbolId/SymbolKeyCompilationsTests.cs
...eatures/CSharpTest/SymbolId/SymbolKeyCompilationsTests.cs
+33
-33
src/EditorFeatures/CSharpTest/SymbolId/SymbolKeyMetadataVsSourceTests.cs
...res/CSharpTest/SymbolId/SymbolKeyMetadataVsSourceTests.cs
+18
-21
src/EditorFeatures/CSharpTest/SymbolId/SymbolKeyTestBase.cs
src/EditorFeatures/CSharpTest/SymbolId/SymbolKeyTestBase.cs
+12
-12
src/EditorFeatures/Core/Implementation/MetadataAsSource/MetadataAsSourceFileService.cs
...mentation/MetadataAsSource/MetadataAsSourceFileService.cs
+3
-3
src/EditorFeatures/Core/Implementation/MetadataAsSource/SymbolMappingServiceFactory.cs
...mentation/MetadataAsSource/SymbolMappingServiceFactory.cs
+1
-1
src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs
...rFeatures/Core/Implementation/Peek/PeekableItemFactory.cs
+1
-2
src/EditorFeatures/VisualBasicTest/SymbolId/SymbolKeyCompilationsTests.vb
...es/VisualBasicTest/SymbolId/SymbolKeyCompilationsTests.vb
+13
-13
src/EditorFeatures/VisualBasicTest/SymbolId/SymbolKeyMetadataVsSourceTests.vb
...isualBasicTest/SymbolId/SymbolKeyMetadataVsSourceTests.vb
+9
-9
src/EditorFeatures/VisualBasicTest/SymbolId/SymbolKeyTestBase.vb
...torFeatures/VisualBasicTest/SymbolId/SymbolKeyTestBase.vb
+11
-11
src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs
src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs
+1
-1
src/Workspaces/Core/Portable/SymbolId/SymbolKey.BodyLevelSymbolKey.cs
...es/Core/Portable/SymbolId/SymbolKey.BodyLevelSymbolKey.cs
+3
-0
src/Workspaces/Core/Portable/SymbolId/SymbolKey.MethodSymbolKey.cs
...paces/Core/Portable/SymbolId/SymbolKey.MethodSymbolKey.cs
+2
-2
src/Workspaces/Core/Portable/SymbolId/SymbolKey.PropertySymbolKey.cs
...ces/Core/Portable/SymbolId/SymbolKey.PropertySymbolKey.cs
+1
-1
src/Workspaces/Core/Portable/SymbolId/SymbolKey.cs
src/Workspaces/Core/Portable/SymbolId/SymbolKey.cs
+3
-4
src/Workspaces/Core/Portable/SymbolId/SymbolKeyExtensions.cs
src/Workspaces/Core/Portable/SymbolId/SymbolKeyExtensions.cs
+1
-8
未找到文件。
src/EditorFeatures/CSharpTest/SymbolId/SymbolKeyCompilationsTests.cs
浏览文件 @
7ce07336
...
@@ -71,7 +71,7 @@ public enum EFoo { Zero, One, Two }
...
@@ -71,7 +71,7 @@ public enum EFoo { Zero, One, Two }
var
originalSymbols
=
GetSourceSymbols
(
comp1
,
SymbolCategory
.
DeclaredType
|
SymbolCategory
.
DeclaredNamespace
).
OrderBy
(
s
=>
s
.
Name
);
var
originalSymbols
=
GetSourceSymbols
(
comp1
,
SymbolCategory
.
DeclaredType
|
SymbolCategory
.
DeclaredNamespace
).
OrderBy
(
s
=>
s
.
Name
);
var
newSymbols
=
GetSourceSymbols
(
comp2
,
SymbolCategory
.
DeclaredType
|
SymbolCategory
.
DeclaredNamespace
).
OrderBy
(
s
=>
s
.
Name
);
var
newSymbols
=
GetSourceSymbols
(
comp2
,
SymbolCategory
.
DeclaredType
|
SymbolCategory
.
DeclaredNamespace
).
OrderBy
(
s
=>
s
.
Name
);
ResolveAndVerifySymbolList
(
newSymbols
,
comp2
,
originalSymbols
,
comp1
);
ResolveAndVerifySymbolList
(
newSymbols
,
originalSymbols
,
comp1
);
}
}
[
Fact
,
WorkItem
(
530171
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530171"
)]
[
Fact
,
WorkItem
(
530171
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530171"
)]
...
@@ -101,7 +101,7 @@ public void Method()
...
@@ -101,7 +101,7 @@ public void Method()
var
originalSymbols
=
GetSourceSymbols
(
comp1
,
SymbolCategory
.
DeclaredType
|
SymbolCategory
.
DeclaredNamespace
).
OrderBy
(
s
=>
s
.
Name
);
var
originalSymbols
=
GetSourceSymbols
(
comp1
,
SymbolCategory
.
DeclaredType
|
SymbolCategory
.
DeclaredNamespace
).
OrderBy
(
s
=>
s
.
Name
);
var
newSymbols
=
GetSourceSymbols
(
comp2
,
SymbolCategory
.
DeclaredType
|
SymbolCategory
.
DeclaredNamespace
).
OrderBy
(
s
=>
s
.
Name
);
var
newSymbols
=
GetSourceSymbols
(
comp2
,
SymbolCategory
.
DeclaredType
|
SymbolCategory
.
DeclaredNamespace
).
OrderBy
(
s
=>
s
.
Name
);
ResolveAndVerifySymbolList
(
newSymbols
,
comp2
,
originalSymbols
,
comp1
);
ResolveAndVerifySymbolList
(
newSymbols
,
originalSymbols
,
comp1
);
}
}
[
Fact
]
[
Fact
]
...
@@ -127,8 +127,8 @@ public partial class C1
...
@@ -127,8 +127,8 @@ public partial class C1
var
implementation
=
definition
.
PartialImplementationPart
;
var
implementation
=
definition
.
PartialImplementationPart
;
// Assert that both the definition and implementation resolve back to themselves
// Assert that both the definition and implementation resolve back to themselves
Assert
.
Equal
(
definition
,
ResolveSymbol
(
definition
,
comp
,
comp
,
SymbolKeyComparison
.
None
));
Assert
.
Equal
(
definition
,
ResolveSymbol
(
definition
,
comp
,
SymbolKeyComparison
.
None
));
Assert
.
Equal
(
implementation
,
ResolveSymbol
(
implementation
,
comp
,
comp
,
SymbolKeyComparison
.
None
));
Assert
.
Equal
(
implementation
,
ResolveSymbol
(
implementation
,
comp
,
SymbolKeyComparison
.
None
));
}
}
[
Fact
]
[
Fact
]
...
@@ -170,10 +170,10 @@ class C<T> : I<T>, I
...
@@ -170,10 +170,10 @@ class C<T> : I<T>, I
var
indexer1
=
type
.
GetMembers
().
Where
(
m
=>
m
.
MetadataName
==
"I.Item"
).
Single
()
as
IPropertySymbol
;
var
indexer1
=
type
.
GetMembers
().
Where
(
m
=>
m
.
MetadataName
==
"I.Item"
).
Single
()
as
IPropertySymbol
;
var
indexer2
=
type
.
GetMembers
().
Where
(
m
=>
m
.
MetadataName
==
"I<T>.Item"
).
Single
()
as
IPropertySymbol
;
var
indexer2
=
type
.
GetMembers
().
Where
(
m
=>
m
.
MetadataName
==
"I<T>.Item"
).
Single
()
as
IPropertySymbol
;
AssertSymbolKeysEqual
(
indexer1
,
compilation
,
indexer2
,
compilation
,
SymbolKeyComparison
.
None
,
expectEqual
:
false
);
AssertSymbolKeysEqual
(
indexer1
,
indexer2
,
SymbolKeyComparison
.
None
,
expectEqual
:
false
);
Assert
.
Equal
(
indexer1
,
ResolveSymbol
(
indexer1
,
compilation
,
compilation
,
SymbolKeyComparison
.
None
));
Assert
.
Equal
(
indexer1
,
ResolveSymbol
(
indexer1
,
compilation
,
SymbolKeyComparison
.
None
));
Assert
.
Equal
(
indexer2
,
ResolveSymbol
(
indexer2
,
compilation
,
compilation
,
SymbolKeyComparison
.
None
));
Assert
.
Equal
(
indexer2
,
ResolveSymbol
(
indexer2
,
compilation
,
SymbolKeyComparison
.
None
));
}
}
#
endregion
#
endregion
...
@@ -234,7 +234,7 @@ internal enum EFoo : long { Zero, One } // change base class, and modifier
...
@@ -234,7 +234,7 @@ internal enum EFoo : long { Zero, One } // change base class, and modifier
var
originalSymbols
=
GetSourceSymbols
(
comp1
,
SymbolCategory
.
DeclaredType
);
var
originalSymbols
=
GetSourceSymbols
(
comp1
,
SymbolCategory
.
DeclaredType
);
var
newSymbols
=
GetSourceSymbols
(
comp2
,
SymbolCategory
.
DeclaredType
);
var
newSymbols
=
GetSourceSymbols
(
comp2
,
SymbolCategory
.
DeclaredType
);
ResolveAndVerifySymbolList
(
newSymbols
,
comp2
,
originalSymbols
,
comp1
);
ResolveAndVerifySymbolList
(
newSymbols
,
originalSymbols
,
comp1
);
}
}
[
Fact
]
[
Fact
]
...
@@ -275,10 +275,10 @@ public class C2 // rename C1 to C2
...
@@ -275,10 +275,10 @@ public class C2 // rename C1 to C2
var
typeSym02
=
namespace2
.
GetTypeMembers
(
"C2"
).
Single
()
as
NamedTypeSymbol
;
var
typeSym02
=
namespace2
.
GetTypeMembers
(
"C2"
).
Single
()
as
NamedTypeSymbol
;
// new C1 resolve to old C1
// new C1 resolve to old C1
ResolveAndVerifySymbol
(
typeSym01
,
comp2
,
typeSym00
,
comp1
);
ResolveAndVerifySymbol
(
typeSym01
,
typeSym00
,
comp1
);
// old C1 (new C2) NOT resolve to old C1
// old C1 (new C2) NOT resolve to old C1
var
symkey
=
SymbolKey
.
Create
(
typeSym02
,
comp1
,
CancellationToken
.
None
);
var
symkey
=
SymbolKey
.
Create
(
typeSym02
,
CancellationToken
.
None
);
var
syminfo
=
symkey
.
Resolve
(
comp1
);
var
syminfo
=
symkey
.
Resolve
(
comp1
);
Assert
.
Null
(
syminfo
.
Symbol
);
Assert
.
Null
(
syminfo
.
Symbol
);
}
}
...
@@ -320,7 +320,7 @@ public class Test
...
@@ -320,7 +320,7 @@ public class Test
var
newSymbols
=
GetSourceSymbols
(
comp2
,
SymbolCategory
.
NonTypeMember
|
SymbolCategory
.
Parameter
)
var
newSymbols
=
GetSourceSymbols
(
comp2
,
SymbolCategory
.
NonTypeMember
|
SymbolCategory
.
Parameter
)
.
Where
(
s
=>
!
s
.
IsAccessor
()).
OrderBy
(
s
=>
s
.
Name
);
.
Where
(
s
=>
!
s
.
IsAccessor
()).
OrderBy
(
s
=>
s
.
Name
);
ResolveAndVerifySymbolList
(
newSymbols
,
comp2
,
originalSymbols
,
comp1
);
ResolveAndVerifySymbolList
(
newSymbols
,
originalSymbols
,
comp1
);
}
}
[
WorkItem
(
542700
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542700"
)]
[
WorkItem
(
542700
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542700"
)]
...
@@ -353,8 +353,8 @@ public class Test
...
@@ -353,8 +353,8 @@ public class Test
var
typeSym2
=
comp2
.
SourceModule
.
GlobalNamespace
.
GetTypeMembers
(
"Test"
).
Single
()
as
NamedTypeSymbol
;
var
typeSym2
=
comp2
.
SourceModule
.
GlobalNamespace
.
GetTypeMembers
(
"Test"
).
Single
()
as
NamedTypeSymbol
;
var
newSymbols
=
typeSym2
.
GetMembers
(
WellKnownMemberNames
.
Indexer
);
var
newSymbols
=
typeSym2
.
GetMembers
(
WellKnownMemberNames
.
Indexer
);
ResolveAndVerifySymbol
(
newSymbols
.
First
(),
comp2
,
originalSymbols
.
First
(),
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
newSymbols
.
First
(),
originalSymbols
.
First
(),
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
newSymbols
.
Last
(),
comp2
,
originalSymbols
.
Last
(),
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
newSymbols
.
Last
(),
originalSymbols
.
Last
(),
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
}
}
[
Fact
]
[
Fact
]
...
@@ -379,10 +379,10 @@ public class C1
...
@@ -379,10 +379,10 @@ public class C1
var
typeSym02
=
namespace2
.
GetTypeMembers
(
"C1"
).
FirstOrDefault
()
as
NamedTypeSymbol
;
var
typeSym02
=
namespace2
.
GetTypeMembers
(
"C1"
).
FirstOrDefault
()
as
NamedTypeSymbol
;
// new C1 resolves to old C1 if we ignore assembly and module ids
// new C1 resolves to old C1 if we ignore assembly and module ids
ResolveAndVerifySymbol
(
typeSym02
,
comp2
,
typeSym01
,
comp1
,
SymbolKeyComparison
.
CaseSensitive
|
SymbolKeyComparison
.
IgnoreAssemblyIds
);
ResolveAndVerifySymbol
(
typeSym02
,
typeSym01
,
comp1
,
SymbolKeyComparison
.
CaseSensitive
|
SymbolKeyComparison
.
IgnoreAssemblyIds
);
// new C1 DOES NOT resolve to old C1 if we don't ignore assembly and module ids
// new C1 DOES NOT resolve to old C1 if we don't ignore assembly and module ids
Assert
.
Null
(
ResolveSymbol
(
typeSym02
,
comp2
,
comp1
,
SymbolKeyComparison
.
CaseSensitive
));
Assert
.
Null
(
ResolveSymbol
(
typeSym02
,
comp1
,
SymbolKeyComparison
.
CaseSensitive
));
}
}
[
WpfFact
(
Skip
=
"530169"
),
WorkItem
(
530169
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530169"
)]
[
WpfFact
(
Skip
=
"530169"
),
WorkItem
(
530169
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530169"
)]
...
@@ -398,19 +398,19 @@ public void C2CAssemblyChanged02()
...
@@ -398,19 +398,19 @@ public void C2CAssemblyChanged02()
Symbol
sym2
=
comp2
.
Assembly
;
Symbol
sym2
=
comp2
.
Assembly
;
// Not ignoreAssemblyAndModules
// Not ignoreAssemblyAndModules
ResolveAndVerifySymbol
(
sym1
,
comp2
,
sym2
,
comp2
);
ResolveAndVerifySymbol
(
sym1
,
sym2
,
comp2
);
AssertSymbolKeysEqual
(
sym1
,
comp1
,
sym2
,
comp
2
,
SymbolKeyComparison
.
IgnoreAssemblyIds
,
true
);
AssertSymbolKeysEqual
(
sym1
,
sym
2
,
SymbolKeyComparison
.
IgnoreAssemblyIds
,
true
);
Assert
.
NotNull
(
ResolveSymbol
(
sym1
,
comp
1
,
comp
2
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
Assert
.
NotNull
(
ResolveSymbol
(
sym1
,
comp2
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
// Module
// Module
sym1
=
comp1
.
Assembly
.
Modules
[
0
];
sym1
=
comp1
.
Assembly
.
Modules
[
0
];
sym2
=
comp2
.
Assembly
.
Modules
[
0
];
sym2
=
comp2
.
Assembly
.
Modules
[
0
];
ResolveAndVerifySymbol
(
sym1
,
comp1
,
sym2
,
comp2
);
ResolveAndVerifySymbol
(
sym1
,
sym2
,
comp2
);
AssertSymbolKeysEqual
(
sym2
,
comp2
,
sym1
,
comp
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
,
true
);
AssertSymbolKeysEqual
(
sym2
,
sym
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
,
true
);
Assert
.
NotNull
(
ResolveSymbol
(
sym2
,
comp
2
,
comp
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
Assert
.
NotNull
(
ResolveSymbol
(
sym2
,
comp1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
}
}
[
Fact
,
WorkItem
(
530170
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530170"
)]
[
Fact
,
WorkItem
(
530170
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530170"
)]
...
@@ -427,25 +427,25 @@ public void C2CAssemblyChanged03()
...
@@ -427,25 +427,25 @@ public void C2CAssemblyChanged03()
ISymbol
assembly2
=
compilation2
.
Assembly
;
ISymbol
assembly2
=
compilation2
.
Assembly
;
// different
// different
AssertSymbolKeysEqual
(
assembly2
,
compilation2
,
assembly1
,
compilation
1
,
SymbolKeyComparison
.
CaseSensitive
,
expectEqual
:
false
);
AssertSymbolKeysEqual
(
assembly2
,
assembly
1
,
SymbolKeyComparison
.
CaseSensitive
,
expectEqual
:
false
);
Assert
.
Null
(
ResolveSymbol
(
assembly2
,
compilation
2
,
compilation
1
,
SymbolKeyComparison
.
CaseSensitive
));
Assert
.
Null
(
ResolveSymbol
(
assembly2
,
compilation1
,
SymbolKeyComparison
.
CaseSensitive
));
// ignore means ALL assembly/module symbols have same ID
// ignore means ALL assembly/module symbols have same ID
AssertSymbolKeysEqual
(
assembly2
,
compilation2
,
assembly1
,
compilation
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
,
expectEqual
:
true
);
AssertSymbolKeysEqual
(
assembly2
,
assembly
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
,
expectEqual
:
true
);
// But can NOT be resolved
// But can NOT be resolved
Assert
.
Null
(
ResolveSymbol
(
assembly2
,
compilation
2
,
compilation
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
Assert
.
Null
(
ResolveSymbol
(
assembly2
,
compilation1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
// Module
// Module
var
module1
=
compilation1
.
Assembly
.
Modules
[
0
];
var
module1
=
compilation1
.
Assembly
.
Modules
[
0
];
var
module2
=
compilation2
.
Assembly
.
Modules
[
0
];
var
module2
=
compilation2
.
Assembly
.
Modules
[
0
];
// different
// different
AssertSymbolKeysEqual
(
module1
,
compilation1
,
module2
,
compilation
2
,
SymbolKeyComparison
.
CaseSensitive
,
expectEqual
:
false
);
AssertSymbolKeysEqual
(
module1
,
module
2
,
SymbolKeyComparison
.
CaseSensitive
,
expectEqual
:
false
);
Assert
.
Null
(
ResolveSymbol
(
module1
,
compilation
1
,
compilation
2
,
SymbolKeyComparison
.
CaseSensitive
));
Assert
.
Null
(
ResolveSymbol
(
module1
,
compilation2
,
SymbolKeyComparison
.
CaseSensitive
));
AssertSymbolKeysEqual
(
module2
,
compilation2
,
module1
,
compilation
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
);
AssertSymbolKeysEqual
(
module2
,
module
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
);
Assert
.
Null
(
ResolveSymbol
(
module2
,
compilation
2
,
compilation
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
Assert
.
Null
(
ResolveSymbol
(
module2
,
compilation1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
}
}
[
Fact
,
WorkItem
(
546254
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546254"
)]
[
Fact
,
WorkItem
(
546254
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546254"
)]
...
@@ -471,12 +471,12 @@ public class C {}
...
@@ -471,12 +471,12 @@ public class C {}
Symbol
sym2
=
comp2
.
Assembly
;
Symbol
sym2
=
comp2
.
Assembly
;
// comment is changed to compare Name ONLY
// comment is changed to compare Name ONLY
AssertSymbolKeysEqual
(
sym1
,
comp1
,
sym2
,
comp
2
,
SymbolKeyComparison
.
CaseSensitive
,
expectEqual
:
true
);
AssertSymbolKeysEqual
(
sym1
,
sym
2
,
SymbolKeyComparison
.
CaseSensitive
,
expectEqual
:
true
);
var
resolved
=
ResolveSymbol
(
sym2
,
comp
2
,
comp
1
,
SymbolKeyComparison
.
CaseSensitive
);
var
resolved
=
ResolveSymbol
(
sym2
,
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
Assert
.
Equal
(
sym1
,
resolved
);
Assert
.
Equal
(
sym1
,
resolved
);
AssertSymbolKeysEqual
(
sym1
,
comp1
,
sym2
,
comp
2
,
SymbolKeyComparison
.
IgnoreAssemblyIds
);
AssertSymbolKeysEqual
(
sym1
,
sym
2
,
SymbolKeyComparison
.
IgnoreAssemblyIds
);
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp
2
,
comp
1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp1
,
SymbolKeyComparison
.
IgnoreAssemblyIds
));
}
}
#
endregion
#
endregion
...
...
src/EditorFeatures/CSharpTest/SymbolId/SymbolKeyMetadataVsSourceTests.cs
浏览文件 @
7ce07336
...
@@ -78,11 +78,11 @@ public class App : C
...
@@ -78,11 +78,11 @@ public class App : C
// 'E'
// 'E'
var
member05
=
(
typesym
.
GetMembers
(
WellKnownMemberNames
.
Indexer
).
Single
()
as
PropertySymbol
).
Type
;
var
member05
=
(
typesym
.
GetMembers
(
WellKnownMemberNames
.
Indexer
).
Single
()
as
PropertySymbol
).
Type
;
ResolveAndVerifySymbol
(
member03
,
comp2
,
originalSymbols
[
0
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
member03
,
originalSymbols
[
0
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
member01
,
comp2
,
originalSymbols
[
1
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
member01
,
originalSymbols
[
1
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
member05
,
comp2
,
originalSymbols
[
2
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
member05
,
originalSymbols
[
2
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
member02
,
comp2
,
originalSymbols
[
3
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
member02
,
originalSymbols
[
3
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
member04
,
comp2
,
originalSymbols
[
4
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
ResolveAndVerifySymbol
(
member04
,
originalSymbols
[
4
],
comp1
,
SymbolKeyComparison
.
CaseSensitive
);
}
}
[
WorkItem
(
542700
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542700"
)]
[
WorkItem
(
542700
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542700"
)]
...
@@ -249,24 +249,21 @@ static void Main()
...
@@ -249,24 +249,21 @@ static void Main()
foreach
(
var
body
in
list
)
foreach
(
var
body
in
list
)
{
{
var
df
=
model
.
AnalyzeDataFlow
(
body
.
Statements
.
First
(),
body
.
Statements
.
Last
());
var
df
=
model
.
AnalyzeDataFlow
(
body
.
Statements
.
First
(),
body
.
Statements
.
Last
());
if
(
df
.
VariablesDeclared
!=
null
)
foreach
(
var
local
in
df
.
VariablesDeclared
)
{
{
foreach
(
var
local
in
df
.
VariablesDeclared
)
var
localType
=
((
LocalSymbol
)
local
).
Type
;
if
(
local
.
Name
==
"fi"
)
{
ResolveAndVerifySymbol
(
localType
,
mtsym20_1
,
comp20
,
SymbolKeyComparison
.
CaseSensitive
);
}
else
if
(
local
.
Name
==
"ary"
)
{
ResolveAndVerifySymbol
(
localType
,
mtsym20_2
,
comp20
,
SymbolKeyComparison
.
CaseSensitive
);
}
else
if
(
local
.
Name
==
"dt"
)
{
{
var
localType
=
((
LocalSymbol
)
local
).
Type
;
ResolveAndVerifySymbol
(
localType
,
mtsym20_3
,
comp20
,
SymbolKeyComparison
.
CaseSensitive
);
if
(
local
.
Name
==
"fi"
)
{
ResolveAndVerifySymbol
(
localType
,
comp40
,
mtsym20_1
,
comp20
,
SymbolKeyComparison
.
CaseSensitive
);
}
else
if
(
local
.
Name
==
"ary"
)
{
ResolveAndVerifySymbol
(
localType
,
comp40
,
mtsym20_2
,
comp20
,
SymbolKeyComparison
.
CaseSensitive
);
}
else
if
(
local
.
Name
==
"dt"
)
{
ResolveAndVerifySymbol
(
localType
,
comp40
,
mtsym20_3
,
comp20
,
SymbolKeyComparison
.
CaseSensitive
);
}
}
}
}
}
}
}
...
...
src/EditorFeatures/CSharpTest/SymbolId/SymbolKeyTestBase.cs
浏览文件 @
7ce07336
...
@@ -35,7 +35,7 @@ internal enum SymbolCategory
...
@@ -35,7 +35,7 @@ internal enum SymbolCategory
#
region
"Verification"
#
region
"Verification"
internal
static
void
ResolveAndVerifySymbolList
(
IEnumerable
<
ISymbol
>
newSymbols
,
Compilation
newCompilation
,
IEnumerable
<
ISymbol
>
originalSymbols
,
CSharpCompilation
originalComp
)
internal
static
void
ResolveAndVerifySymbolList
(
IEnumerable
<
ISymbol
>
newSymbols
,
IEnumerable
<
ISymbol
>
originalSymbols
,
CSharpCompilation
originalComp
)
{
{
var
newlist
=
newSymbols
.
OrderBy
(
s
=>
s
.
Name
).
ToList
();
var
newlist
=
newSymbols
.
OrderBy
(
s
=>
s
.
Name
).
ToList
();
var
origlist
=
originalSymbols
.
OrderBy
(
s
=>
s
.
Name
).
ToList
();
var
origlist
=
originalSymbols
.
OrderBy
(
s
=>
s
.
Name
).
ToList
();
...
@@ -44,28 +44,28 @@ internal static void ResolveAndVerifySymbolList(IEnumerable<ISymbol> newSymbols,
...
@@ -44,28 +44,28 @@ internal static void ResolveAndVerifySymbolList(IEnumerable<ISymbol> newSymbols,
for
(
int
i
=
0
;
i
<
newlist
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
newlist
.
Count
;
i
++)
{
{
ResolveAndVerifySymbol
(
newlist
[
i
],
newCompilation
,
origlist
[
i
],
originalComp
);
ResolveAndVerifySymbol
(
newlist
[
i
],
origlist
[
i
],
originalComp
);
}
}
}
}
internal
static
void
ResolveAndVerifyTypeSymbol
(
ExpressionSyntax
node
,
ITypeSymbol
sourceSymbol
,
SemanticModel
model
,
CSharpCompilation
sourceComp
)
internal
static
void
ResolveAndVerifyTypeSymbol
(
ExpressionSyntax
node
,
ITypeSymbol
sourceSymbol
,
SemanticModel
model
,
CSharpCompilation
sourceComp
)
{
{
var
typeinfo
=
model
.
GetTypeInfo
(
node
);
var
typeinfo
=
model
.
GetTypeInfo
(
node
);
ResolveAndVerifySymbol
(
typeinfo
.
Type
??
typeinfo
.
ConvertedType
,
model
.
Compilation
,
sourceSymbol
,
sourceComp
);
ResolveAndVerifySymbol
(
typeinfo
.
Type
??
typeinfo
.
ConvertedType
,
sourceSymbol
,
sourceComp
);
}
}
internal
static
void
ResolveAndVerifySymbol
(
ExpressionSyntax
node
,
ISymbol
sourceSymbol
,
SemanticModel
model
,
CSharpCompilation
sourceComp
,
SymbolKeyComparison
comparison
=
SymbolKeyComparison
.
None
)
internal
static
void
ResolveAndVerifySymbol
(
ExpressionSyntax
node
,
ISymbol
sourceSymbol
,
SemanticModel
model
,
CSharpCompilation
sourceComp
,
SymbolKeyComparison
comparison
=
SymbolKeyComparison
.
None
)
{
{
var
syminfo
=
model
.
GetSymbolInfo
(
node
);
var
syminfo
=
model
.
GetSymbolInfo
(
node
);
ResolveAndVerifySymbol
(
syminfo
.
Symbol
,
model
.
Compilation
,
sourceSymbol
,
sourceComp
,
comparison
);
ResolveAndVerifySymbol
(
syminfo
.
Symbol
,
sourceSymbol
,
sourceComp
,
comparison
);
}
}
internal
static
void
ResolveAndVerifySymbol
(
ISymbol
symbol1
,
Compilation
compilation1
,
ISymbol
symbol2
,
Compilation
compilation2
,
SymbolKeyComparison
comparison
=
SymbolKeyComparison
.
None
)
internal
static
void
ResolveAndVerifySymbol
(
ISymbol
symbol1
,
ISymbol
symbol2
,
Compilation
compilation2
,
SymbolKeyComparison
comparison
=
SymbolKeyComparison
.
None
)
{
{
// same ID
// same ID
AssertSymbolKeysEqual
(
symbol1
,
compilation1
,
symbol2
,
compilation
2
,
comparison
);
AssertSymbolKeysEqual
(
symbol1
,
symbol
2
,
comparison
);
var
resolvedSymbol
=
ResolveSymbol
(
symbol1
,
compilation
1
,
compilation
2
,
comparison
);
var
resolvedSymbol
=
ResolveSymbol
(
symbol1
,
compilation2
,
comparison
);
Assert
.
NotNull
(
resolvedSymbol
);
Assert
.
NotNull
(
resolvedSymbol
);
...
@@ -74,18 +74,18 @@ internal static void ResolveAndVerifySymbol(ISymbol symbol1, Compilation compila
...
@@ -74,18 +74,18 @@ internal static void ResolveAndVerifySymbol(ISymbol symbol1, Compilation compila
Assert
.
Equal
(
symbol2
.
GetHashCode
(),
resolvedSymbol
.
GetHashCode
());
Assert
.
Equal
(
symbol2
.
GetHashCode
(),
resolvedSymbol
.
GetHashCode
());
}
}
internal
static
ISymbol
ResolveSymbol
(
ISymbol
originalSymbol
,
Compilation
originalCompilation
,
Compilation
targetCompilation
,
SymbolKeyComparison
comparison
)
internal
static
ISymbol
ResolveSymbol
(
ISymbol
originalSymbol
,
Compilation
targetCompilation
,
SymbolKeyComparison
comparison
)
{
{
var
sid
=
SymbolKey
.
Create
(
originalSymbol
,
originalCompilation
,
CancellationToken
.
None
);
var
sid
=
SymbolKey
.
Create
(
originalSymbol
,
CancellationToken
.
None
);
var
symInfo
=
sid
.
Resolve
(
targetCompilation
,
(
comparison
&
SymbolKeyComparison
.
IgnoreAssemblyIds
)
==
SymbolKeyComparison
.
IgnoreAssemblyIds
);
var
symInfo
=
sid
.
Resolve
(
targetCompilation
,
(
comparison
&
SymbolKeyComparison
.
IgnoreAssemblyIds
)
==
SymbolKeyComparison
.
IgnoreAssemblyIds
);
return
symInfo
.
Symbol
;
return
symInfo
.
Symbol
;
}
}
internal
static
void
AssertSymbolKeysEqual
(
ISymbol
symbol1
,
Compilation
compilation1
,
ISymbol
symbol2
,
Compilation
compilation
2
,
SymbolKeyComparison
comparison
,
bool
expectEqual
=
true
)
internal
static
void
AssertSymbolKeysEqual
(
ISymbol
symbol1
,
ISymbol
symbol
2
,
SymbolKeyComparison
comparison
,
bool
expectEqual
=
true
)
{
{
var
sid1
=
SymbolKey
.
Create
(
symbol1
,
compilation1
,
CancellationToken
.
None
);
var
sid1
=
SymbolKey
.
Create
(
symbol1
,
CancellationToken
.
None
);
var
sid2
=
SymbolKey
.
Create
(
symbol2
,
compilation2
,
CancellationToken
.
None
);
var
sid2
=
SymbolKey
.
Create
(
symbol2
,
CancellationToken
.
None
);
// default is Insensitive
// default is Insensitive
var
isCaseSensitive
=
(
comparison
&
SymbolKeyComparison
.
CaseSensitive
)
==
SymbolKeyComparison
.
CaseSensitive
;
var
isCaseSensitive
=
(
comparison
&
SymbolKeyComparison
.
CaseSensitive
)
==
SymbolKeyComparison
.
CaseSensitive
;
...
...
src/EditorFeatures/Core/Implementation/MetadataAsSource/MetadataAsSourceFileService.cs
浏览文件 @
7ce07336
...
@@ -88,7 +88,7 @@ public async Task<MetadataAsSourceFile> GetGeneratedFileAsync(Project project, I
...
@@ -88,7 +88,7 @@ public async Task<MetadataAsSourceFile> GetGeneratedFileAsync(Project project, I
MetadataAsSourceGeneratedFileInfo
fileInfo
;
MetadataAsSourceGeneratedFileInfo
fileInfo
;
Location
navigateLocation
=
null
;
Location
navigateLocation
=
null
;
var
topLevelNamedType
=
MetadataAsSourceHelpers
.
GetTopLevelContainingNamedType
(
symbol
);
var
topLevelNamedType
=
MetadataAsSourceHelpers
.
GetTopLevelContainingNamedType
(
symbol
);
var
symbolId
=
SymbolKey
.
Create
(
symbol
,
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
),
cancellationToken
);
var
symbolId
=
SymbolKey
.
Create
(
symbol
,
cancellationToken
);
using
(
await
_gate
.
DisposableWaitAsync
(
cancellationToken
).
ConfigureAwait
(
false
))
using
(
await
_gate
.
DisposableWaitAsync
(
cancellationToken
).
ConfigureAwait
(
false
))
{
{
...
@@ -244,11 +244,11 @@ private async Task<UniqueDocumentKey> GetUniqueDocumentKey(Project project, INam
...
@@ -244,11 +244,11 @@ private async Task<UniqueDocumentKey> GetUniqueDocumentKey(Project project, INam
if
(
peMetadataReference
.
FilePath
!=
null
)
if
(
peMetadataReference
.
FilePath
!=
null
)
{
{
return
new
UniqueDocumentKey
(
peMetadataReference
.
FilePath
,
project
.
Language
,
SymbolKey
.
Create
(
topLevelNamedType
,
c
ompilation
,
c
ancellationToken
));
return
new
UniqueDocumentKey
(
peMetadataReference
.
FilePath
,
project
.
Language
,
SymbolKey
.
Create
(
topLevelNamedType
,
cancellationToken
));
}
}
else
else
{
{
return
new
UniqueDocumentKey
(
topLevelNamedType
.
ContainingAssembly
.
Identity
,
project
.
Language
,
SymbolKey
.
Create
(
topLevelNamedType
,
c
ompilation
,
c
ancellationToken
));
return
new
UniqueDocumentKey
(
topLevelNamedType
.
ContainingAssembly
.
Identity
,
project
.
Language
,
SymbolKey
.
Create
(
topLevelNamedType
,
cancellationToken
));
}
}
}
}
...
...
src/EditorFeatures/Core/Implementation/MetadataAsSource/SymbolMappingServiceFactory.cs
浏览文件 @
7ce07336
...
@@ -35,7 +35,7 @@ public Task<SymbolMappingResult> MapSymbolAsync(Document document, SymbolKey sym
...
@@ -35,7 +35,7 @@ public Task<SymbolMappingResult> MapSymbolAsync(Document document, SymbolKey sym
public
async
Task
<
SymbolMappingResult
>
MapSymbolAsync
(
Document
document
,
ISymbol
symbol
,
CancellationToken
cancellationToken
)
public
async
Task
<
SymbolMappingResult
>
MapSymbolAsync
(
Document
document
,
ISymbol
symbol
,
CancellationToken
cancellationToken
)
{
{
var
compilation
=
await
document
.
Project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
compilation
=
await
document
.
Project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
return
await
MapSymbolAsync
(
document
,
SymbolKey
.
Create
(
symbol
,
c
ompilation
,
c
ancellationToken
),
cancellationToken
).
ConfigureAwait
(
false
);
return
await
MapSymbolAsync
(
document
,
SymbolKey
.
Create
(
symbol
,
cancellationToken
),
cancellationToken
).
ConfigureAwait
(
false
);
}
}
}
}
}
}
...
...
src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs
浏览文件 @
7ce07336
...
@@ -68,8 +68,7 @@ public async Task<IEnumerable<IPeekableItem>> GetPeekableItemsAsync(ISymbol symb
...
@@ -68,8 +68,7 @@ public async Task<IEnumerable<IPeekableItem>> GetPeekableItemsAsync(ISymbol symb
}
}
else
else
{
{
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
symbolKey
=
SymbolKey
.
Create
(
symbol
,
cancellationToken
);
var
symbolKey
=
SymbolKey
.
Create
(
symbol
,
compilation
,
cancellationToken
);
var
firstLocation
=
symbol
.
Locations
.
FirstOrDefault
();
var
firstLocation
=
symbol
.
Locations
.
FirstOrDefault
();
if
(
firstLocation
!=
null
)
if
(
firstLocation
!=
null
)
...
...
src/EditorFeatures/VisualBasicTest/SymbolId/SymbolKeyCompilationsTests.vb
浏览文件 @
7ce07336
...
@@ -119,8 +119,8 @@ End Namespace
...
@@ -119,8 +119,8 @@ End Namespace
Dim
sym1
=
origlist
(
i
)
Dim
sym1
=
origlist
(
i
)
Dim
sym2
=
newlist
(
i
)
Dim
sym2
=
newlist
(
i
)
AssertSymbolsIdsEqual
(
sym2
,
comp2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseSensitive
,
expectEqual
:
=
False
)
AssertSymbolsIdsEqual
(
sym2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseSensitive
,
expectEqual
:
=
False
)
Dim
resolvedSymbol
=
ResolveSymbol
(
sym2
,
comp
2
,
comp
1
,
SymbolIdComparison
.
CaseSensitive
)
' ignored
Dim
resolvedSymbol
=
ResolveSymbol
(
sym2
,
comp1
,
SymbolIdComparison
.
CaseSensitive
)
' ignored
Assert
.
NotNull
(
resolvedSymbol
)
Assert
.
NotNull
(
resolvedSymbol
)
Assert
.
Equal
(
sym1
,
resolvedSymbol
)
Assert
.
Equal
(
sym1
,
resolvedSymbol
)
Next
Next
...
@@ -228,10 +228,10 @@ End Class
...
@@ -228,10 +228,10 @@ End Class
Dim
sym1
=
comp1
.
SourceModule
.
GlobalNamespace
.
GetMembers
(
"C"
).
FirstOrDefault
()
Dim
sym1
=
comp1
.
SourceModule
.
GlobalNamespace
.
GetMembers
(
"C"
).
FirstOrDefault
()
Dim
sym2
=
comp2
.
SourceModule
.
GlobalNamespace
.
GetMembers
(
"C"
).
FirstOrDefault
()
Dim
sym2
=
comp2
.
SourceModule
.
GlobalNamespace
.
GetMembers
(
"C"
).
FirstOrDefault
()
AssertSymbolsIdsEqual
(
sym2
,
comp2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
,
expectEqual
:
=
False
)
AssertSymbolsIdsEqual
(
sym2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
,
expectEqual
:
=
False
)
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp
2
,
comp
1
,
SymbolIdComparison
.
CaseInsensitive
))
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
))
' ignore asm id
' ignore asm id
ResolveAndVerifySymbol
(
sym2
,
comp2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
Or
SymbolIdComparison
.
IgnoreAssemblyIds
)
ResolveAndVerifySymbol
(
sym2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
Or
SymbolIdComparison
.
IgnoreAssemblyIds
)
End
Sub
End
Sub
<
Fact
,
WorkItem
(
530170
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530170"
)
>
<
Fact
,
WorkItem
(
530170
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530170"
)
>
...
@@ -263,22 +263,22 @@ End Class
...
@@ -263,22 +263,22 @@ End Class
Dim
sym1
As
ISymbol
=
comp1
.
Assembly
Dim
sym1
As
ISymbol
=
comp1
.
Assembly
Dim
sym2
As
ISymbol
=
comp2
.
Assembly
Dim
sym2
As
ISymbol
=
comp2
.
Assembly
AssertSymbolsIdsEqual
(
sym2
,
comp2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
,
False
)
AssertSymbolsIdsEqual
(
sym2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
,
False
)
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp
2
,
comp
1
,
SymbolIdComparison
.
CaseInsensitive
))
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
))
' ignore asm id
' ignore asm id
' Same ID
' Same ID
AssertSymbolsIdsEqual
(
sym2
,
comp2
,
sym1
,
comp1
,
SymbolIdComparison
.
IgnoreAssemblyIds
)
AssertSymbolsIdsEqual
(
sym2
,
sym1
,
comp1
,
SymbolIdComparison
.
IgnoreAssemblyIds
)
' but can NOT resolve
' but can NOT resolve
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp
2
,
comp
1
,
SymbolIdComparison
.
CaseInsensitive
Or
SymbolIdComparison
.
IgnoreAssemblyIds
))
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
Or
SymbolIdComparison
.
IgnoreAssemblyIds
))
sym1
=
comp1
.
Assembly
.
Modules
(
0
)
sym1
=
comp1
.
Assembly
.
Modules
(
0
)
sym2
=
comp2
.
Assembly
.
Modules
(
0
)
sym2
=
comp2
.
Assembly
.
Modules
(
0
)
AssertSymbolsIdsEqual
(
sym2
,
comp2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
,
False
)
AssertSymbolsIdsEqual
(
sym2
,
sym1
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
,
False
)
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp
2
,
comp
1
,
SymbolIdComparison
.
CaseInsensitive
))
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp1
,
SymbolIdComparison
.
CaseInsensitive
))
AssertSymbolsIdsEqual
(
sym2
,
comp2
,
sym1
,
comp1
,
SymbolIdComparison
.
IgnoreAssemblyIds
)
AssertSymbolsIdsEqual
(
sym2
,
sym1
,
comp1
,
SymbolIdComparison
.
IgnoreAssemblyIds
)
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp
2
,
comp
1
,
SymbolIdComparison
.
IgnoreAssemblyIds
))
Assert
.
Null
(
ResolveSymbol
(
sym2
,
comp1
,
SymbolIdComparison
.
IgnoreAssemblyIds
))
End
Sub
End
Sub
#End Region
#End Region
...
...
src/EditorFeatures/VisualBasicTest/SymbolId/SymbolKeyMetadataVsSourceTests.vb
浏览文件 @
7ce07336
...
@@ -88,11 +88,11 @@ End Class
...
@@ -88,11 +88,11 @@ End Class
' 'E'
' 'E'
Dim
mtSym05
=
(
TryCast
(
typesym
.
GetMembers
(
"Item"
).
[
Single
]
(),
IPropertySymbol
)).
Type
Dim
mtSym05
=
(
TryCast
(
typesym
.
GetMembers
(
"Item"
).
[
Single
]
(),
IPropertySymbol
)).
Type
ResolveAndVerifySymbol
(
mtSym03
,
comp2
,
originalSymbols
(
0
),
comp1
,
SymbolIdComparison
.
CaseSensitive
)
ResolveAndVerifySymbol
(
mtSym03
,
originalSymbols
(
0
),
comp1
,
SymbolIdComparison
.
CaseSensitive
)
ResolveAndVerifySymbol
(
mtSym01
,
comp2
,
originalSymbols
(
1
),
comp1
,
SymbolIdComparison
.
CaseSensitive
)
ResolveAndVerifySymbol
(
mtSym01
,
originalSymbols
(
1
),
comp1
,
SymbolIdComparison
.
CaseSensitive
)
ResolveAndVerifySymbol
(
mtSym05
,
comp2
,
originalSymbols
(
2
),
comp1
,
SymbolIdComparison
.
CaseSensitive
)
ResolveAndVerifySymbol
(
mtSym05
,
originalSymbols
(
2
),
comp1
,
SymbolIdComparison
.
CaseSensitive
)
ResolveAndVerifySymbol
(
mtSym02
,
comp2
,
originalSymbols
(
3
),
comp1
,
SymbolIdComparison
.
CaseInsensitive
)
ResolveAndVerifySymbol
(
mtSym02
,
originalSymbols
(
3
),
comp1
,
SymbolIdComparison
.
CaseInsensitive
)
ResolveAndVerifySymbol
(
mtSym04
,
comp2
,
originalSymbols
(
4
),
comp1
,
SymbolIdComparison
.
CaseInsensitive
)
ResolveAndVerifySymbol
(
mtSym04
,
originalSymbols
(
4
),
comp1
,
SymbolIdComparison
.
CaseInsensitive
)
End
Sub
End
Sub
<
Fact
>
<
Fact
>
...
@@ -245,13 +245,13 @@ End Class
...
@@ -245,13 +245,13 @@ End Class
Dim
localSymbols
=
ver40Symbols
.
OrderBy
(
Function
(
s
)
s
.
Name
).
[
Select
]
(
Function
(
s
)
DirectCast
(
s
,
ILocalSymbol
)).
ToList
()
Dim
localSymbols
=
ver40Symbols
.
OrderBy
(
Function
(
s
)
s
.
Name
).
[
Select
]
(
Function
(
s
)
DirectCast
(
s
,
ILocalSymbol
)).
ToList
()
' a
' a
ResolveAndVerifySymbol
(
localSymbols
(
0
).
Type
,
comp40
,
typeA
,
comp20
,
SymbolIdComparison
.
CaseInsensitive
)
ResolveAndVerifySymbol
(
localSymbols
(
0
).
Type
,
typeA
,
comp20
,
SymbolIdComparison
.
CaseInsensitive
)
' ary
' ary
ResolveAndVerifySymbol
(
localSymbols
(
1
).
Type
,
comp40
,
DirectCast
(
ver20Symbols
(
0
),
IParameterSymbol
).
Type
,
comp20
,
SymbolIdComparison
.
CaseInsensitive
)
ResolveAndVerifySymbol
(
localSymbols
(
1
).
Type
,
DirectCast
(
ver20Symbols
(
0
),
IParameterSymbol
).
Type
,
comp20
,
SymbolIdComparison
.
CaseInsensitive
)
' dt
' dt
ResolveAndVerifySymbol
(
localSymbols
(
2
).
Type
,
comp40
,
DirectCast
(
ver20Symbols
(
4
),
IParameterSymbol
).
Type
,
comp20
,
SymbolIdComparison
.
CaseInsensitive
)
ResolveAndVerifySymbol
(
localSymbols
(
2
).
Type
,
DirectCast
(
ver20Symbols
(
4
),
IParameterSymbol
).
Type
,
comp20
,
SymbolIdComparison
.
CaseInsensitive
)
' fi
' fi
ResolveAndVerifySymbol
(
localSymbols
(
3
).
Type
,
comp40
,
DirectCast
(
ver20Symbols
(
1
),
IMethodSymbol
).
ReturnType
,
comp20
,
SymbolIdComparison
.
CaseInsensitive
)
ResolveAndVerifySymbol
(
localSymbols
(
3
).
Type
,
DirectCast
(
ver20Symbols
(
1
),
IMethodSymbol
).
ReturnType
,
comp20
,
SymbolIdComparison
.
CaseInsensitive
)
End
Sub
End
Sub
...
...
src/EditorFeatures/VisualBasicTest/SymbolId/SymbolKeyTestBase.vb
浏览文件 @
7ce07336
...
@@ -38,14 +38,14 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SymbolId
...
@@ -38,14 +38,14 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SymbolId
Assert
.
Equal
(
origlist
.
Count
,
newlist
.
Count
)
Assert
.
Equal
(
origlist
.
Count
,
newlist
.
Count
)
For
i
=
0
To
newlist
.
Count
-
1
For
i
=
0
To
newlist
.
Count
-
1
ResolveAndVerifySymbol
(
newlist
(
i
),
newCompilation
,
origlist
(
i
),
originalCompilation
)
ResolveAndVerifySymbol
(
newlist
(
i
),
origlist
(
i
),
originalCompilation
)
Next
Next
End
Sub
End
Sub
Friend
Shared
Sub
ResolveAndVerifyTypeSymbol
(
node
As
ExpressionSyntax
,
sourceSymbol
As
ITypeSymbol
,
model
As
SemanticModel
,
sourceComp
As
Compilation
)
Friend
Shared
Sub
ResolveAndVerifyTypeSymbol
(
node
As
ExpressionSyntax
,
sourceSymbol
As
ITypeSymbol
,
model
As
SemanticModel
,
sourceComp
As
Compilation
)
Dim
typeinfo
=
model
.
GetTypeInfo
(
node
)
Dim
typeinfo
=
model
.
GetTypeInfo
(
node
)
ResolveAndVerifySymbol
(
If
(
typeinfo
.
Type
,
typeinfo
.
ConvertedType
),
model
.
Compilation
,
sourceSymbol
,
sourceComp
)
ResolveAndVerifySymbol
(
If
(
typeinfo
.
Type
,
typeinfo
.
ConvertedType
),
sourceSymbol
,
sourceComp
)
End
Sub
End
Sub
Friend
Shared
Sub
ResolveAndVerifySymbol
(
node
As
ExpressionSyntax
,
sourceSymbol
As
ISymbol
,
model
As
SemanticModel
,
sourceComp
As
Compilation
,
Optional
comparison
As
SymbolIdComparison
=
SymbolIdComparison
.
None
)
Friend
Shared
Sub
ResolveAndVerifySymbol
(
node
As
ExpressionSyntax
,
sourceSymbol
As
ISymbol
,
model
As
SemanticModel
,
sourceComp
As
Compilation
,
Optional
comparison
As
SymbolIdComparison
=
SymbolIdComparison
.
None
)
...
@@ -56,29 +56,29 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SymbolId
...
@@ -56,29 +56,29 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SymbolId
symbol
=
syminfo
.
CandidateSymbols
.
Single
()
symbol
=
syminfo
.
CandidateSymbols
.
Single
()
End
If
End
If
ResolveAndVerifySymbol
(
symbol
,
model
.
Compilation
,
sourceSymbol
,
sourceComp
,
comparison
)
ResolveAndVerifySymbol
(
symbol
,
sourceSymbol
,
sourceComp
,
comparison
)
End
Sub
End
Sub
Friend
Shared
Sub
ResolveAndVerifySymbol
(
symbol1
As
ISymbol
,
compilation1
As
Compilation
,
symbol2
As
ISymbol
,
compilation2
As
Compilation
,
Optional
comparison
As
SymbolIdComparison
=
SymbolIdComparison
.
None
)
Friend
Shared
Sub
ResolveAndVerifySymbol
(
symbol1
As
ISymbol
,
symbol2
As
ISymbol
,
compilation2
As
Compilation
,
Optional
comparison
As
SymbolIdComparison
=
SymbolIdComparison
.
None
)
AssertSymbolsIdsEqual
(
symbol1
,
compilation1
,
symbol2
,
compilation2
,
comparison
)
AssertSymbolsIdsEqual
(
symbol1
,
symbol2
,
compilation2
,
comparison
)
Dim
resolvedSymbol
=
ResolveSymbol
(
symbol1
,
compilation
1
,
compilation
2
,
comparison
)
Dim
resolvedSymbol
=
ResolveSymbol
(
symbol1
,
compilation2
,
comparison
)
Assert
.
NotNull
(
resolvedSymbol
)
Assert
.
NotNull
(
resolvedSymbol
)
Assert
.
Equal
(
symbol2
,
resolvedSymbol
)
Assert
.
Equal
(
symbol2
,
resolvedSymbol
)
Assert
.
Equal
(
symbol2
.
GetHashCode
(),
resolvedSymbol
.
GetHashCode
())
Assert
.
Equal
(
symbol2
.
GetHashCode
(),
resolvedSymbol
.
GetHashCode
())
End
Sub
End
Sub
Friend
Shared
Function
ResolveSymbol
(
originalSymbol
As
ISymbol
,
originalCompilation
As
Compilation
,
targetCompilation
As
Compilation
,
comparison
As
SymbolIdComparison
)
As
ISymbol
Friend
Shared
Function
ResolveSymbol
(
originalSymbol
As
ISymbol
,
targetCompilation
As
Compilation
,
comparison
As
SymbolIdComparison
)
As
ISymbol
Dim
sid
=
SymbolKey
.
Create
(
originalSymbol
,
originalCompilation
,
CancellationToken
.
None
)
Dim
sid
=
SymbolKey
.
Create
(
originalSymbol
,
CancellationToken
.
None
)
Dim
symInfo
=
sid
.
Resolve
(
targetCompilation
,
(
comparison
And
SymbolIdComparison
.
IgnoreAssemblyIds
)
=
SymbolIdComparison
.
IgnoreAssemblyIds
)
Dim
symInfo
=
sid
.
Resolve
(
targetCompilation
,
(
comparison
And
SymbolIdComparison
.
IgnoreAssemblyIds
)
=
SymbolIdComparison
.
IgnoreAssemblyIds
)
Return
symInfo
.
Symbol
Return
symInfo
.
Symbol
End
Function
End
Function
Friend
Shared
Sub
AssertSymbolsIdsEqual
(
symbol1
As
ISymbol
,
compilation1
As
Compilation
,
symbol2
As
ISymbol
,
compilation2
As
Compilation
,
comparison
As
SymbolIdComparison
,
Optional
expectEqual
As
Boolean
=
True
)
Friend
Shared
Sub
AssertSymbolsIdsEqual
(
symbol1
As
ISymbol
,
symbol2
As
ISymbol
,
compilation2
As
Compilation
,
comparison
As
SymbolIdComparison
,
Optional
expectEqual
As
Boolean
=
True
)
Dim
sid1
=
SymbolKey
.
Create
(
symbol1
,
compilation1
,
CancellationToken
.
None
)
Dim
sid1
=
SymbolKey
.
Create
(
symbol1
,
CancellationToken
.
None
)
Dim
sid2
=
SymbolKey
.
Create
(
symbol2
,
compilation2
,
CancellationToken
.
None
)
Dim
sid2
=
SymbolKey
.
Create
(
symbol2
,
CancellationToken
.
None
)
Dim
isCaseSensitive
=
(
comparison
And
SymbolIdComparison
.
CaseSensitive
)
=
SymbolIdComparison
.
CaseSensitive
Dim
isCaseSensitive
=
(
comparison
And
SymbolIdComparison
.
CaseSensitive
)
=
SymbolIdComparison
.
CaseSensitive
Dim
ignoreAssemblyIds
=
(
comparison
And
SymbolIdComparison
.
IgnoreAssemblyIds
)
=
SymbolIdComparison
.
IgnoreAssemblyIds
Dim
ignoreAssemblyIds
=
(
comparison
And
SymbolIdComparison
.
IgnoreAssemblyIds
)
=
SymbolIdComparison
.
IgnoreAssemblyIds
...
...
src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs
浏览文件 @
7ce07336
...
@@ -156,7 +156,7 @@ private static bool TryResolveSymbol(ISymbol symbol, Project project, Cancellati
...
@@ -156,7 +156,7 @@ private static bool TryResolveSymbol(ISymbol symbol, Project project, Cancellati
}
}
var
originalCompilation
=
project
.
GetCompilationAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
var
originalCompilation
=
project
.
GetCompilationAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
var
symbolId
=
SymbolKey
.
Create
(
symbol
,
originalCompilation
,
cancellationToken
);
var
symbolId
=
SymbolKey
.
Create
(
symbol
,
cancellationToken
);
var
currentCompilation
=
currentProject
.
GetCompilationAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
var
currentCompilation
=
currentProject
.
GetCompilationAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
var
symbolInfo
=
symbolId
.
Resolve
(
currentCompilation
,
cancellationToken
:
cancellationToken
);
var
symbolInfo
=
symbolId
.
Resolve
(
currentCompilation
,
cancellationToken
:
cancellationToken
);
...
...
src/Workspaces/Core/Portable/SymbolId/SymbolKey.BodyLevelSymbolKey.cs
浏览文件 @
7ce07336
...
@@ -30,6 +30,9 @@ internal NonDeclarationSymbolKey(TSymbol symbol, Visitor visitor)
...
@@ -30,6 +30,9 @@ internal NonDeclarationSymbolKey(TSymbol symbol, Visitor visitor)
_containingKey
=
GetOrCreate
(
containingSymbol
,
visitor
);
_containingKey
=
GetOrCreate
(
containingSymbol
,
visitor
);
_localName
=
symbol
.
Name
;
_localName
=
symbol
.
Name
;
Contract
.
ThrowIfNull
(
visitor
.
Compilation
,
message
:
$"visitor cannot be created with a null compilation and visit a
{
nameof
(
NonDeclarationSymbolKey
<
TSymbol
>)}
."
);
foreach
(
var
possibleSymbol
in
EnumerateSymbols
(
visitor
.
Compilation
,
containingSymbol
,
_localName
,
visitor
.
CancellationToken
))
foreach
(
var
possibleSymbol
in
EnumerateSymbols
(
visitor
.
Compilation
,
containingSymbol
,
_localName
,
visitor
.
CancellationToken
))
{
{
if
(
possibleSymbol
.
Item1
.
Equals
(
symbol
))
if
(
possibleSymbol
.
Item1
.
Equals
(
symbol
))
...
...
src/Workspaces/Core/Portable/SymbolId/SymbolKey.MethodSymbolKey.cs
浏览文件 @
7ce07336
...
@@ -87,13 +87,13 @@ private IEnumerable<IMethodSymbol> Resolve(Compilation compilation, INamedTypeSy
...
@@ -87,13 +87,13 @@ private IEnumerable<IMethodSymbol> Resolve(Compilation compilation, INamedTypeSy
// Is this a conversion operator? If so, we must also compare the return type.
// Is this a conversion operator? If so, we must also compare the return type.
if
(
_returnType
!=
null
)
if
(
_returnType
!=
null
)
{
{
if
(!
_returnType
.
Equals
(
SymbolKey
.
Create
(
method
.
ReturnType
,
c
ompilation
,
c
ancellationToken
),
comparisonOptions
))
if
(!
_returnType
.
Equals
(
SymbolKey
.
Create
(
method
.
ReturnType
,
cancellationToken
),
comparisonOptions
))
{
{
continue
;
continue
;
}
}
}
}
if
(!
ParametersMatch
(
comparisonOptions
,
compilation
,
method
.
OriginalDefinition
.
Parameters
,
_refKinds
,
_originalParameterTypeKeys
,
cancellationToken
))
if
(!
ParametersMatch
(
comparisonOptions
,
method
.
OriginalDefinition
.
Parameters
,
_refKinds
,
_originalParameterTypeKeys
,
cancellationToken
))
{
{
continue
;
continue
;
}
}
...
...
src/Workspaces/Core/Portable/SymbolId/SymbolKey.PropertySymbolKey.cs
浏览文件 @
7ce07336
...
@@ -39,7 +39,7 @@ public override SymbolKeyResolution Resolve(Compilation compilation, bool ignore
...
@@ -39,7 +39,7 @@ public override SymbolKeyResolution Resolve(Compilation compilation, bool ignore
var
comparisonOptions
=
new
ComparisonOptions
(
compilation
.
IsCaseSensitive
,
ignoreAssemblyKey
,
compareMethodTypeParametersByName
:
true
);
var
comparisonOptions
=
new
ComparisonOptions
(
compilation
.
IsCaseSensitive
,
ignoreAssemblyKey
,
compareMethodTypeParametersByName
:
true
);
var
matchingProperties
=
properties
.
Where
(
p
=>
var
matchingProperties
=
properties
.
Where
(
p
=>
ParametersMatch
(
comparisonOptions
,
compilation
,
p
.
OriginalDefinition
.
Parameters
,
_refKinds
,
_originalParameterTypeKeys
,
cancellationToken
));
ParametersMatch
(
comparisonOptions
,
p
.
OriginalDefinition
.
Parameters
,
_refKinds
,
_originalParameterTypeKeys
,
cancellationToken
));
return
CreateSymbolInfo
(
matchingProperties
);
return
CreateSymbolInfo
(
matchingProperties
);
}
}
...
...
src/Workspaces/Core/Portable/SymbolId/SymbolKey.cs
浏览文件 @
7ce07336
...
@@ -103,9 +103,9 @@ public static IEqualityComparer<SymbolKey> GetComparer(bool ignoreCase, bool ign
...
@@ -103,9 +103,9 @@ public static IEqualityComparer<SymbolKey> GetComparer(bool ignoreCase, bool ign
/// through GetOrCreate and not Create.
/// through GetOrCreate and not Create.
/// </para>
/// </para>
/// </summary>
/// </summary>
internal
static
SymbolKey
Create
(
ISymbol
symbol
,
C
ompilation
compilation
=
null
,
C
ancellationToken
cancellationToken
=
default
(
CancellationToken
))
internal
static
SymbolKey
Create
(
ISymbol
symbol
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
{
{
return
GetOrCreate
(
symbol
,
new
Visitor
(
c
ompilation
,
cancellationToken
));
return
GetOrCreate
(
symbol
,
new
Visitor
(
(
symbol
.
ContainingAssembly
as
ISourceAssemblySymbol
)?.
C
ompilation
,
cancellationToken
));
}
}
private
static
SymbolKey
GetOrCreate
(
ISymbol
symbol
,
Visitor
visitor
)
private
static
SymbolKey
GetOrCreate
(
ISymbol
symbol
,
Visitor
visitor
)
...
@@ -213,7 +213,6 @@ private static SymbolKeyResolution CreateSymbolInfo(ISymbol[] symbols)
...
@@ -213,7 +213,6 @@ private static SymbolKeyResolution CreateSymbolInfo(ISymbol[] symbols)
private
static
bool
ParametersMatch
(
private
static
bool
ParametersMatch
(
ComparisonOptions
options
,
ComparisonOptions
options
,
Compilation
compilation
,
ImmutableArray
<
IParameterSymbol
>
parameters
,
ImmutableArray
<
IParameterSymbol
>
parameters
,
RefKind
[]
refKinds
,
RefKind
[]
refKinds
,
SymbolKey
[]
typeKeys
,
SymbolKey
[]
typeKeys
,
...
@@ -243,7 +242,7 @@ private static SymbolKeyResolution CreateSymbolInfo(ISymbol[] symbols)
...
@@ -243,7 +242,7 @@ private static SymbolKeyResolution CreateSymbolInfo(ISymbol[] symbols)
options
.
IgnoreAssemblyKey
,
options
.
IgnoreAssemblyKey
,
compareMethodTypeParametersByName
:
true
);
compareMethodTypeParametersByName
:
true
);
if
(!
typeKeys
[
i
].
Equals
(
SymbolKey
.
Create
(
parameter
.
Type
,
c
ompilation
,
c
ancellationToken
),
newOptions
))
if
(!
typeKeys
[
i
].
Equals
(
SymbolKey
.
Create
(
parameter
.
Type
,
cancellationToken
),
newOptions
))
{
{
return
false
;
return
false
;
}
}
...
...
src/Workspaces/Core/Portable/SymbolId/SymbolKeyExtensions.cs
浏览文件 @
7ce07336
...
@@ -8,14 +8,7 @@ internal static class SymbolKeyExtensions
...
@@ -8,14 +8,7 @@ internal static class SymbolKeyExtensions
{
{
public
static
SymbolKey
GetSymbolKey
(
this
ISymbol
symbol
)
public
static
SymbolKey
GetSymbolKey
(
this
ISymbol
symbol
)
{
{
return
SymbolKey
.
Create
(
symbol
,
null
,
CancellationToken
.
None
);
return
SymbolKey
.
Create
(
symbol
,
CancellationToken
.
None
);
}
}
#if false
internal
static
SymbolKey
GetSymbolKey
(
this
ISymbol
symbol
,
Compilation
compilation
,
CancellationToken
cancellationToken
)
{
return
SymbolKey
.
Create
(
symbol
,
compilation
,
cancellationToken
);
}
#endif
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录