From 146a0028e47ec963741728cf689a9e33bc0a2e85 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 8 Jul 2021 10:10:27 -0700 Subject: [PATCH] Switch progression search over to navto search by default. --- .../Progression/GraphQueries/SearchGraphQuery.cs | 6 +++++- .../Implementation/Progression/ProgressionOptions.cs | 2 +- .../Core/Test/Progression/SearchGraphQueryTests.vb | 11 +++++++++++ .../Portable/Experiments/IExperimentationService.cs | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/Progression/GraphQueries/SearchGraphQuery.cs b/src/VisualStudio/Core/Def/Implementation/Progression/GraphQueries/SearchGraphQuery.cs index 2a525df7db468..448311407c50b 100644 --- a/src/VisualStudio/Core/Def/Implementation/Progression/GraphQueries/SearchGraphQuery.cs +++ b/src/VisualStudio/Core/Def/Implementation/Progression/GraphQueries/SearchGraphQuery.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; +using Microsoft.CodeAnalysis.Experiments; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.NavigateTo; using Microsoft.CodeAnalysis.PooledObjects; @@ -38,8 +39,11 @@ public SearchGraphQuery( public Task GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken) { + var experimentationService = solution.Workspace.Services.GetService(); + var forceLegacySearch = experimentationService?.IsExperimentEnabled(WellKnownExperimentNames.ProgressionForceLegacySearch) == true; + var option = solution.Options.GetOption(ProgressionOptions.SearchUsingNavigateToEngine); - return option + return !forceLegacySearch && option ? SearchUsingNavigateToEngineAsync(solution, context, cancellationToken) : SearchUsingSymbolsAsync(solution, context, cancellationToken); } diff --git a/src/VisualStudio/Core/Def/Implementation/Progression/ProgressionOptions.cs b/src/VisualStudio/Core/Def/Implementation/Progression/ProgressionOptions.cs index 94a3c73b535cf..4e9eeb23cbae7 100644 --- a/src/VisualStudio/Core/Def/Implementation/Progression/ProgressionOptions.cs +++ b/src/VisualStudio/Core/Def/Implementation/Progression/ProgressionOptions.cs @@ -13,7 +13,7 @@ internal static class ProgressionOptions private const string LocalRegistryPath = @"Roslyn\Internal\OnOff\Components\Progression\"; public static readonly Option2 SearchUsingNavigateToEngine = new( - nameof(ProgressionOptions), nameof(SearchUsingNavigateToEngine), defaultValue: false, + nameof(ProgressionOptions), nameof(SearchUsingNavigateToEngine), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "SearchUsingNavigateToEngine")); } } diff --git a/src/VisualStudio/Core/Test/Progression/SearchGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/SearchGraphQueryTests.vb index ff84d6ee40eb9..4641ed11ca716 100644 --- a/src/VisualStudio/Core/Test/Progression/SearchGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/SearchGraphQueryTests.vb @@ -25,6 +25,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="C", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -59,6 +60,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="F", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -95,6 +97,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="M", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -144,6 +147,7 @@ End Namespace ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="C", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -194,6 +198,7 @@ End Namespace ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="Goo", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -243,6 +248,7 @@ End Namespace ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="Z", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -284,6 +290,7 @@ End Namespace ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="D.B", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -320,6 +327,7 @@ End Namespace ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="C.B", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -344,6 +352,7 @@ End Namespace ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="D.B", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -380,6 +389,7 @@ End Namespace ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="A.D.B", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) @@ -416,6 +426,7 @@ End Namespace ) + testState.Workspace.SetOptions(testState.Workspace.Options.WithChangedOption(ProgressionOptions.SearchUsingNavigateToEngine, False)) Dim threadingContext = testState.Workspace.ExportProvider.GetExportedValue(Of IThreadingContext) Dim outputContext = Await testState.GetGraphContextAfterQuery( New Graph(), New SearchGraphQuery(searchPattern:="A.D.B", threadingContext, AsynchronousOperationListenerProvider.NullListener), GraphContextDirection.Custom) diff --git a/src/Workspaces/Core/Portable/Experiments/IExperimentationService.cs b/src/Workspaces/Core/Portable/Experiments/IExperimentationService.cs index f120570649767..483f023be23b0 100644 --- a/src/Workspaces/Core/Portable/Experiments/IExperimentationService.cs +++ b/src/Workspaces/Core/Portable/Experiments/IExperimentationService.cs @@ -43,5 +43,6 @@ internal static class WellKnownExperimentNames public const string RazorLspEditorFeatureFlag = "Razor.LSP.Editor"; public const string InheritanceMargin = "Roslyn.InheritanceMargin"; public const string LspPullDiagnosticsFeatureFlag = "Lsp.PullDiagnostics"; + public const string ProgressionForceLegacySearch = "Roslyn.ProgressionForceLegacySearch"; } }