Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
6a463b29
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,发现更多精彩内容 >>
提交
6a463b29
编写于
5月 07, 2017
作者:
C
CyrusNajmabadi
提交者:
GitHub
5月 07, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19328 from CyrusNajmabadi/deferCompilationCreation
Defer creating a compilation if it is not needed.
上级
4f99e31b
618fd16c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
35 deletion
+34
-35
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
...es/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
+7
-1
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Metadata.cs
...ortable/FindSymbols/SymbolTree/SymbolTreeInfo_Metadata.cs
+3
-3
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Serialization.cs
...le/FindSymbols/SymbolTree/SymbolTreeInfo_Serialization.cs
+10
-15
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Source.cs
.../Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Source.cs
+11
-11
src/Workspaces/CoreTest/FindAllDeclarationsTests.cs
src/Workspaces/CoreTest/FindAllDeclarationsTests.cs
+3
-5
未找到文件。
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs
浏览文件 @
6a463b29
...
...
@@ -323,7 +323,13 @@ private int BinarySearch(string name)
// for non-fuzzy searches, and soon afterwards it will be able to perform
// fuzzy searches as well.
return
Task
.
Run
(()
=>
LoadOrCreateSpellCheckerAsync
(
solution
,
checksum
,
filePath
,
()
=>
new
SpellChecker
(
checksum
,
sortedNodes
.
Select
(
n
=>
new
StringSlice
(
concatenatedNames
,
n
.
NameSpan
)))));
()
=>
CreateSpellCheckerAsync
(
checksum
,
concatenatedNames
,
sortedNodes
)));
}
private
static
Task
<
SpellChecker
>
CreateSpellCheckerAsync
(
Checksum
checksum
,
string
concatenatedNames
,
Node
[]
sortedNodes
)
{
return
Task
.
FromResult
(
new
SpellChecker
(
checksum
,
sortedNodes
.
Select
(
n
=>
new
StringSlice
(
concatenatedNames
,
n
.
NameSpan
))));
}
private
static
void
SortNodes
(
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Metadata.cs
浏览文件 @
6a463b29
...
...
@@ -161,20 +161,20 @@ private static Metadata GetMetadataNoThrow(PortableExecutableReference reference
checksum
,
filePath
,
loadOnly
,
create
:
()
=>
CreateMetadataSymbolTreeInfo
(
solution
,
checksum
,
reference
,
cancellationToken
),
create
Async
:
()
=>
CreateMetadataSymbolTreeInfoAsync
(
solution
,
checksum
,
reference
,
cancellationToken
),
keySuffix
:
"_Metadata"
,
getPersistedChecksum
:
info
=>
info
.
Checksum
,
readObject
:
reader
=>
ReadSymbolTreeInfo
(
reader
,
(
names
,
nodes
)
=>
GetSpellCheckerTask
(
solution
,
checksum
,
filePath
,
names
,
nodes
)),
cancellationToken
:
cancellationToken
);
}
private
static
SymbolTreeInfo
CreateMetadataSymbolTreeInfo
(
private
static
Task
<
SymbolTreeInfo
>
CreateMetadataSymbolTreeInfoAsync
(
Solution
solution
,
Checksum
checksum
,
PortableExecutableReference
reference
,
CancellationToken
cancellationToken
)
{
var
creator
=
new
MetadataInfoCreator
(
solution
,
checksum
,
reference
,
cancellationToken
);
return
creator
.
Create
(
);
return
Task
.
FromResult
(
creator
.
Create
()
);
}
private
struct
MetadataInfoCreator
:
IDisposable
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Serialization.cs
浏览文件 @
6a463b29
...
...
@@ -24,22 +24,17 @@ internal partial class SymbolTreeInfo : IObjectWritable
/// info can't be loaded, it will be created (and persisted if possible).
/// </summary>
private
static
Task
<
SymbolTreeInfo
>
LoadOrCreateSourceSymbolTreeInfoAsync
(
Solution
solution
,
IAssemblySymbol
assembly
,
Checksum
checksum
,
string
filePath
,
bool
loadOnly
,
CancellationToken
cancellationToken
)
Project
project
,
Checksum
checksum
,
bool
loadOnly
,
CancellationToken
cancellationToken
)
{
return
LoadOrCreateAsync
(
s
olution
,
project
.
S
olution
,
checksum
,
f
ilePath
,
project
.
F
ilePath
,
loadOnly
,
create
:
()
=>
CreateSourceSymbolTreeInfo
(
solution
,
checksum
,
assembly
,
filePath
,
cancellationToken
),
create
Async
:
()
=>
CreateSourceSymbolTreeInfoAsync
(
project
,
checksum
,
cancellationToken
),
keySuffix
:
"_Source"
,
getPersistedChecksum
:
info
=>
info
.
Checksum
,
readObject
:
reader
=>
ReadSymbolTreeInfo
(
reader
,
(
names
,
nodes
)
=>
GetSpellCheckerTask
(
solution
,
checksum
,
f
ilePath
,
names
,
nodes
)),
readObject
:
reader
=>
ReadSymbolTreeInfo
(
reader
,
(
names
,
nodes
)
=>
GetSpellCheckerTask
(
project
.
Solution
,
checksum
,
project
.
F
ilePath
,
names
,
nodes
)),
cancellationToken
:
cancellationToken
);
}
...
...
@@ -51,14 +46,14 @@ internal partial class SymbolTreeInfo : IObjectWritable
Solution
solution
,
Checksum
checksum
,
string
filePath
,
Func
<
SpellChecker
>
create
)
Func
<
Task
<
SpellChecker
>>
createAsync
)
{
return
LoadOrCreateAsync
(
solution
,
checksum
,
filePath
,
loadOnly
:
false
,
create
:
create
,
create
Async
:
createAsync
,
keySuffix
:
"_SpellChecker"
,
getPersistedChecksum
:
s
=>
s
.
Checksum
,
readObject
:
SpellChecker
.
ReadFrom
,
...
...
@@ -74,7 +69,7 @@ internal partial class SymbolTreeInfo : IObjectWritable
Checksum
checksum
,
string
filePath
,
bool
loadOnly
,
Func
<
T
>
create
,
Func
<
T
ask
<
T
>>
createAsync
,
string
keySuffix
,
Func
<
T
,
Checksum
>
getPersistedChecksum
,
Func
<
ObjectReader
,
T
>
readObject
,
...
...
@@ -82,7 +77,7 @@ internal partial class SymbolTreeInfo : IObjectWritable
{
if
(
checksum
==
null
)
{
return
loadOnly
?
null
:
create
(
);
return
loadOnly
?
null
:
await
createAsync
().
ConfigureAwait
(
false
);
}
// Ok, we can use persistence. First try to load from the persistence service.
...
...
@@ -120,7 +115,7 @@ internal partial class SymbolTreeInfo : IObjectWritable
}
// Now, try to create a new instance and write it to the persistence service.
result
=
create
(
);
result
=
await
createAsync
().
ConfigureAwait
(
false
);
if
(
result
!=
null
)
{
using
(
var
stream
=
SerializableBytes
.
CreateWritableStream
())
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Source.cs
浏览文件 @
6a463b29
...
...
@@ -28,14 +28,11 @@ private static void FreeSymbolMap(MultiDictionary<string, ISymbol> symbolMap)
s_symbolMapPool
.
Free
(
symbolMap
);
}
public
static
async
Task
<
SymbolTreeInfo
>
GetInfoForSourceAssemblyAsync
(
public
static
Task
<
SymbolTreeInfo
>
GetInfoForSourceAssemblyAsync
(
Project
project
,
Checksum
checksum
,
CancellationToken
cancellationToken
)
{
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
return
await
LoadOrCreateSourceSymbolTreeInfoAsync
(
project
.
Solution
,
compilation
.
Assembly
,
checksum
,
project
.
FilePath
,
loadOnly
:
false
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
return
LoadOrCreateSourceSymbolTreeInfoAsync
(
project
,
checksum
,
loadOnly
:
false
,
cancellationToken
:
cancellationToken
);
}
public
static
async
Task
<
Checksum
>
GetSourceSymbolsChecksumAsync
(
Project
project
,
CancellationToken
cancellationToken
)
...
...
@@ -49,7 +46,9 @@ public static async Task<Checksum> GetSourceSymbolsChecksumAsync(Project project
var
serializer
=
new
Serializer
(
project
.
Solution
.
Workspace
);
var
projectStateChecksums
=
await
project
.
State
.
GetStateChecksumsAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
textChecksumsTasks
=
project
.
Documents
.
Select
(
async
d
=>
// Order the documents by FilePath. Default ordering in the RemoteWorkspace is
// to be ordered by Guid (which is not consistent across VS sessions).
var
textChecksumsTasks
=
project
.
Documents
.
OrderBy
(
d
=>
d
.
FilePath
).
Select
(
async
d
=>
{
var
documentStateChecksum
=
await
d
.
State
.
GetStateChecksumsAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
return
documentStateChecksum
.
Text
;
...
...
@@ -75,10 +74,11 @@ public static async Task<Checksum> GetSourceSymbolsChecksumAsync(Project project
}
}
internal
static
SymbolTreeInfo
CreateSourceSymbolTreeInfo
(
Solution
solution
,
Checksum
checksum
,
IAssemblySymbol
assembly
,
string
filePath
,
CancellationToken
cancellationToken
)
internal
static
async
Task
<
SymbolTreeInfo
>
CreateSourceSymbolTreeInfoAsync
(
Project
project
,
Checksum
checksum
,
CancellationToken
cancellationToken
)
{
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
assembly
=
compilation
.
Assembly
;
if
(
assembly
==
null
)
{
return
null
;
...
...
@@ -90,7 +90,7 @@ public static async Task<Checksum> GetSourceSymbolsChecksumAsync(Project project
GenerateSourceNodes
(
assembly
.
GlobalNamespace
,
unsortedNodes
,
s_getMembersNoPrivate
);
return
CreateSymbolTreeInfo
(
solution
,
checksum
,
f
ilePath
,
unsortedNodes
.
ToImmutableAndFree
(),
project
.
Solution
,
checksum
,
project
.
F
ilePath
,
unsortedNodes
.
ToImmutableAndFree
(),
inheritanceMap
:
new
OrderPreservingMultiDictionary
<
string
,
string
>());
}
...
...
src/Workspaces/CoreTest/FindAllDeclarationsTests.cs
浏览文件 @
6a463b29
...
...
@@ -537,13 +537,11 @@ public async Task FindSourceDeclarationsAsync_Solution_Func_Test_Cancellation()
public
async
Task
TestSymbolTreeInfoSerialization
()
{
var
solution
=
GetSolution
(
WorkspaceKind
.
SingleClass
);
var
compilation
=
await
solution
.
Projects
.
First
().
GetCompilationAsync
();
var
assembly
=
compilation
.
GetSpecialType
(
SpecialType
.
System_Byte
).
ContainingAssembly
;
////var assembly = compilation.Assembly;
var
project
=
solution
.
Projects
.
First
();
// create symbol tree info from assembly
var
info
=
SymbolTreeInfo
.
CreateSourceSymbolTreeInfo
(
solution
,
Checksum
.
Null
,
assembly
,
""
,
cancellationToken
:
CancellationToken
.
None
);
var
info
=
await
SymbolTreeInfo
.
CreateSourceSymbolTreeInfoAsync
(
project
,
Checksum
.
Null
,
cancellationToken
:
CancellationToken
.
None
);
using
(
var
writerStream
=
new
MemoryStream
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录