Skip to content

Commit

Permalink
Merge pull request #57808 from CyrusNajmabadi/addBackAsyncLightbulbOp…
Browse files Browse the repository at this point in the history
…tino

Add back option to allow users to disable async lightbulbs
  • Loading branch information
CyrusNajmabadi authored Nov 22, 2021
2 parents c089e53 + b62ffd1 commit 879cbef
Show file tree
Hide file tree
Showing 23 changed files with 214 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ public SuggestedActionsSourceProvider(
if (textBuffer.IsInLspEditorContext())
return null;

return _globalOptions.GetOption(SuggestionsOptions.AsynchronousQuickActionsDisableFeatureFlag)
? new SyncSuggestedActionsSource(_threadingContext, _globalOptions, this, textView, textBuffer, _suggestedActionCategoryRegistry)
: new AsyncSuggestedActionsSource(_threadingContext, _globalOptions, this, textView, textBuffer, _suggestedActionCategoryRegistry);
// if user has explicitly set the option defer to that. otherwise, we are enabled by default (unless our
// A/B escape hatch disables us).
var asyncEnabled = _globalOptions.GetOption(SuggestionsOptions.Asynchronous) is bool b ? b : !_globalOptions.GetOption(SuggestionsOptions.AsynchronousQuickActionsDisableFeatureFlag);

return asyncEnabled
? new AsyncSuggestedActionsSource(_threadingContext, _globalOptions, this, textView, textBuffer, _suggestedActionCategoryRegistry)
: new SyncSuggestedActionsSource(_threadingContext, _globalOptions, this, textView, textBuffer, _suggestedActionCategoryRegistry);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public SuggestionsOptions()

private const string FeatureName = "SuggestionsOptions";

public static readonly Option2<bool?> Asynchronous = new(FeatureName, nameof(Asynchronous), defaultValue: null,
new RoamingProfileStorageLocation("TextEditor.Specific.Suggestions.Asynchronous4"));

public static readonly Option2<bool> AsynchronousQuickActionsDisableFeatureFlag = new(FeatureName, nameof(AsynchronousQuickActionsDisableFeatureFlag), defaultValue: false,
new FeatureFlagStorageLocation("Roslyn.AsynchronousQuickActionsDisable"));
new FeatureFlagStorageLocation("Roslyn.AsynchronousQuickActionsDisable2"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Immutable;
using System.Composition;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Options.Providers;

namespace Microsoft.CodeAnalysis.Editor.Implementation.Suggestions
{
[ExportGlobalOptionProvider, Shared]
internal sealed class SuggestionsOptionsProvider : IOptionProvider
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public SuggestionsOptionsProvider()
{
}

public ImmutableArray<IOption> Options { get; } = ImmutableArray.Create<IOption>(
SuggestionsOptions.Asynchronous,
SuggestionsOptions.AsynchronousQuickActionsDisableFeatureFlag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
Content="{x:Static local:AdvancedOptionPageStrings.Option_Add_missing_using_directives_on_paste}" />
</StackPanel>
</GroupBox>
<GroupBox x:Uid="QuickActionsBox"
Header="{x:Static local:AdvancedOptionPageStrings.Option_Quick_Actions}">
<StackPanel>
<CheckBox x:Name="ComputeQuickActionsAsynchronouslyExperimental"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Compute_Quick_Actions_asynchronously_experimental}" />
</StackPanel>
</GroupBox>
<GroupBox x:Uid="HighlightingGroupBox"
Header="{x:Static local:AdvancedOptionPageStrings.Option_Highlighting}">
<StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ public AdvancedOptionPageControl(OptionStore optionStore, IComponentModel compon
BindToOption(ShowRemarksInQuickInfo, QuickInfoOptions.Metadata.ShowRemarksInQuickInfo, LanguageNames.CSharp);
BindToOption(DisplayLineSeparators, FeatureOnOffOptions.LineSeparator, LanguageNames.CSharp);

// Quick Actions
BindToOption(ComputeQuickActionsAsynchronouslyExperimental, SuggestionsOptions.Asynchronous, () =>
{
// If the option has not been set by the user, check if the option is disabled from experimentation.
return !optionStore.GetOption(SuggestionsOptions.AsynchronousQuickActionsDisableFeatureFlag);
});

// Highlighting
BindToOption(EnableHighlightReferences, FeatureOnOffOptions.ReferenceHighlighting, LanguageNames.CSharp);
BindToOption(EnableHighlightKeywords, FeatureOnOffOptions.KeywordHighlighting, LanguageNames.CSharp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ public static string Option_OptimizeForSolutionSize_Regular
public static string Option_OptimizeForSolutionSize_Small
=> CSharpVSResources.Small;

public static string Option_Quick_Actions
=> ServicesVSResources.Quick_Actions;

public static string Option_Compute_Quick_Actions_asynchronously_experimental
=> ServicesVSResources.Compute_Quick_Actions_asynchronously_experimental;

public static string Option_Outlining
=> ServicesVSResources.Outlining;

Expand Down
6 changes: 6 additions & 0 deletions src/VisualStudio/Core/Def/ServicesVSResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,12 @@ Additional information: {1}</value>
<data name="Run_code_analysis_in_separate_process_requires_restart" xml:space="preserve">
<value>Run code analysis in separate process (requires restart)</value>
</data>
<data name="Compute_Quick_Actions_asynchronously_experimental" xml:space="preserve">
<value>Compute Quick Actions asynchronously (experimental, requires restart)</value>
</data>
<data name="Quick_Actions" xml:space="preserve">
<value>Quick Actions</value>
</data>
<data name="Combine_inheritance_margin_with_indicator_margin" xml:space="preserve">
<value>Combine inheritance margin with indicator margin</value>
</data>
Expand Down
10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 879cbef

Please sign in to comment.