Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Completion.Providers;
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.AsyncCompletion;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data;
Expand Down Expand Up @@ -43,9 +42,6 @@ protected override OptionSet WithChangedOptions(OptionSet options)
.WithChangedOption(CompletionServiceOptions.TimeoutInMillisecondsForExtensionMethodImportCompletion, TimeoutInMilliseconds);
}

protected override TestComposition GetComposition()
=> base.GetComposition().AddParts(typeof(TestExperimentationService));

internal override Type GetCompletionProviderType()
=> typeof(ExtensionMethodImportCompletionProvider);

Expand Down Expand Up @@ -2016,7 +2012,7 @@ public void M(int x)
}}
}}";

SetExperimentOption(WellKnownExperimentNames.TargetTypedCompletionFilter, true);
TargetTypedCompletionFilterFeatureFlag = true;
var markup = CreateMarkupForProjectWithProjectReference(srcDoc, refDoc, LanguageNames.CSharp, LanguageNames.CSharp);

string expectedDescription = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.CSharp.Completion.Providers;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders;
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.AsyncCompletion;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data;
using Roslyn.Test.Utilities;
Expand All @@ -27,9 +26,6 @@ public partial class SymbolCompletionProviderTests : AbstractCSharpCompletionPro
internal override Type GetCompletionProviderType()
=> typeof(SymbolCompletionProvider);

protected override TestComposition GetComposition()
=> base.GetComposition().AddParts(typeof(TestExperimentationService));

