From 02da81764681aa19807c780fbbcefdf249c6d290 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 1 May 2020 21:19:47 -0700 Subject: [PATCH] PR feedback --- .../FindReferences/FindReferencesCommandHandler.cs | 3 +++ .../Core/Def/Implementation/Watson/WatsonReporter.cs | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/EditorFeatures/Core/FindReferences/FindReferencesCommandHandler.cs b/src/EditorFeatures/Core/FindReferences/FindReferencesCommandHandler.cs index 53e8cbe6e69..76534aace59 100644 --- a/src/EditorFeatures/Core/FindReferences/FindReferencesCommandHandler.cs +++ b/src/EditorFeatures/Core/FindReferences/FindReferencesCommandHandler.cs @@ -109,6 +109,9 @@ private bool TryExecuteCommand(int caretPosition, Document document, IFindUsages { try { + if (document != null) + throw new Exception(); + using var token = _asyncListener.BeginAsyncOperation(nameof(StreamingFindReferencesAsync)); // Let the presented know we're starting a search. It will give us back diff --git a/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs b/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs index db04b0166a9..3d598821b41 100644 --- a/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs +++ b/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs @@ -88,7 +88,7 @@ public static void ReportNonFatal(Exception exception) var faultEvent = new FaultEvent( eventName: FunctionId.NonFatalWatson.GetEventName(), - description: GetDescription(), + description: GetDescription(exception), FaultSeverity.Diagnostic, exceptionObject: exception, gatherEventDetails: faultUtility => @@ -114,16 +114,16 @@ public static void ReportNonFatal(Exception exception) 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. try { // 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 methodName = method?.Name; @@ -134,7 +134,7 @@ private static string GetDescription() if (declaringTypeName == null) continue; - if (declaringTypeName.StartsWith(OurNamespace)) + if (!declaringTypeName.StartsWith(CodeAnalysisNamespace)) continue; return declaringTypeName + "." + methodName; -- GitLab