Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b53eb293
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,发现更多精彩内容 >>
提交
b53eb293
编写于
4月 29, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify incremental analyzer more.
上级
264ea45b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
35 deletion
+28
-35
src/Features/Core/Portable/IncrementalCaches/SymbolTreeInfoIncrementalAnalyzerProvider.cs
...mentalCaches/SymbolTreeInfoIncrementalAnalyzerProvider.cs
+17
-32
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Metadata.cs
...ortable/FindSymbols/SymbolTree/SymbolTreeInfo_Metadata.cs
+10
-0
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Source.cs
.../Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Source.cs
+1
-3
未找到文件。
src/Features/Core/Portable/IncrementalCaches/SymbolTreeInfoIncrementalAnalyzerProvider.cs
浏览文件 @
b53eb293
...
...
@@ -107,21 +107,6 @@ public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
private
static
string
GetReferenceKey
(
PortableExecutableReference
reference
)
=>
reference
.
FilePath
??
reference
.
Display
;
private
static
async
Task
<
Checksum
>
GetTotalProjectChecksumAsync
(
Project
project
,
CancellationToken
cancellationToken
)
{
// We want to recompute the symbol trees for a project whenever its source symbols
// change, or if it's metadata references change. So we get the checksums for both
// and we produce a final checksum out of that.
var
projectSourceSymbolsChecksum
=
await
SymbolTreeInfo
.
GetSourceSymbolsChecksumAsync
(
project
,
cancellationToken
).
ConfigureAwait
(
false
);
var
projectStateChecksum
=
await
project
.
State
.
GetStateChecksumsAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
metadataReferencesChecksum
=
projectStateChecksum
.
MetadataReferences
.
Checksum
;
return
Checksum
.
Create
(
nameof
(
SymbolTreeInfoIncrementalAnalyzerProvider
),
new
[]
{
projectSourceSymbolsChecksum
,
metadataReferencesChecksum
});
}
private
class
SymbolTreeInfoCacheService
:
ISymbolTreeInfoCacheService
{
private
readonly
ConcurrentDictionary
<
ProjectId
,
ProjectInfo
>
_projectToInfo
;
...
...
@@ -164,7 +149,7 @@ private class SymbolTreeInfoCacheService : ISymbolTreeInfoCacheService
Project
project
,
CancellationToken
cancellationToken
)
{
if
(
_projectToInfo
.
TryGetValue
(
project
.
Id
,
out
var
projectInfo
)
&&
projectInfo
.
Checksum
==
await
GetTotalProject
ChecksumAsync
(
project
,
cancellationToken
).
ConfigureAwait
(
false
))
projectInfo
.
Checksum
==
await
SymbolTreeInfo
.
GetSourceSymbols
ChecksumAsync
(
project
,
cancellationToken
).
ConfigureAwait
(
false
))
{
return
projectInfo
.
SymbolTreeInfo
;
}
...
...
@@ -225,41 +210,41 @@ private async Task UpdateSymbolTreeInfoAsync(Project project, CancellationToken
return
;
}
// Check the semantic version of this project. The semantic version will change
// if any of the source files changed, or if the project version itself changed.
// (The latter happens when something happens to the project like metadata
// changing on disk).
var
checksum
=
await
GetTotalProjectChecksumAsync
(
project
,
cancellationToken
).
ConfigureAwait
(
false
);
// Produce the indices for the source and metadata symbols in parallel.
var
projectTask
=
UpdateSourceSymbolTreeInfoAsync
(
project
,
cancellationToken
);
var
referencesTask
=
UpdateReferencesAync
(
project
,
cancellationToken
);
await
Task
.
WhenAll
(
projectTask
,
referencesTask
).
ConfigureAwait
(
false
);
}
private
async
Task
UpdateSourceSymbolTreeInfoAsync
(
Project
project
,
CancellationToken
cancellationToken
)
{
var
checksum
=
await
SymbolTreeInfo
.
GetSourceSymbolsChecksumAsync
(
project
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(!
_projectToInfo
.
TryGetValue
(
project
.
Id
,
out
var
projectInfo
)
||
projectInfo
.
Checksum
!=
checksum
)
{
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
// Update the symbol tree infos for metadata and source in parallel.
var
referencesTask
=
UpdateReferencesAync
(
project
,
compilation
,
cancellationToken
);
var
projectTask
=
SymbolTreeInfo
.
GetInfoForSourceAssemblyAsync
(
project
,
cancellationToken
);
await
Task
.
WhenAll
(
referencesTask
,
projectTask
).
ConfigureAwait
(
false
);
var
info
=
await
SymbolTreeInfo
.
GetInfoForSourceAssemblyAsync
(
project
,
checksum
,
cancellationToken
).
ConfigureAwait
(
false
);
// Mark that we're up to date with this project. Future calls with the same
// semantic version can bail out immediately.
projectInfo
=
new
ProjectInfo
(
checksum
,
await
projectTask
.
ConfigureAwait
(
false
)
);
projectInfo
=
new
ProjectInfo
(
checksum
,
info
);
_projectToInfo
.
AddOrUpdate
(
project
.
Id
,
projectInfo
,
(
_1
,
_2
)
=>
projectInfo
);
}
}
private
Task
UpdateReferencesAync
(
Project
project
,
C
ompilation
compilation
,
C
ancellationToken
cancellationToken
)
private
Task
UpdateReferencesAync
(
Project
project
,
CancellationToken
cancellationToken
)
{
// Process all metadata references in parallel.
var
tasks
=
project
.
MetadataReferences
.
OfType
<
PortableExecutableReference
>()
.
Select
(
r
=>
UpdateReferenceAsync
(
project
,
compilation
,
r
,
cancellationToken
))
.
Select
(
r
=>
UpdateReferenceAsync
(
project
,
r
,
cancellationToken
))
.
ToArray
();
return
Task
.
WhenAll
(
tasks
);
}
private
async
Task
UpdateReferenceAsync
(
Project
project
,
Compilation
compilation
,
PortableExecutableReference
reference
,
CancellationToken
cancellationToken
)
Project
project
,
PortableExecutableReference
reference
,
CancellationToken
cancellationToken
)
{
var
key
=
GetReferenceKey
(
reference
);
if
(
key
==
null
)
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Metadata.cs
浏览文件 @
b53eb293
...
...
@@ -59,6 +59,16 @@ private static Metadata GetMetadataNoThrow(PortableExecutableReference reference
}
}
public
static
Task
<
SymbolTreeInfo
>
TryGetInfoForMetadataReferenceAsync
(
Solution
solution
,
PortableExecutableReference
reference
,
bool
loadOnly
,
CancellationToken
cancellationToken
)
{
var
checksum
=
GetMetadataChecksum
(
solution
,
reference
,
cancellationToken
);
return
TryGetInfoForMetadataReferenceAsync
(
solution
,
reference
,
checksum
,
loadOnly
,
cancellationToken
);
}
/// <summary>
/// Produces a <see cref="SymbolTreeInfo"/> for a given <see cref="PortableExecutableReference"/>.
/// Note: can return <code>null</code> if we weren't able to actually load the metadata for some
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Source.cs
浏览文件 @
b53eb293
...
...
@@ -26,12 +26,10 @@ private static void FreeSymbolMap(MultiDictionary<string, ISymbol> symbolMap)
}
public
static
async
Task
<
SymbolTreeInfo
>
GetInfoForSourceAssemblyAsync
(
Project
project
,
CancellationToken
cancellationToken
)
Project
project
,
C
hecksum
checksum
,
C
ancellationToken
cancellationToken
)
{
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
checksum
=
await
GetSourceSymbolsChecksumAsync
(
project
,
cancellationToken
).
ConfigureAwait
(
false
);
return
await
LoadOrCreateSourceSymbolTreeInfoAsync
(
project
.
Solution
,
compilation
.
Assembly
,
checksum
,
project
.
FilePath
,
loadOnly
:
false
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录