Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
dbb8fd4d
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,发现更多精彩内容 >>
未验证
提交
dbb8fd4d
编写于
2月 20, 2020
作者:
J
Jason Malinowski
提交者:
GitHub
2月 20, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #41475 from jasonmalinowski/change-graphmodel-error-handling
Change our error handling for GraphQueryManager
上级
59902284
35930ec6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
28 deletion
+54
-28
src/VisualStudio/Core/Def/Implementation/Progression/GraphQueries/SearchGraphQuery.cs
...plementation/Progression/GraphQueries/SearchGraphQuery.cs
+23
-2
src/VisualStudio/Core/Def/Implementation/Progression/GraphQueryManager.cs
.../Core/Def/Implementation/Progression/GraphQueryManager.cs
+31
-26
未找到文件。
src/VisualStudio/Core/Def/Implementation/Progression/GraphQueries/SearchGraphQuery.cs
浏览文件 @
dbb8fd4d
...
...
@@ -13,6 +13,7 @@
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.VisualStudio.GraphModel
;
using
Roslyn.Utilities
;
using
System.Runtime.ExceptionServices
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.Progression
{
...
...
@@ -109,8 +110,28 @@ private async Task<GraphNode> AddLinkedNodeForMemberAsync(Project project, ISymb
internal
async
Task
<
ImmutableArray
<
ISymbol
>>
FindNavigableSourceSymbolsAsync
(
Project
project
,
CancellationToken
cancellationToken
)
{
var
declarations
=
await
DeclarationFinder
.
FindSourceDeclarationsWithPatternAsync
(
project
,
_searchPattern
,
SymbolFilter
.
TypeAndMember
,
cancellationToken
).
ConfigureAwait
(
false
);
ImmutableArray
<
SymbolAndProjectId
>
declarations
;
// FindSourceDeclarationsWithPatternAsync calls into OOP to do the search; if something goes badly it
// throws a SoftCrashException which inherits from OperationCanceledException. This is unfortunate, because
// it means that other bits of code see this as a cancellation and then may crash because they expect that if this
// method is raising cancellation, it's because cancellationToken requested the cancellation. The intent behind
// SoftCrashException was since it inherited from OperationCancelled it would make things safer, but in this case
// it's violating other invariants in the process which creates other problems.
//
// https://github.com/dotnet/roslyn/issues/40476 tracks removing SoftCrashException. When it is removed, the
// catch here can be removed and simply let the exception propagate; our Progression code is hardened to
// handle exceptions and report them gracefully.
try
{
declarations
=
await
DeclarationFinder
.
FindSourceDeclarationsWithPatternAsync
(
project
,
_searchPattern
,
SymbolFilter
.
TypeAndMember
,
cancellationToken
).
ConfigureAwait
(
false
);
}
catch
(
SoftCrashException
ex
)
when
(
ex
.
InnerException
!=
null
)
{
ExceptionDispatchInfo
.
Capture
(
ex
.
InnerException
).
Throw
();
throw
ExceptionUtilities
.
Unreachable
;
}
var
symbols
=
declarations
.
SelectAsArray
(
d
=>
d
.
Symbol
);
...
...
src/VisualStudio/Core/Def/Implementation/Progression/GraphQueryManager.cs
浏览文件 @
dbb8fd4d
...
...
@@ -2,6 +2,8 @@
// 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
System.Linq
;
...
...
@@ -9,6 +11,7 @@
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.ErrorReporting
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Microsoft.VisualStudio.GraphModel
;
using
Roslyn.Utilities
;
...
...
@@ -23,13 +26,13 @@ internal class GraphQueryManager
private
readonly
IAsynchronousOperationListener
_asyncListener
;
/// <summary>
/// This gate locks manipulation of
trackedQueries
.
/// This gate locks manipulation of
<see cref="_trackedQueries"/>
.
/// </summary>
private
readonly
object
_gate
=
new
object
();
private
readonly
List
<
ValueTuple
<
WeakReference
<
IGraphContext
>,
List
<
IGraphQuery
>>>
_trackedQueries
=
new
List
<
ValueTuple
<
WeakReference
<
IGraphContext
>,
List
<
IGraphQuery
>>>();
// We update all of our tracked queries when this delay elapses.
private
ResettableDelay
_delay
;
private
ResettableDelay
?
_delay
;
internal
GraphQueryManager
(
Workspace
workspace
,
IAsynchronousOperationListener
asyncListener
)
{
...
...
@@ -116,7 +119,7 @@ private Task UpdateAsync()
List
<
ValueTuple
<
IGraphContext
,
List
<
IGraphQuery
>>>
liveQueries
;
lock
(
_gate
)
{
liveQueries
=
_trackedQueries
.
Select
(
t
=>
ValueTuple
.
Create
(
t
.
Item1
.
GetTarget
(),
t
.
Item2
)).
Where
(
t
=>
t
.
Item1
!=
null
).
ToList
();
liveQueries
=
_trackedQueries
.
Select
(
t
=>
ValueTuple
.
Create
(
t
.
Item1
.
GetTarget
(),
t
.
Item2
)).
Where
(
t
=>
t
.
Item1
!=
null
).
ToList
()
!
;
}
var
solution
=
_workspace
.
CurrentSolution
;
...
...
@@ -152,33 +155,35 @@ private static bool IsTrackingContext(WeakReference<IGraphContext> weakContext)
/// <summary>
/// Populate the graph of the context with the values for the given Solution.
/// </summary>
private
static
Task
PopulateContextGraphAsync
(
Solution
solution
,
List
<
IGraphQuery
>
graphQueries
,
IGraphContext
context
)
{
var
cancellationToken
=
context
.
CancelToken
;
var
graphTasks
=
graphQueries
.
Select
(
q
=>
q
.
GetGraphAsync
(
solution
,
context
,
cancellationToken
)).
ToArray
();
var
whenAllTask
=
Task
.
WhenAll
(
graphTasks
);
return
whenAllTask
.
SafeContinueWith
(
t
=>
ProcessGraphTasks
(
t
.
Result
,
context
),
cancellationToken
,
TaskContinuationOptions
.
None
,
TaskScheduler
.
Default
);
}
private
static
void
ProcessGraphTasks
(
GraphBuilder
[]
graphBuilders
,
IGraphContext
context
)
private
static
async
Task
PopulateContextGraphAsync
(
Solution
solution
,
List
<
IGraphQuery
>
graphQueries
,
IGraphContext
context
)
{
// Perform the actual graph transaction
using
var
transaction
=
new
GraphTransactionScope
();
// Remove any links that may have been added by a previous population. We don't
// remove nodes to maintain node identity, matching the behavior of the old
// providers.
context
.
Graph
.
Links
.
Clear
();
foreach
(
var
graphBuilder
in
graphBuilders
)
try
{
graphBuilder
.
ApplyToGraph
(
context
.
Graph
);
var
cancellationToken
=
context
.
CancelToken
;
var
graphBuilderTasks
=
graphQueries
.
Select
(
q
=>
q
.
GetGraphAsync
(
solution
,
context
,
cancellationToken
)).
ToArray
();
var
graphBuilders
=
await
Task
.
WhenAll
(
graphBuilderTasks
).
ConfigureAwait
(
false
);
context
.
OutputNodes
.
AddAll
(
graphBuilder
.
CreatedNodes
);
}
// Perform the actual graph transaction
using
var
transaction
=
new
GraphTransactionScope
();
// Remove any links that may have been added by a previous population. We don't
// remove nodes to maintain node identity, matching the behavior of the old
// providers.
context
.
Graph
.
Links
.
Clear
();
transaction
.
Complete
();
foreach
(
var
graphBuilder
in
graphBuilders
)
{
graphBuilder
.
ApplyToGraph
(
context
.
Graph
);
context
.
OutputNodes
.
AddAll
(
graphBuilder
.
CreatedNodes
);
}
transaction
.
Complete
();
}
catch
(
Exception
ex
)
when
(
FatalError
.
ReportWithoutCrashUnlessCanceledAndPropagate
(
ex
))
{
throw
ExceptionUtilities
.
Unreachable
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录