Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
8bb97a1e
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,发现更多精彩内容 >>
提交
8bb97a1e
编写于
5月 09, 2017
作者:
T
Tom Meschter
提交者:
GitHub
5月 09, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18287 from tmeschter/ActuallyThrowExceptions
Ensure non-fatal exceptions are actually thrown
上级
c4b16921
db8b8e9a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
15 deletion
+37
-15
src/Compilers/Core/Portable/InternalUtilities/FatalError.cs
src/Compilers/Core/Portable/InternalUtilities/FatalError.cs
+22
-1
src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.Update.cs
...ures/Core/SymbolSearch/SymbolSearchUpdateEngine.Update.cs
+9
-12
src/VisualStudio/Core/Def/Utilities/IVsEditorAdaptersFactoryServiceExtensions.cs
...ef/Utilities/IVsEditorAdaptersFactoryServiceExtensions.cs
+3
-2
src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs
...orkspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
...Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
+1
-0
未找到文件。
src/Compilers/Core/Portable/InternalUtilities/FatalError.cs
浏览文件 @
8bb97a1e
...
...
@@ -131,13 +131,34 @@ public static bool Report(Exception exception)
}
/// <summary>
///
Use in an exception filter to report a non
fatal error.
///
Report a non-
fatal error.
/// Calls <see cref="NonFatalHandler"/> and doesn't pass the exception through (the method returns true).
/// This is generally expected to be used within an exception filter as that allows us to
/// capture data at the point the exception is thrown rather than when it is handled.
/// However, it can also be used outside of an exception filter. If the exception has not
/// already been thrown the method will throw and catch it itself to ensure we get a useful
/// stack trace.
/// </summary>
/// <returns>True to catch the exception.</returns>
[
DebuggerHidden
]
public
static
bool
ReportWithoutCrash
(
Exception
exception
)
{
// There have been cases where a new, unthrown exception has been passed to this method.
// In these cases the exception won't have a stack trace, which isn't very helpful. We
// throw and catch the exception here as that will result in a stack trace that is
// better than nothing.
if
(
exception
.
StackTrace
==
null
)
{
try
{
throw
exception
;
}
catch
{
// Empty; we just need the exception to have a stack trace.
}
}
Report
(
exception
,
s_nonFatalHandler
);
return
true
;
}
...
...
src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.Update.cs
浏览文件 @
8bb97a1e
...
...
@@ -564,15 +564,14 @@ private async Task RepeatIOAsync(Func<Task> action)
await
action
().
ConfigureAwait
(
false
);
return
;
}
catch
(
Exception
e
)
catch
(
Exception
e
)
when
(
IOUtilities
.
IsNormalIOException
(
e
)
||
_service
.
_reportAndSwallowException
(
e
))
{
// Normal IO exception. Don't bother reporting it. We don't want to get
// lots of hits just because we couldn't write a file because of something
// like an anti-virus tool lockign the file.
if
(!
IOUtilities
.
IsNormalIOException
(
e
))
{
_service
.
_reportAndSwallowException
(
e
);
}
// The exception filter above might be a little funny looking. We always
// want to enter this catch block, but if we ran into a normal IO exception
// we shouldn't bother reporting it. We don't want to get lots of hits just
// because something like an anti-virus tool locked the file and we
// couldn't write to it. The call to IsNormalIOException will shortcut
// around the reporting in this case.
var
delay
=
_service
.
_delayService
.
FileWriteDelay
;
await
_service
.
LogExceptionAsync
(
e
,
$"Operation failed. Trying again after
{
delay
}
"
).
ConfigureAwait
(
false
);
...
...
@@ -587,8 +586,7 @@ private async Task RepeatIOAsync(Func<Task> action)
var
contentsAttribute
=
element
.
Attribute
(
ContentAttributeName
);
if
(
contentsAttribute
==
null
)
{
_service
.
_reportAndSwallowException
(
new
FormatException
(
$"Database element invalid. Missing '
{
ContentAttributeName
}
' attribute"
));
_service
.
_reportAndSwallowException
(
new
FormatException
(
$"Database element invalid. Missing '
{
ContentAttributeName
}
' attribute"
));
return
ValueTuple
.
Create
(
false
,
(
byte
[])
null
);
}
...
...
@@ -607,8 +605,7 @@ private async Task RepeatIOAsync(Func<Task> action)
if
(!
StringComparer
.
Ordinal
.
Equals
(
expectedChecksum
,
actualChecksum
))
{
_service
.
_reportAndSwallowException
(
new
FormatException
(
$"Checksum mismatch: expected != actual.
{
expectedChecksum
}
!=
{
actualChecksum
}
"
));
_service
.
_reportAndSwallowException
(
new
FormatException
(
$"Checksum mismatch: expected != actual.
{
expectedChecksum
}
!=
{
actualChecksum
}
"
));
return
ValueTuple
.
Create
(
false
,
(
byte
[])
null
);
}
...
...
src/VisualStudio/Core/Def/Utilities/IVsEditorAdaptersFactoryServiceExtensions.cs
浏览文件 @
8bb97a1e
...
...
@@ -30,8 +30,9 @@ internal static class IVsEditorAdaptersFactoryServiceExtensions
var
message
=
contextDocumentId
==
null
?
$"
{
nameof
(
contextDocumentId
)}
was null."
:
$"
{
nameof
(
contextDocumentId
)}
was not null."
;
FatalError
.
ReportWithoutCrash
(
new
InvalidOperationException
(
"Could not retrieve document. "
+
message
));
FatalError
.
ReportWithoutCrash
(
new
InvalidOperationException
(
"Could not retrieve document. "
+
message
));
return
null
;
}
...
...
src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs
浏览文件 @
8bb97a1e
...
...
@@ -188,7 +188,9 @@ public ISymbol TryResolve(SemanticModel semanticModel, CancellationToken cancell
$@"Invalid span in
{
nameof
(
DeclaredSymbolInfo
)}
.
{
nameof
(
this
.
Span
)}
=
{
this
.
Span
}
{
nameof
(
root
.
FullSpan
)}
=
{
root
.
FullSpan
}
"
;
FatalError
.
ReportWithoutCrash
(
new
InvalidOperationException
(
message
));
return
null
;
}
}
...
...
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
浏览文件 @
8bb97a1e
...
...
@@ -89,6 +89,7 @@ internal sealed partial class SyntaxTreeIndex
$@"Invalid span in
{
nameof
(
declaredSymbolInfo
)}
.
{
nameof
(
declaredSymbolInfo
.
Span
)}
=
{
declaredSymbolInfo
.
Span
}
{
nameof
(
root
.
FullSpan
)}
=
{
root
.
FullSpan
}
"
;
FatalError
.
ReportWithoutCrash
(
new
InvalidOperationException
(
message
));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录