Skip to content

Commit

Permalink
Remove OOP related feature options. (#31644)
Browse files Browse the repository at this point in the history
* Enable OOP features by default.

* Removing unused function.

* conflicts
  • Loading branch information
CyrusNajmabadi authored and heejaechang committed Mar 1, 2019
1 parent ca4bd71 commit 6f5be2e
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ private static int GetSemicolonLocation(SyntaxNode root, SyntaxNode currentNode,
private static bool CaretIsInForStatementCondition(int caretPosition, ForStatementSyntax forStatementSyntax)
// If condition is null and caret is in the condition section, as in `for ( ; $$; )`,
// we will have bailed earlier due to not being inside supported delimiters
=> forStatementSyntax.Condition == null ?
false :
caretPosition > forStatementSyntax.Condition.SpanStart &&
caretPosition < forStatementSyntax.Condition.Span.End;
=> forStatementSyntax.Condition == null
? false
: caretPosition > forStatementSyntax.Condition.SpanStart &&
caretPosition < forStatementSyntax.Condition.Span.End;

private static bool CaretIsInForStatementDeclaration(int caretPosition, ForStatementSyntax forStatementSyntax)
=> forStatementSyntax.Declaration != null &&
Expand Down
3 changes: 1 addition & 2 deletions src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
Workspace workspace, TestParameters parameters)
{
var outOfProcess = (bool)parameters.fixProviderData;
workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess)
.WithChangedOption(RemoteFeatureOptions.AddImportEnabled, outOfProcess);
workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess);

return base.CreateDiagnosticProviderAndFixer(workspace, parameters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public static async Task<ISymbolSearchUpdateEngine> CreateEngineAsync(
ISymbolSearchProgressService progressService,
CancellationToken cancellationToken)
{
var client = await workspace.TryGetRemoteHostClientAsync(
RemoteFeatureOptions.SymbolSearchEnabled, cancellationToken).ConfigureAwait(false);
var client = await workspace.TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
if (client != null)
{
var callbackObject = new CallbackObject(logService, progressService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

Imports System.Collections.Immutable
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Editor.FindUsages
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.FindSymbols
Imports Microsoft.CodeAnalysis.FindUsages
Imports Microsoft.CodeAnalysis.PooledObjects
Imports Microsoft.CodeAnalysis.Remote
Imports Microsoft.CodeAnalysis.Test.Utilities.RemoteHost
Imports Microsoft.CodeAnalysis.Text
Imports Roslyn.Utilities
Expand Down Expand Up @@ -46,8 +44,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
End If

Using workspace = TestWorkspace.Create(element)
workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess).
WithChangedOption(RemoteFeatureOptions.SymbolFinderEnabled, outOfProcess)
workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess)

Assert.True(workspace.Documents.Any(Function(d) d.CursorPosition.HasValue))

Expand Down Expand Up @@ -176,9 +173,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
outOfProcess As Boolean) As Task
options = If(options, FindReferencesSearchOptions.Default)
Using workspace = TestWorkspace.Create(definition)
workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess).
WithChangedOption(RemoteFeatureOptions.SymbolFinderEnabled, outOfProcess)

workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess)
workspace.SetTestLogger(AddressOf _outputHelper.WriteLine)

For Each cursorDocument In workspace.Documents.Where(Function(d) d.CursorPosition.HasValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Imports Microsoft.CodeAnalysis.Editor.Shared.Utilities
Imports Microsoft.CodeAnalysis.Editor.Tagging
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Notification
Imports Microsoft.CodeAnalysis.Remote
Imports Microsoft.CodeAnalysis.Shared.TestHooks
Imports Microsoft.CodeAnalysis.Test.Utilities.RemoteHost
Imports Microsoft.VisualStudio.Text
Expand All @@ -26,9 +25,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting
Private Async Function VerifyHighlightsAsync(test As XElement, optionIsEnabled As Boolean, outOfProcess As Boolean) As Tasks.Task
Using workspace = TestWorkspace.Create(test)
WpfTestRunner.RequireWpfFact($"{NameOf(AbstractReferenceHighlightingTests)}.{NameOf(Me.VerifyHighlightsAsync)} creates asynchronous taggers")

workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess).
WithChangedOption(RemoteFeatureOptions.DocumentHighlightingEnabled, outOfProcess)
workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess)

