From 3ef7b361f42a1d837c70e0123ce792f066a7bc95 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 9 Sep 2020 17:32:30 -0700 Subject: [PATCH 1/7] Initialize fatal error handlers in VS and OOP --- .../Implementation/ProjectSystem/VisualStudioWorkspace.cs | 6 ++++++ src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspace.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspace.cs index b3d8e77f2d91b..b85e39e017cf0 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspace.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspace.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Threading; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -24,6 +25,11 @@ public abstract class VisualStudioWorkspace : Workspace private BackgroundCompiler? _backgroundCompiler; private readonly BackgroundParser _backgroundParser; + static VisualStudioWorkspace() + { + WatsonReporter.InitializeFatalErrorHandlers(); + } + internal VisualStudioWorkspace(HostServices hostServices) : base(hostServices, WorkspaceKind.Host) { diff --git a/src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs b/src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs index ea49ebfac254a..f236b0bd84f07 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs @@ -43,6 +43,8 @@ internal abstract class ServiceBase : IDisposable static ServiceBase() { + WatsonReporter.InitializeFatalErrorHandlers(); + // Use a TraceListener hook to intercept assertion failures and report them through FatalError. WatsonTraceListener.Install(); } From 3328bd4fe4d98c22c4be8abd8334865c709a0cd6 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 10 Sep 2020 09:17:00 -0700 Subject: [PATCH 2/7] Remove WatsonTraceListener from Remote.ServiceHub This listener conflicts with ThrowingTraceListener, and significantly impairs the ability to identify test failures. --- .../ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj | 1 - src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/Workspaces/Remote/ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj b/src/Workspaces/Remote/ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj index 2403bb45f22eb..64df51e3276f5 100644 --- a/src/Workspaces/Remote/ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj +++ b/src/Workspaces/Remote/ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj @@ -41,7 +41,6 @@ - diff --git a/src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs b/src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs index f236b0bd84f07..83862e28eed8d 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/ServiceBase.cs @@ -44,9 +44,6 @@ internal abstract class ServiceBase : IDisposable static ServiceBase() { WatsonReporter.InitializeFatalErrorHandlers(); - - // Use a TraceListener hook to intercept assertion failures and report them through FatalError. - WatsonTraceListener.Install(); } protected ServiceBase(IServiceProvider serviceProvider, Stream stream, IEnumerable? jsonConverters = null) From ae59b76365fe965beecd834d1859ba03706dde96 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 10 Sep 2020 16:23:37 -0700 Subject: [PATCH 3/7] Fix failure to handle null DataLocation --- .../TaskList/ExternalErrorDiagnosticUpdateSource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VisualStudio/Core/Def/Implementation/TaskList/ExternalErrorDiagnosticUpdateSource.cs b/src/VisualStudio/Core/Def/Implementation/TaskList/ExternalErrorDiagnosticUpdateSource.cs index 60e56ab6c4510..c455dda6e116b 100644 --- a/src/VisualStudio/Core/Def/Implementation/TaskList/ExternalErrorDiagnosticUpdateSource.cs +++ b/src/VisualStudio/Core/Def/Implementation/TaskList/ExternalErrorDiagnosticUpdateSource.cs @@ -510,7 +510,7 @@ static bool IsDocumentLevelDiagnostic(DiagnosticData diagnoaticData) // // unfortunately, there is no 100% correct way to do this. // so we will use a heuristic that will most likely work for most of common cases. - return !string.IsNullOrEmpty(diagnoaticData.DataLocation.OriginalFilePath) && + return !string.IsNullOrEmpty(diagnoaticData.DataLocation?.OriginalFilePath) && (diagnoaticData.DataLocation.OriginalStartLine > 0 || diagnoaticData.DataLocation.OriginalStartColumn > 0); } From aeb0a50a3d01bf786936e9cde5ca4e7f9d724b21 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 10 Sep 2020 16:45:50 -0700 Subject: [PATCH 4/7] Disable validation of incremental parsing Currently the incremental parser is not producing trees with the correct text. However, this bug was introduced in the past and is failing now that debug assertions are checked in builds. See #47610 --- .../Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb b/src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb index 0304c36e8e63d..654ab31347d55 100644 --- a/src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb +++ b/src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb @@ -2405,7 +2405,7 @@ public class Goo End Function - + Public Async Function LocalFunctionAttributeNamedPropertyCompletionCommitWithTab(showCompletionInArgumentLists As Boolean) As Task Using state = TestStateFactory.CreateCSharpTestState( From 643961fc926b1dda6984386bf3db70a2f2fb8e1a Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 10 Sep 2020 20:49:35 -0700 Subject: [PATCH 5/7] Implement stub FindAllReferencesWindow.SetProgress --- .../Core/Test/Venus/DocumentService_IntegrationTests.vb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/VisualStudio/Core/Test/Venus/DocumentService_IntegrationTests.vb b/src/VisualStudio/Core/Test/Venus/DocumentService_IntegrationTests.vb index c86a1a16434e7..1252f492cbecd 100644 --- a/src/VisualStudio/Core/Test/Venus/DocumentService_IntegrationTests.vb +++ b/src/VisualStudio/Core/Test/Venus/DocumentService_IntegrationTests.vb @@ -400,15 +400,13 @@ class { } Public Sub AddCommandTarget(target As IOleCommandTarget, ByRef [next] As IOleCommandTarget) Implements IFindAllReferencesWindow.AddCommandTarget Throw New NotImplementedException() End Sub +#End Region Public Sub SetProgress(progress As Double) Implements IFindAllReferencesWindow.SetProgress - Throw New NotImplementedException() End Sub Public Sub SetProgress(completed As Integer, maximum As Integer) Implements IFindAllReferencesWindow.SetProgress - Throw New NotImplementedException() End Sub -#End Region End Class Private Class TableDataSink From 5045f9461a025e0d23212dbb25b82a1ff7f3f39c Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 11 Sep 2020 15:25:22 -0700 Subject: [PATCH 6/7] Wait for reference highlighting before navigating --- .../IntegrationTests/CSharp/CSharpReferenceHighlighting.cs | 3 +-- .../VisualBasic/BasicKeywordHighlighting.cs | 2 +- .../TestUtilities/OutOfProcess/Editor_OutOfProc.cs | 6 ++++++ .../IntegrationTest/TestUtilities/WellKnownCommandNames.cs | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs b/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs index 499701cd16e1d..f9bc29eb0da7d 100644 --- a/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs +++ b/src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs @@ -79,8 +79,7 @@ void M() }"; VisualStudio.Editor.SetText(text); VisualStudio.Editor.PlaceCaret("x"); - VisualStudio.Workspace.WaitForAsyncOperations(Helper.HangMitigatingTimeout, FeatureAttribute.ReferenceHighlighting); - VisualStudio.ExecuteCommand("Edit.NextHighlightedReference"); + VisualStudio.Editor.InvokeNavigateToNextHighlightedReference(); VisualStudio.Workspace.WaitForAsyncOperations(Helper.HangMitigatingTimeout, FeatureAttribute.ReferenceHighlighting); VisualStudio.Editor.Verify.CurrentLineText("x$$ = 3;", assertCaretPosition: true, trimWhitespace: true); } diff --git a/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicKeywordHighlighting.cs b/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicKeywordHighlighting.cs index 815a22f4901dd..bb45c7f474ac5 100644 --- a/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicKeywordHighlighting.cs +++ b/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicKeywordHighlighting.cs @@ -35,7 +35,7 @@ End Sub End Class"); Verify("To", 3); - VisualStudio.ExecuteCommand("Edit.NextHighlightedReference"); + VisualStudio.Editor.InvokeNavigateToNextHighlightedReference(); VisualStudio.Editor.Verify.CurrentLineText("For a = 0 To 1 Step$$ 1", assertCaretPosition: true, trimWhitespace: true); } diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/Editor_OutOfProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/Editor_OutOfProc.cs index ac3625a0817dc..a137ef6b931f1 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/Editor_OutOfProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/Editor_OutOfProc.cs @@ -86,6 +86,12 @@ public ImmutableArray GetTagSpans(string tagId) return builder.ToImmutableAndFree(); } + public void InvokeNavigateToNextHighlightedReference() + { + _instance.Workspace.WaitForAsyncOperations(Helper.HangMitigatingTimeout, FeatureAttribute.ReferenceHighlighting); + _instance.ExecuteCommand(WellKnownCommandNames.Edit_NextHighlightedReference); + } + public string GetCurrentCompletionItem() { WaitForCompletionSet(); diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/WellKnownCommandNames.cs b/src/VisualStudio/IntegrationTest/TestUtilities/WellKnownCommandNames.cs index f0ba1bc671f12..5375afe0d60f1 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/WellKnownCommandNames.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/WellKnownCommandNames.cs @@ -23,6 +23,7 @@ public static class WellKnownCommandNames public const string Edit_LineEnd = "Edit.LineEnd"; public const string Edit_LineStartExtend = "Edit.LineStartExtend"; public const string Edit_LineEndExtend = "Edit.LineEndExtend"; + public const string Edit_NextHighlightedReference = "Edit.NextHighlightedReference"; public const string Edit_SelectAll = "Edit.SelectAll"; public const string Edit_Copy = "Edit.Copy"; public const string Edit_Cut = "Edit.Cut"; From c560a93428501fa9b40f6d4f25a0fdcc0ca6896a Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 19 Sep 2020 14:17:19 -0700 Subject: [PATCH 7/7] Fix incorrect assertion in 'TestBuildProgressUpdated' --- .../Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/VisualStudio/Core/Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb b/src/VisualStudio/Core/Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb index 81aa089d9a347..476b0a5248a15 100644 --- a/src/VisualStudio/Core/Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb +++ b/src/VisualStudio/Core/Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb @@ -327,9 +327,11 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics source.AddNewErrors(projectId1, GetDiagnosticData(projectId1)) Await waiter.ExpeditedWaitAsync() + Dim numberOfUpdateCalls = 0 AddHandler source.BuildProgressChanged, Sub(o, progress) If progress = ExternalErrorDiagnosticUpdateSource.BuildProgress.Updated Then - Assert.Equal(1, source.GetBuildErrors().Length) + numberOfUpdateCalls += 1 + Assert.Equal(numberOfUpdateCalls, source.GetBuildErrors().Length) ElseIf progress = ExternalErrorDiagnosticUpdateSource.BuildProgress.Done Then Assert.Equal(2, source.GetBuildErrors().Length) End If