提交 02da8176 编写于 作者: C Cyrus Najmabadi

PR feedback

上级 88c71cd3
...@@ -109,6 +109,9 @@ private bool TryExecuteCommand(int caretPosition, Document document, IFindUsages ...@@ -109,6 +109,9 @@ private bool TryExecuteCommand(int caretPosition, Document document, IFindUsages
{ {
try try
{ {
if (document != null)
throw new Exception();
using var token = _asyncListener.BeginAsyncOperation(nameof(StreamingFindReferencesAsync)); using var token = _asyncListener.BeginAsyncOperation(nameof(StreamingFindReferencesAsync));
// Let the presented know we're starting a search. It will give us back // Let the presented know we're starting a search. It will give us back
......
...@@ -88,7 +88,7 @@ public static void ReportNonFatal(Exception exception) ...@@ -88,7 +88,7 @@ public static void ReportNonFatal(Exception exception)
var faultEvent = new FaultEvent( var faultEvent = new FaultEvent(
eventName: FunctionId.NonFatalWatson.GetEventName(), eventName: FunctionId.NonFatalWatson.GetEventName(),
description: GetDescription(), description: GetDescription(exception),
FaultSeverity.Diagnostic, FaultSeverity.Diagnostic,
exceptionObject: exception, exceptionObject: exception,
gatherEventDetails: faultUtility => gatherEventDetails: faultUtility =>
...@@ -114,16 +114,16 @@ public static void ReportNonFatal(Exception exception) ...@@ -114,16 +114,16 @@ public static void ReportNonFatal(Exception exception)
session.PostEvent(faultEvent); session.PostEvent(faultEvent);
} }
private static string GetDescription() private static string GetDescription(Exception exception)
{ {
const string OurNamespace = nameof(Microsoft) + "." + nameof(CodeAnalysis) + "." + nameof(ErrorReporting); const string CodeAnalysisNamespace = nameof(Microsoft) + "." + nameof(CodeAnalysis);
// Be resilient to failing here. If we can't get a suitable name, just fallback to the standard name we // Be resilient to failing here. If we can't get a suitable name, just fall back to the standard name we
// used to report. // used to report.
try try
{ {
// walk up the stack looking for the first call from a type that isn't in the ErrorReporting namespace. // walk up the stack looking for the first call from a type that isn't in the ErrorReporting namespace.
foreach (var frame in new StackTrace().GetFrames()) foreach (var frame in new StackTrace(exception).GetFrames())
{ {
var method = frame.GetMethod(); var method = frame.GetMethod();
var methodName = method?.Name; var methodName = method?.Name;
...@@ -134,7 +134,7 @@ private static string GetDescription() ...@@ -134,7 +134,7 @@ private static string GetDescription()
if (declaringTypeName == null) if (declaringTypeName == null)
continue; continue;
if (declaringTypeName.StartsWith(OurNamespace)) if (!declaringTypeName.StartsWith(CodeAnalysisNamespace))
continue; continue;
return declaringTypeName + "." + methodName; return declaringTypeName + "." + methodName;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册