Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
79b7e18d
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,发现更多精彩内容 >>
提交
79b7e18d
编写于
7月 25, 2017
作者:
H
Heejae Chang
提交者:
GitHub
7月 25, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21038 from heejaechang/crashPort
report more data on crash due to dispose
上级
ad0efbb6
5bcacbaf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
96 addition
and
2 deletion
+96
-2
src/EditorFeatures/TestUtilities/Remote/WatsonReporter.cs
src/EditorFeatures/TestUtilities/Remote/WatsonReporter.cs
+23
-0
src/EditorFeatures/TestUtilities/ServicesTestUtilities.csproj
...EditorFeatures/TestUtilities/ServicesTestUtilities.csproj
+1
-0
src/VisualStudio/Core/Next/Remote/JsonRpcClient.cs
src/VisualStudio/Core/Next/Remote/JsonRpcClient.cs
+72
-2
未找到文件。
src/EditorFeatures/TestUtilities/Remote/WatsonReporter.cs
0 → 100644
浏览文件 @
79b7e18d
// 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
src/EditorFeatures/TestUtilities/ServicesTestUtilities.csproj
浏览文件 @
79b7e18d
...
...
@@ -246,6 +246,7 @@
<Compile
Include=
"Preview\MockPreviewPaneService.cs"
/>
<Compile
Include=
"QuickInfo\AbstractQuickInfoSourceTests.cs"
/>
<Compile
Include=
"QuickInfo\AbstractSemanticQuickInfoSourceTests.cs"
/>
<Compile
Include=
"Remote\WatsonReporter.cs"
/>
<Compile
Include=
"RenameTracking\MockPreviewDialogService.cs"
/>
<Compile
Include=
"RenameTracking\MockRefactorNotifyService.cs"
/>
<Compile
Include=
"Semantics\SpeculationAnalyzerTestsBase.cs"
/>
...
...
src/VisualStudio/Core/Next/Remote/JsonRpcClient.cs
浏览文件 @
79b7e18d
...
...
@@ -2,12 +2,15 @@
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
StreamJsonRpc
;
using
Microsoft.CodeAnalysis.ErrorReporting
;
using
Microsoft.CodeAnalysis.Remote
;
using
Roslyn.Utilities
;
using
Microsoft.VisualStudio.LanguageServices.Implementation
;
namespace
Microsoft.VisualStudio.LanguageServices.Remote
{
...
...
@@ -20,6 +23,9 @@ 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
)
{
...
...
@@ -42,7 +48,7 @@ public async Task InvokeAsync(string targetName, params object[] arguments)
{
await
_rpc
.
InvokeAsync
(
targetName
,
arguments
).
ConfigureAwait
(
false
);
}
catch
catch
(
Exception
ex
)
when
(
ReportUnlessCanceled
(
ex
,
_cancellationToken
))
{
// any exception can be thrown from StreamJsonRpc if JsonRpc is disposed in the middle of read/write.
// until we move to newly added cancellation support in JsonRpc, we will catch exception and translate to
...
...
@@ -61,7 +67,7 @@ public async Task<T> InvokeAsync<T>(string targetName, params object[] arguments
{
return
await
_rpc
.
InvokeAsync
<
T
>(
targetName
,
arguments
).
ConfigureAwait
(
false
);
}
catch
catch
(
Exception
ex
)
when
(
ReportUnlessCanceled
(
ex
,
_cancellationToken
))
{
// any exception can be thrown from StreamJsonRpc if JsonRpc is disposed in the middle of read/write.
// until we move to newly added cancellation support in JsonRpc, we will catch exception and translate to
...
...
@@ -82,6 +88,68 @@ public Task<T> InvokeAsync<T>(string targetName, IEnumerable<object> arguments,
return
Extensions
.
InvokeAsync
(
_rpc
,
targetName
,
arguments
,
funcWithDirectStreamAsync
,
_cancellationToken
);
}
private
bool
ReportUnlessCanceled
(
Exception
ex
,
CancellationToken
cancellationToken
)
{
if
(
cancellationToken
.
IsCancellationRequested
)
{
return
true
;
}
// save extra info using NFW
ReportExtraInfoAsNFW
(
ex
);
// make it to explicitly crash to get better info
FatalError
.
Report
(
ex
);
GC
.
KeepAlive
(
_debuggingLastDisconnectReason
);
GC
.
KeepAlive
(
_debuggingLastDisconnectCallstack
);
return
Contract
.
FailWithReturn
<
bool
>(
"shouldn't be able to reach here"
);
}
private
void
ReportExtraInfoAsNFW
(
Exception
ex
)
{
WatsonReporter
.
Report
(
"RemoteHost Failed"
,
ex
,
u
=>
{
try
{
// we will record dumps for all service hub processes
foreach
(
var
p
in
Process
.
GetProcessesByName
(
"ServiceHub.RoslynCodeAnalysisService32"
))
{
// include all remote host processes
u
.
AddProcessDump
(
p
.
Id
);
}
// include all service hub logs as well
var
logPath
=
Path
.
Combine
(
Path
.
GetTempPath
(),
"servicehub"
,
"logs"
);
if
(
Directory
.
Exists
(
logPath
))
{
// attach all log files that are modified less than 1 day before.
var
now
=
DateTime
.
UtcNow
;
var
oneDay
=
TimeSpan
.
FromDays
(
1
);
foreach
(
var
file
in
Directory
.
EnumerateFiles
(
logPath
,
"*.log"
))
{
var
lastWrite
=
File
.
GetLastWriteTimeUtc
(
file
);
if
(
now
-
lastWrite
>
oneDay
)
{
continue
;
}
u
.
AddFile
(
file
);
}
}
}
catch
{
// ignore issue
}
// 0 means send watson
return
0
;
});
}
public
void
Dispose
()
{
OnDisposed
();
...
...
@@ -104,6 +172,8 @@ protected virtual void OnDisposed()
protected
virtual
void
OnDisconnected
(
object
sender
,
JsonRpcDisconnectedEventArgs
e
)
{
// do nothing
_debuggingLastDisconnectReason
=
e
;
_debuggingLastDisconnectCallstack
=
new
StackTrace
().
ToString
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录