Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
R
roslyn
管理
动态
成员
标记
计划
议题
议题看板
里程碑
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
构建
流水线
作业
流水线计划
产物
部署
发布
软件包库
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
Show more breadcrumbs
麦壳饼
roslyn
提交
e5e5e609
提交
e5e5e609
编辑于
7年前
作者:
Sam Harwell
提交者:
GitHub
7年前
浏览文件
操作
下载
差异文件
Merge pull request #21152 from heejaechang/dontcrash2
replaced crash to NFW. it will now show info bar and throw cancellati…
上级
caae8b5a
093cf36c
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
src/EditorFeatures/TestUtilities/Remote/WatsonReporter.cs
+28
-22
28 个添加, 22 个删除
src/EditorFeatures/TestUtilities/Remote/WatsonReporter.cs
src/VisualStudio/Core/Next/Remote/JsonRpcClient.cs
+73
-30
73 个添加, 30 个删除
src/VisualStudio/Core/Next/Remote/JsonRpcClient.cs
有
101 个添加
和
52 个删除
src/EditorFeatures/TestUtilities/Remote/WatsonReporter.cs
+
28
−
22
浏览文件 @
e5e5e609
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation
{
/// <summary>
/// Mock to make test project build
/// </summary>
internal
class
WatsonReporter
{
public
static
void
Report
(
string
description
,
Exception
exception
,
Func
<
IFaultUtility
,
int
>
callback
)
{
// do nothing
}
public
interface
IFaultUtility
{
void
AddProcessDump
(
int
pid
);
void
AddFile
(
string
fullpathname
);
}
}
}
\ No newline at end of file
using
System
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation
{
/// <summary>
/// Mock to make test project build
/// </summary>
internal
class
WatsonReporter
{
public
static
void
Report
(
string
description
,
Exception
exception
,
Func
<
IFaultUtility
,
int
>
callback
)
{
// do nothing
}
public
interface
IFaultUtility
{
void
AddProcessDump
(
int
pid
);
void
AddFile
(
string
fullpathname
);
}
}
// Mock resource to make test project build
internal
static
class
ServicesVSResources
{
public
const
string
Unfortunately_a_process_used_by_Visual_Studio_has_encountered_an_unrecoverable_error_We_recommend_saving_your_work_and_then_closing_and_restarting_Visual_Studio
=
""
;
}
}
This diff is collapsed.
点击以展开。
src/VisualStudio/Core/Next/Remote/JsonRpcClient.cs
+
73
−
30
浏览文件 @
e5e5e609
...
...
@@ -8,9 +8,10 @@
using
System.Threading.Tasks
;
using
StreamJsonRpc
;
using
Microsoft.CodeAnalysis.ErrorReporting
;
using
Microsoft.CodeAnalysis.Extensions
;
using
Microsoft.CodeAnalysis.Remote
;
using
Roslyn.Utilities
;
using
Microsoft.VisualStudio.LanguageServices.Implementation
;
using
Roslyn.Utilities
;
namespace
Microsoft.VisualStudio.LanguageServices.Remote
{
...
...
@@ -23,9 +24,6 @@ internal class JsonRpcClient : IDisposable
private
readonly
JsonRpc
_rpc
;
private
readonly
CancellationToken
_cancellationToken
;
private
JsonRpcDisconnectedEventArgs
_debuggingLastDisconnectReason
;
private
string
_debuggingLastDisconnectCallstack
;
public
JsonRpcClient
(
Stream
stream
,
object
callbackTarget
,
bool
useThisAsCallback
,
CancellationToken
cancellationToken
)
{
...
...
@@ -55,7 +53,10 @@ public async Task InvokeAsync(string targetName, params object[] arguments)
// cancellation exception here. if any exception is thrown unrelated to cancellation, then we will rethrow
// the exception
_cancellationToken
.
ThrowIfCancellationRequested
();
throw
;
// this is to make us not crash. we should remove this once we figure out
// what is causing this
ThrowOwnCancellationToken
();
}
}
...
...
@@ -74,7 +75,11 @@ public async Task<T> InvokeAsync<T>(string targetName, params object[] arguments
// cancellation exception here. if any exception is thrown unrelated to cancellation, then we will rethrow
// the exception
_cancellationToken
.
ThrowIfCancellationRequested
();
throw
;
// this is to make us not crash. we should remove this once we figure out
// what is causing this
ThrowOwnCancellationToken
();
return
Contract
.
FailWithReturn
<
T
>(
"can't reach here"
);
}
}
...
...
@@ -88,6 +93,33 @@ public Task<T> InvokeAsync<T>(string targetName, IEnumerable<object> arguments,
return
Extensions
.
InvokeAsync
(
_rpc
,
targetName
,
arguments
,
funcWithDirectStreamAsync
,
_cancellationToken
);
}
public
void
Dispose
()
{
OnDisposed
();
_rpc
.
Dispose
();
}
protected
void
StartListening
()
{
// due to this issue - https://github.com/dotnet/roslyn/issues/16900#issuecomment-277378950
// _rpc need to be explicitly started
_rpc
.
StartListening
();
}
protected
virtual
void
OnDisposed
()
{
// do nothing
}
// these are for debugging purpose. once we find out root cause of the issue
// we will remove these.
private
static
JsonRpcDisconnectedEventArgs
s_debuggingLastDisconnectReason
;
private
static
string
s_debuggingLastDisconnectCallstack
;
private
JsonRpcDisconnectedEventArgs
_debuggingLastDisconnectReason
;
private
string
_debuggingLastDisconnectCallstack
;
private
bool
ReportUnlessCanceled
(
Exception
ex
,
CancellationToken
cancellationToken
)
{
if
(
cancellationToken
.
IsCancellationRequested
)
...
...
@@ -95,16 +127,46 @@ private bool ReportUnlessCanceled(Exception ex, CancellationToken cancellationTo
return
true
;
}
// save extra info using NFW
ReportExtraInfoAsNFW
(
ex
)
;
s_debuggingLastDisconnectReason
=
_debuggingLastDisconnectReason
;
s_debuggingLastDisconnectCallstack
=
_debuggingLastDisconnectCallstack
;
//
make it to explicitly crash to get better info
FatalError
.
Report
(
ex
);
//
send NFW to figure out why this is happening
ReportExtraInfoAsNFW
(
ex
);
GC
.
KeepAlive
(
_debuggingLastDisconnectReason
);
GC
.
KeepAlive
(
_debuggingLastDisconnectCallstack
);
return
Contract
.
FailWithReturn
<
bool
>(
"shouldn't be able to reach here"
);
return
true
;
}
private
static
bool
s_reported
=
false
;
/// <summary>
/// Show info bar and throw its own cancellation exception until
/// we figure out this issue.
/// https://devdiv.visualstudio.com/DevDiv/_workitems/edit/453544
///
/// the issue is basically we are getting unexpected exception from InvokeAsync
/// and we don't know exactly why that is happening.
/// </summary>
private
void
ThrowOwnCancellationToken
()
{
if
(
CodeAnalysis
.
PrimaryWorkspace
.
Workspace
!=
null
&&
!
s_reported
)
{
// do not report it multiple times
s_reported
=
true
;
// use info bar to show warning to users
CodeAnalysis
.
PrimaryWorkspace
.
Workspace
.
Services
.
GetService
<
IErrorReportingService
>()?.
ShowGlobalErrorInfo
(
ServicesVSResources
.
Unfortunately_a_process_used_by_Visual_Studio_has_encountered_an_unrecoverable_error_We_recommend_saving_your_work_and_then_closing_and_restarting_Visual_Studio
);
}
// create its own cancellation token and throw it
using
(
var
ownCancellationSource
=
new
CancellationTokenSource
())
{
ownCancellationSource
.
Cancel
();
ownCancellationSource
.
Token
.
ThrowIfCancellationRequested
();
}
}
private
void
ReportExtraInfoAsNFW
(
Exception
ex
)
...
...
@@ -150,25 +212,6 @@ private void ReportExtraInfoAsNFW(Exception ex)
});
}
public
void
Dispose
()
{
OnDisposed
();
_rpc
.
Dispose
();
}
protected
void
StartListening
()
{
// due to this issue - https://github.com/dotnet/roslyn/issues/16900#issuecomment-277378950
// _rpc need to be explicitly started
_rpc
.
StartListening
();
}
protected
virtual
void
OnDisposed
()
{
// do nothing
}
protected
virtual
void
OnDisconnected
(
object
sender
,
JsonRpcDisconnectedEventArgs
e
)
{
// do nothing
...
...
This diff is collapsed.
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录