Skip to content

Commit

Permalink
Merge pull request #54686 from CyrusNajmabadi/progressionOption
Browse files Browse the repository at this point in the history
Switch progression search over to navto search by default.
  • Loading branch information
CyrusNajmabadi authored Jul 12, 2021
2 parents 0f4736a + 146a002 commit ce3a20e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -38,8 +39,11 @@ public SearchGraphQuery(

public Task<GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
{
var experimentationService = solution.Workspace.Services.GetService<IExperimentationService>();
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static class ProgressionOptions
private const string LocalRegistryPath = @"Roslyn\Internal\OnOff\Components\Progression\";

public static readonly Option2<bool> SearchUsingNavigateToEngine = new(
nameof(ProgressionOptions), nameof(SearchUsingNavigateToEngine), defaultValue: false,
nameof(ProgressionOptions), nameof(SearchUsingNavigateToEngine), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "SearchUsingNavigateToEngine"));
}
}
11 changes: 11 additions & 0 deletions src/VisualStudio/Core/Test/Progression/SearchGraphQueryTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression
</Project>
</Workspace>)

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)
Expand Down Expand Up @@ -59,6 +60,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression
</Project>
</Workspace>)

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)
Expand Down Expand Up @@ -95,6 +97,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression
</Project>
</Workspace>)

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)
Expand Down Expand Up @@ -144,6 +147,7 @@ End Namespace
</Project>
</Workspace>)

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)
Expand Down Expand Up @@ -194,6 +198,7 @@ End Namespace
</Project>
</Workspace>)

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)
Expand Down Expand Up @@ -243,6 +248,7 @@ End Namespace
</Project>
</Workspace>)

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)
Expand Down Expand Up @@ -284,6 +290,7 @@ End Namespace
</Project>
</Workspace>)

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)
Expand Down Expand Up @@ -320,6 +327,7 @@ End Namespace
</Project>
</Workspace>)

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)
Expand All @@ -344,6 +352,7 @@ End Namespace
</Project>
</Workspace>)

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)
Expand Down Expand Up @@ -380,6 +389,7 @@ End Namespace
</Project>
</Workspace>)

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)
Expand Down Expand Up @@ -416,6 +426,7 @@ End Namespace
</Project>
</Workspace>)

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

0 comments on commit ce3a20e

Please sign in to comment.