Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
387ba581
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,发现更多精彩内容 >>
提交
387ba581
编写于
6月 12, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unnecessary types
上级
3815a991
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
94 deletion
+17
-94
src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjects/DefinitionProject.cs
...ols/FindReferences/DependentProjects/DefinitionProject.cs
+0
-39
src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjects/DependentProject.cs
...bols/FindReferences/DependentProjects/DependentProject.cs
+0
-36
src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjectsFinder.cs
...ble/FindSymbols/FindReferences/DependentProjectsFinder.cs
+17
-19
未找到文件。
src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjects/DefinitionProject.cs
已删除
100644 → 0
浏览文件 @
3815a991
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.FindSymbols.DependentProjects
{
/// <summary>
/// The name of the assembly, and optionally also the project, that a symbol came from. Used in the <see
/// cref="DependentProjectsFinder"/> to quickly find which set of projects in a solution should searched when
/// looking at symbols from that same location.
/// </summary>
internal
readonly
struct
DefinitionProject
:
IEquatable
<
DefinitionProject
>
{
private
readonly
ProjectId
?
_sourceProjectId
;
private
readonly
string
_assemblyName
;
public
DefinitionProject
(
ProjectId
?
sourceProjectId
,
string
assemblyName
)
{
_sourceProjectId
=
sourceProjectId
;
_assemblyName
=
assemblyName
;
}
public
override
bool
Equals
(
object
?
obj
)
=>
obj
is
DefinitionProject
project
&&
Equals
(
project
);
public
bool
Equals
(
DefinitionProject
other
)
=>
EqualityComparer
<
ProjectId
?>.
Default
.
Equals
(
_sourceProjectId
,
other
.
_sourceProjectId
)
&&
_assemblyName
==
other
.
_assemblyName
;
public
override
int
GetHashCode
()
=>
Hash
.
Combine
(
_sourceProjectId
,
_assemblyName
.
GetHashCode
());
}
}
src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjects/DependentProject.cs
已删除
100644 → 0
浏览文件 @
3815a991
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.FindSymbols.DependentProjects
{
/// <summary>
/// Represents a project that depends on some assembly, and if that project can see the internal symbols of that
/// assembly or not.
/// </summary>
internal
readonly
struct
DependentProject
:
IEquatable
<
DependentProject
>
{
public
readonly
ProjectId
ProjectId
;
public
readonly
bool
HasInternalsAccess
;
public
DependentProject
(
ProjectId
dependentProjectId
,
bool
hasInternalsAccess
)
{
this
.
ProjectId
=
dependentProjectId
;
this
.
HasInternalsAccess
=
hasInternalsAccess
;
}
public
override
bool
Equals
(
object
?
obj
)
=>
obj
is
DependentProject
project
&&
this
.
Equals
(
project
);
public
override
int
GetHashCode
()
=>
Hash
.
Combine
(
HasInternalsAccess
,
ProjectId
.
GetHashCode
());
public
bool
Equals
(
DependentProject
other
)
=>
HasInternalsAccess
==
other
.
HasInternalsAccess
&&
ProjectId
.
Equals
(
other
.
ProjectId
);
}
}
src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjectsFinder.cs
浏览文件 @
387ba581
...
...
@@ -5,7 +5,6 @@
#
nullable
enable
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Linq
;
...
...
@@ -13,7 +12,6 @@
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.FindSymbols.DependentProjects
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Shared.Utilities
;
using
Roslyn.Utilities
;
...
...
@@ -68,17 +66,17 @@ internal static partial class DependentProjectsFinder
return
ImmutableArray
<
Project
>.
Empty
;
// 1) Compute all the dependent projects (submission + non-submission) and their InternalsVisibleTo semantics to the definition project.
var
symbolVisibility
=
symbol
.
GetResultantVisibility
();
var
dependentProjects
=
await
ComputeDependentProjectsAsync
(
solution
,
symbolOrigination
,
symbol
.
GetResultantVisibility
()
,
cancellationToken
).
ConfigureAwait
(
false
);
solution
,
symbolOrigination
,
symbol
Visibility
,
cancellationToken
).
ConfigureAwait
(
false
);
// 2) Filter the above computed dependent projects based on symbol visibility.
return
GetProjects
(
solution
,
symbol
.
GetResultantVisibility
()
==
SymbolVisibility
.
Internal
?
dependentProjects
.
WhereAsArray
(
dp
=>
dp
.
HasInternalsAccess
)
:
dependentProjects
);
}
var
filteredProjects
=
symbolVisibility
==
SymbolVisibility
.
Internal
?
dependentProjects
.
WhereAsArray
(
dp
=>
dp
.
hasInternalsAccess
)
:
dependentProjects
;
private
static
ImmutableArray
<
Project
>
GetProjects
(
Solution
solution
,
ImmutableArray
<
DependentProject
>
dependentProjects
)
=>
dependentProjects
.
SelectAsArray
(
dp
=>
solution
.
GetRequiredProject
(
dp
.
ProjectId
));
return
filteredProjects
.
SelectAsArray
(
t
=>
t
.
project
);
}
/// <summary>
/// Returns a pair of data bout where <paramref name="symbol"/> originates from. It's <see
...
...
@@ -92,7 +90,7 @@ private static ImmutableArray<Project> GetProjects(Solution solution, ImmutableA
return
assembly
==
null
?
default
:
(
assembly
,
solution
.
GetProject
(
assembly
,
cancellationToken
));
}
private
static
async
Task
<
ImmutableArray
<
DependentProject
>>
ComputeDependentProjectsAsync
(
private
static
async
Task
<
ImmutableArray
<
(
Project
project
,
bool
hasInternalsAccess
)
>>
ComputeDependentProjectsAsync
(
Solution
solution
,
(
IAssemblySymbol
assembly
,
Project
?
sourceProject
)
symbolOrigination
,
SymbolVisibility
visibility
,
...
...
@@ -100,12 +98,12 @@ private static ImmutableArray<Project> GetProjects(Solution solution, ImmutableA
{
cancellationToken
.
ThrowIfCancellationRequested
();
var
dependentProjects
=
new
HashSet
<
DependentProject
>();
var
dependentProjects
=
new
HashSet
<
(
Project
,
bool
hasInternalsAccess
)
>();
// If a symbol was defined in source, then it is always visible to the project it
// was defined in.
if
(
symbolOrigination
.
sourceProject
!=
null
)
dependentProjects
.
Add
(
new
DependentProject
(
symbolOrigination
.
sourceProject
.
Id
,
hasInternalsAccess
:
true
));
dependentProjects
.
Add
(
(
symbolOrigination
.
sourceProject
,
hasInternalsAccess
:
true
));
// If it's not private, then we need to find possible references.
if
(
visibility
!=
SymbolVisibility
.
Private
)
...
...
@@ -119,7 +117,7 @@ private static ImmutableArray<Project> GetProjects(Solution solution, ImmutableA
}
private
static
async
Task
AddSubmissionDependentProjectsAsync
(
Solution
solution
,
Project
?
sourceProject
,
HashSet
<
DependentProject
>
dependentProjects
,
CancellationToken
cancellationToken
)
Solution
solution
,
Project
?
sourceProject
,
HashSet
<
(
Project
project
,
bool
hasInternalsAccess
)
>
dependentProjects
,
CancellationToken
cancellationToken
)
{
if
(
sourceProject
?.
IsSubmission
!=
true
)
return
;
...
...
@@ -161,7 +159,7 @@ private static ImmutableArray<Project> GetProjects(Solution solution, ImmutableA
// and 2, even though 2 doesn't have a direct reference to 1. Hence we need to take
// our current set of projects and find the transitive closure over backwards
// submission previous references.
var
projectIdsToProcess
=
new
Stack
<
ProjectId
>(
dependentProjects
.
Select
(
dp
=>
dp
.
Project
Id
));
var
projectIdsToProcess
=
new
Stack
<
ProjectId
>(
dependentProjects
.
Select
(
dp
=>
dp
.
project
.
Id
));
while
(
projectIdsToProcess
.
Count
>
0
)
{
...
...
@@ -171,9 +169,9 @@ private static ImmutableArray<Project> GetProjects(Solution solution, ImmutableA
{
foreach
(
var
pId
in
submissionIds
)
{
if
(!
dependentProjects
.
Any
(
dp
=>
dp
.
Project
Id
==
pId
))
if
(!
dependentProjects
.
Any
(
dp
=>
dp
.
project
.
Id
==
pId
))
{
dependentProjects
.
Add
(
new
DependentProject
(
pId
,
hasInternalsAccess
:
true
));
dependentProjects
.
Add
(
(
solution
.
GetRequiredProject
(
pId
)
,
hasInternalsAccess
:
true
));
projectIdsToProcess
.
Push
(
pId
);
}
}
...
...
@@ -194,7 +192,7 @@ private static bool IsInternalsVisibleToAttribute(AttributeData attr)
private
static
void
AddNonSubmissionDependentProjects
(
Solution
solution
,
(
IAssemblySymbol
assembly
,
Project
?
sourceProject
)
symbolOrigination
,
HashSet
<
DependentProject
>
dependentProjects
,
HashSet
<
(
Project
project
,
bool
hasInternalsAccess
)
>
dependentProjects
,
CancellationToken
cancellationToken
)
{
if
(
symbolOrigination
.
sourceProject
?.
IsSubmission
==
true
)
...
...
@@ -213,8 +211,8 @@ private static bool IsInternalsVisibleToAttribute(AttributeData attr)
// Ok, we have some project that at least references this assembly. Add it to the result, keeping track
// if it can see internals or not as well.
internalsVisibleToSet
??=
GetInternalsVisibleToSet
(
symbolOrigination
.
assembly
);
var
internalsVisibleTo
=
internalsVisibleToSet
.
Contains
(
project
.
AssemblyName
);
dependentProjects
.
Add
(
new
DependentProject
(
project
.
Id
,
internalsVisibleTo
));
var
hasInternalsAccess
=
internalsVisibleToSet
.
Contains
(
project
.
AssemblyName
);
dependentProjects
.
Add
(
(
project
,
hasInternalsAccess
));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录