[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
[InlineData(SourceCodeKind.Regular)]
[InlineData(SourceCodeKind.Script)]
Expand Down Expand Up @@ -10785,7 +10781,7 @@ class AnotherBuilder
[Fact, Trait(Traits.Feature, Traits.Features.TargetTypedCompletion)]
public async Task TestTargetTypeFilterWithExperimentEnabled()
{
SetExperimentOption(WellKnownExperimentNames.TargetTypedCompletionFilter, true);
TargetTypedCompletionFilterFeatureFlag = true;

var markup =
@"public class C
Expand All @@ -10804,7 +10800,7 @@ await VerifyItemExistsAsync(
[Fact, Trait(Traits.Feature, Traits.Features.TargetTypedCompletion)]
public async Task TestNoTargetTypeFilterWithExperimentDisabled()
{
SetExperimentOption(WellKnownExperimentNames.TargetTypedCompletionFilter, false);
TargetTypedCompletionFilterFeatureFlag = false;

var markup =
@"public class C
Expand All @@ -10823,7 +10819,7 @@ await VerifyItemExistsAsync(
[Fact, Trait(Traits.Feature, Traits.Features.TargetTypedCompletion)]
public async Task TestTargetTypeFilter_NotOnObjectMembers()
{
SetExperimentOption(WellKnownExperimentNames.TargetTypedCompletionFilter, true);
TargetTypedCompletionFilterFeatureFlag = true;

var markup =
@"public class C
Expand All @@ -10841,7 +10837,7 @@ await VerifyItemExistsAsync(
[Fact, Trait(Traits.Feature, Traits.Features.TargetTypedCompletion)]
public async Task TestTargetTypeFilter_NotNamedTypes()
{
SetExperimentOption(WellKnownExperimentNames.TargetTypedCompletionFilter, true);
TargetTypedCompletionFilterFeatureFlag = true;

var markup =
@"public class C
Expand Down Expand Up @@ -11384,7 +11380,7 @@ public void Test()
public async Task TestTargetTypeCompletionDescription(string targetType, string expectedParameterList)
{
// Check the description displayed is based on symbol matches targeted type
SetExperimentOption(WellKnownExperimentNames.TargetTypedCompletionFilter, true);
TargetTypedCompletionFilterFeatureFlag = true;

var markup =
$@"public class C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.CSharp.Completion.Providers;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
Expand Down Expand Up @@ -39,15 +38,12 @@ protected override OptionSet WithChangedOptions(OptionSet options)
.WithChangedOption(CompletionOptions.HideAdvancedMembers, LanguageNames.CSharp, HideAdvancedMembers);
}

protected override TestComposition GetComposition()
=> base.GetComposition().AddParts(typeof(TestExperimentationService));

#region "Option tests"

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task OptionSetToNull_ExpEnabled()
{
SetExperimentOption(WellKnownExperimentNames.TypeImportCompletion, true);
TypeImportCompletionFeatureFlag = true;

ShowImportCompletionItemsOptionValue = null;

Expand Down Expand Up @@ -79,8 +75,7 @@ class Bar
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task OptionSetToFalse(bool isExperimentEnabled)
{
SetExperimentOption(WellKnownExperimentNames.TypeImportCompletion, isExperimentEnabled);

TypeImportCompletionFeatureFlag = isExperimentEnabled;
ShowImportCompletionItemsOptionValue = false;
IsExpandedCompletion = false;

Expand All @@ -98,8 +93,7 @@ class Bar
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task OptionSetToTrue(bool isExperimentEnabled)
{
SetExperimentOption(WellKnownExperimentNames.TypeImportCompletion, isExperimentEnabled);

TypeImportCompletionFeatureFlag = isExperimentEnabled;
ShowImportCompletionItemsOptionValue = true;

var markup = @"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.Tags;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.TestHooks;
Expand Down Expand Up @@ -89,14 +88,8 @@ public SuggestedActionsSourceProvider(
if (textBuffer.IsInLspEditorContext())
return null;

var asyncEnabled = _optionService.GetOption(SuggestionsOptions.Asynchronous);
if (asyncEnabled == null)
{
asyncEnabled =
Workspace.TryGetWorkspace(textBuffer.AsTextContainer(), out var workspace) &&
workspace.Services.GetService<IExperimentationService>() is { } experimentationService &&
experimentationService.IsExperimentEnabled(WellKnownExperimentNames.AsynchronousQuickActions);
}
var asyncEnabled = _optionService.GetOption(SuggestionsOptions.Asynchronous) ??
_optionService.GetOption(SuggestionsOptions.AsynchronousFeatureFlag);

return asyncEnabled == true
? new AsyncSuggestedActionsSource(_threadingContext, this, textView, textBuffer, _suggestedActionCategoryRegistry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Options;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
Expand Down Expand Up @@ -138,13 +137,12 @@ public AsyncCompletionData.CompletionStartData InitializeCompletion(
// For telemetry reporting purpose
static void CheckForExperimentStatus(ITextView textView, Document document)
{
var workspace = document.Project.Solution.Workspace;
var options = document.Project.Solution.Options;

var experimentationService = workspace.Services.GetRequiredService<IExperimentationService>();
textView.Properties[TargetTypeFilterExperimentEnabled] = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.TargetTypedCompletionFilter);
textView.Properties[TargetTypeFilterExperimentEnabled] = options.GetOption(CompletionOptions.TargetTypedCompletionFilterFeatureFlag);

var importCompletionOptionValue = workspace.Options.GetOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, document.Project.Language);
var importCompletionExperimentValue = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.TypeImportCompletion);
var importCompletionOptionValue = options.GetOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, document.Project.Language);
var importCompletionExperimentValue = options.GetOption(CompletionOptions.TypeImportCompletionFeatureFlag);
var isTypeImportEnababled = importCompletionOptionValue == true || (importCompletionOptionValue == null && importCompletionExperimentValue);
textView.Properties[TypeImportCompletionEnabled] = isTypeImportEnababled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

namespace Microsoft.CodeAnalysis.Editor.Implementation.Suggestions
{
internal class SuggestionsOptions
internal static class SuggestionsOptions
{
public static Option2<bool?> Asynchronous =
new(nameof(SuggestionsOptions), nameof(Asynchronous), defaultValue: null,
storageLocation: new RoamingProfileStorageLocation("TextEditor.Specific.Suggestions.Asynchronous2"));
private const string FeatureName = "SuggestionsOptions";

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

public static readonly Option2<bool> AsynchronousFeatureFlag = new(FeatureName, nameof(AsynchronousFeatureFlag), defaultValue: false,
new FeatureFlagStorageLocation("Roslyn.AsynchronousQuickActions"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Microsoft.CodeAnalysis.Editor.Implementation.Suggestions
{
[ExportOptionProvider, Shared]
internal class SuggestionsOptionsProvider : IOptionProvider
internal sealed class SuggestionsOptionsProvider : IOptionProvider
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
Expand All @@ -21,6 +21,7 @@ public SuggestionsOptionsProvider()
}

public ImmutableArray<IOption> Options { get; } = ImmutableArray.Create<IOption>(
SuggestionsOptions.Asynchronous);
SuggestionsOptions.Asynchronous,
SuggestionsOptions.AsynchronousFeatureFlag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ internal static class FeatureOnOffOptions
nameof(FeatureOnOffOptions), nameof(OfferRemoveUnusedReferences), defaultValue: true,
storageLocation: new RoamingProfileStorageLocation($"TextEditor.{nameof(OfferRemoveUnusedReferences)}"));

public static readonly Option<bool> OfferRemoveUnusedReferencesFeatureFlag = new(
nameof(FeatureOnOffOptions), nameof(OfferRemoveUnusedReferencesFeatureFlag), defaultValue: false,
new FeatureFlagStorageLocation("Roslyn.RemoveUnusedReferences"));

public static readonly PerLanguageOption2<bool?> ShowInheritanceMargin =
new(nameof(FeatureOnOffOptions),
nameof(ShowInheritanceMargin),
Expand Down Expand Up @@ -119,6 +123,7 @@ public FeatureOnOffOptionsProvider()
FeatureOnOffOptions.UseEnhancedColors,
FeatureOnOffOptions.AddImportsOnPaste,
FeatureOnOffOptions.OfferRemoveUnusedReferences,
FeatureOnOffOptions.OfferRemoveUnusedReferencesFeatureFlag,
FeatureOnOffOptions.ShowInheritanceMargin,
FeatureOnOffOptions.AutomaticallyCompleteStatementOnSemicolon,
FeatureOnOffOptions.SkipAnalyzersForImplicitlyTriggeredBuilds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6689,7 +6689,7 @@ namespace NS2

Dim workspace = state.Workspace
workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(workspace.Options _
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForImportCompletion, False) _
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForCompletion, False) _
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, True)))

state.SendInvokeCompletionList()
Expand Down Expand Up @@ -6745,7 +6745,7 @@ namespace NS2

Dim workspace = state.Workspace
workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(workspace.Options _
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForImportCompletion, False) _
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForCompletion, False) _
.WithChangedOption(CompletionServiceOptions.TimeoutInMillisecondsForExtensionMethodImportCompletion, -1) _
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, True)))

Expand Down Expand Up @@ -7679,7 +7679,6 @@ namespace OtherNS
public class DES { }
}
</Document>,
extraExportedTypes:={GetType(TestExperimentationService)}.ToList(),
showCompletionInArgumentLists:=showCompletionInArgumentLists)

Dim workspace = state.Workspace
Expand Down Expand Up @@ -7729,7 +7728,6 @@ namespace NS

class ATaAaSaKa { }
} </Document>,
extraExportedTypes:={GetType(TestExperimentationService)}.ToList(),
showCompletionInArgumentLists:=showCompletionInArgumentLists)

Dim workspace = state.Workspace
Expand Down Expand Up @@ -7784,7 +7782,6 @@ namespace NS2
class MyTask3 { }
}
</Document>,
extraExportedTypes:={GetType(TestExperimentationService)}.ToList(),
showCompletionInArgumentLists:=showCompletionInArgumentLists)

Dim workspace = state.Workspace
Expand Down
3 changes: 1 addition & 2 deletions src/EditorFeatures/Test2/Rename/RenameTestHelpers.vb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename

Private ReadOnly s_composition As TestComposition = EditorTestCompositions.EditorFeaturesWpf.AddParts(
GetType(MockDocumentNavigationServiceFactory),
GetType(MockPreviewDialogService),
GetType(TestExperimentationService))
GetType(MockPreviewDialogService))

Private Function GetSessionInfo(workspace As TestWorkspace) As (document As Document, textSpan As TextSpan)
Dim hostdoc = workspace.DocumentWithCursor
Expand Down
Loading