Dim tagProducer = New ReferenceHighlightingViewTaggerProvider(
workspace.ExportProvider.GetExportedValue(Of IThreadingContext),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ internal async Task TestAsync(
using (var workspace = SetupWorkspace(
content, TestExportProvider.ExportProviderWithCSharpAndVisualBasic, createTrackingService))
{
workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess)
.WithChangedOption(RemoteFeatureOptions.NavigateToEnabled, outOfProcess);

workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess);
await body(workspace);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp

Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace, parameters As TestParameters) As (DiagnosticAnalyzer, CodeFixProvider)
Dim outOfProcess = DirectCast(parameters.fixProviderData, Boolean)
workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess).
WithChangedOption(RemoteFeatureOptions.AddImportEnabled, outOfProcess)
workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, outOfProcess)

Return MyBase.CreateDiagnosticProviderAndFixer(workspace, parameters)
End Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public async Task<ImmutableArray<AddImportFixData>> GetFixesAsync(
{
var callbackTarget = new RemoteSymbolSearchService(symbolSearchService, cancellationToken);
var result = await document.Project.Solution.TryRunCodeAnalysisRemoteAsync<IList<AddImportFixData>>(
RemoteFeatureOptions.AddImportEnabled,
callbackTarget,
nameof(IRemoteAddImportFeatureService.GetFixesAsync),
new object[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public async Task<ImmutableArray<DocumentHighlights>> GetDocumentHighlightsAsync
Document document, int position, IImmutableSet<Document> documentsToSearch, CancellationToken cancellationToken)
{
var result = await document.Project.Solution.TryRunCodeAnalysisRemoteAsync<IList<SerializableDocumentHighlights>>(
RemoteFeatureOptions.DocumentHighlightingEnabled,
nameof(IRemoteDocumentHighlights.GetDocumentHighlightsAsync),
new object[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static async Task<RemoteHostClient> TryGetRemoteHostClientAsync(Project
return null;
}

return await project.Solution.Workspace.TryGetRemoteHostClientAsync(RemoteFeatureOptions.NavigateToEnabled, cancellationToken).ConfigureAwait(false);
return await project.Solution.Workspace.TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ protected override void AddOptions(Panel panel)
// add OOP feature options
var oopFeatureGroup = new StackPanel();

AddOption(oopFeatureGroup, RemoteFeatureOptions.AddImportEnabled, nameof(RemoteFeatureOptions.AddImportEnabled));
AddOption(oopFeatureGroup, RemoteFeatureOptions.DocumentHighlightingEnabled, nameof(RemoteFeatureOptions.DocumentHighlightingEnabled));
AddOption(oopFeatureGroup, RemoteFeatureOptions.NavigateToEnabled, nameof(RemoteFeatureOptions.NavigateToEnabled));
AddOption(oopFeatureGroup, RemoteFeatureOptions.SymbolFinderEnabled, nameof(RemoteFeatureOptions.SymbolFinderEnabled));
AddOption(oopFeatureGroup, RemoteFeatureOptions.SymbolSearchEnabled, nameof(RemoteFeatureOptions.SymbolSearchEnabled));

panel.Children.Add(oopFeatureGroup);

// and add the rest of the options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ await AddMetadataDeclarationsWithNormalQueryAsync(
}

var result = await project.Solution.TryRunCodeAnalysisRemoteAsync<IList<SerializableSymbolAndProjectId>>(
RemoteFeatureOptions.SymbolFinderEnabled,
nameof(IRemoteSymbolFinder.FindAllDeclarationsWithNormalQueryAsync),
new object[] { project.Id, query.Name, query.Kind, criteria }, cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public static async Task<ImmutableArray<SymbolAndProjectId>> FindSourceDeclarati
Solution solution, string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken)
{
var result = await solution.TryRunCodeAnalysisRemoteAsync<IList<SerializableSymbolAndProjectId>>(
RemoteFeatureOptions.SymbolFinderEnabled,
nameof(IRemoteSymbolFinder.FindSolutionSourceDeclarationsWithNormalQueryAsync),
new object[] { name, ignoreCase, criteria }, cancellationToken).ConfigureAwait(false);

Expand All @@ -165,7 +164,6 @@ public static async Task<ImmutableArray<SymbolAndProjectId>> FindSourceDeclarati
}

var result = await project.Solution.TryRunCodeAnalysisRemoteAsync<IList<SerializableSymbolAndProjectId>>(
RemoteFeatureOptions.SymbolFinderEnabled,
nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithNormalQueryAsync),
new object[] { project.Id, name, ignoreCase, criteria }, cancellationToken).ConfigureAwait(false);

Expand All @@ -184,7 +182,6 @@ public static async Task<ImmutableArray<SymbolAndProjectId>> FindSourceDeclarati
Solution solution, string pattern, SymbolFilter criteria, CancellationToken cancellationToken)
{
var result = await solution.TryRunCodeAnalysisRemoteAsync<IList<SerializableSymbolAndProjectId>>(
RemoteFeatureOptions.SymbolFinderEnabled,
nameof(IRemoteSymbolFinder.FindSolutionSourceDeclarationsWithPatternAsync),
new object[] { pattern, criteria }, cancellationToken).ConfigureAwait(false);

Expand All @@ -208,7 +205,6 @@ public static async Task<ImmutableArray<SymbolAndProjectId>> FindSourceDeclarati
}

var result = await project.Solution.TryRunCodeAnalysisRemoteAsync<IList<SerializableSymbolAndProjectId>>(
RemoteFeatureOptions.SymbolFinderEnabled,
nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithPatternAsync),
new object[] { project.Id, pattern, criteria }, cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ private static async Task<bool> TryFindLiteralReferencesInServiceProcessAsync(
var serverCallback = new FindLiteralsServerCallback(solution, progress, cancellationToken);

return await solution.TryRunCodeAnalysisRemoteAsync(
RemoteFeatureOptions.SymbolFinderEnabled,
serverCallback,
nameof(IRemoteSymbolFinder.FindLiteralReferencesAsync),
new object[] { value, typeCode },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ private static async Task<bool> TryFindReferencesInServiceProcessAsync(
var serverCallback = new FindReferencesServerCallback(solution, progress, cancellationToken);

return await solution.TryRunCodeAnalysisRemoteAsync(
RemoteFeatureOptions.SymbolFinderEnabled,
serverCallback,
nameof(IRemoteSymbolFinder.FindReferencesAsync),
new object[]
Expand Down
37 changes: 1 addition & 36 deletions src/Workspaces/Core/Portable/Remote/RemoteFeatureOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,10 @@ internal static class RemoteFeatureOptions
{
private const string LocalRegistryPath = @"Roslyn\Features\Remote\";

// Individual feature switches. Not exposed to the user. Supplied as an escape hatch for
// features if necessary. If all features use OOP then no indices will need to be built
// within VS. However, if any features need to run in VS, then we have to build our indices
// in VS as well.

public static readonly Option<bool> AddImportEnabled = new Option<bool>(
nameof(RemoteFeatureOptions), nameof(AddImportEnabled), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(AddImportEnabled)));

public static readonly Option<bool> DocumentHighlightingEnabled = new Option<bool>(
nameof(RemoteFeatureOptions), nameof(DocumentHighlightingEnabled), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(DocumentHighlightingEnabled)));

public static readonly Option<bool> NavigateToEnabled = new Option<bool>(
nameof(RemoteFeatureOptions), nameof(NavigateToEnabled), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(NavigateToEnabled)));

public static readonly Option<bool> SymbolSearchEnabled = new Option<bool>(
nameof(RemoteFeatureOptions), nameof(SymbolSearchEnabled), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(SymbolSearchEnabled)));

public static readonly Option<bool> SymbolFinderEnabled = new Option<bool>(
nameof(RemoteFeatureOptions), nameof(SymbolFinderEnabled), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(SymbolFinderEnabled)));

public static readonly Option<bool> DiagnosticsEnabled = new Option<bool>(
nameof(RemoteFeatureOptions), nameof(DiagnosticsEnabled), defaultValue: true,
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(DiagnosticsEnabled)));

private static ImmutableArray<Option<bool>> AllFeatureOptions { get; } =
ImmutableArray.Create(AddImportEnabled, DocumentHighlightingEnabled, NavigateToEnabled, SymbolSearchEnabled, SymbolFinderEnabled);

public static bool AnyFeatureRunsInProcess(Workspace workspace)
=> AllFeatureOptions.Any(o => !workspace.IsOutOfProcessEnabled(o));

public static bool ShouldComputeIndex(Workspace workspace)
{
switch (workspace.Kind)
Expand All @@ -56,13 +25,9 @@ public static bool ShouldComputeIndex(Workspace workspace)
case WorkspaceKind.RemoteWorkspace:
// Always compute indices in the remote workspace.
return true;

case WorkspaceKind.Host:

This comment has been minimized.

Copy link
@Therzok

Therzok Apr 1, 2019

Contributor

This breaks VSMac which doesn't have a remote workspace.

// If any features are going to run in-process, then we need to create an index in the
// host workspace.
return AnyFeatureRunsInProcess(workspace);
}

// Otherwise, don't compute the index for any other workspaces.
return false;
}
}
Expand Down
Loading

0 comments on commit 6f5be2e

Please sign in to comment.