Skip to content

Commit

Permalink
Remove import completion experiment and enable it by default
Browse files Browse the repository at this point in the history
  • Loading branch information
genlu committed Oct 9, 2020
1 parent 127a1de commit bbd312b
Show file tree
Hide file tree
Showing 38 changed files with 66 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ protected override OptionSet WithChangedOptions(OptionSet options)
.WithChangedOption(CompletionOptions.HideAdvancedMembers, LanguageNames.CSharp, HideAdvancedMembers);
}

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.CSharp.Completion.Providers;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
Expand Down Expand Up @@ -42,48 +42,11 @@ 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);

ShowImportCompletionItemsOptionValue = null;

var markup = @"
class Bar
{
$$
}";

await VerifyAnyItemExistsAsync(markup);
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task OptionSetToNull_ExpDisabled()
{
ShowImportCompletionItemsOptionValue = null;
IsExpandedCompletion = false;
var markup = @"
class Bar
{
$$
}";

await VerifyNoItemsExistAsync(markup);
}

[InlineData(true)]
[InlineData(false)]
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task OptionSetToFalse(bool isExperimentEnabled)
public async Task OptionSetToFalse()
{
SetExperimentOption(WellKnownExperimentNames.TypeImportCompletion, isExperimentEnabled);

ShowImportCompletionItemsOptionValue = false;
IsExpandedCompletion = false;

Expand All @@ -96,13 +59,9 @@ class Bar
await VerifyNoItemsExistAsync(markup);
}

[InlineData(true)]
[InlineData(false)]
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task OptionSetToTrue(bool isExperimentEnabled)
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task OptionSetToTrue()
{
SetExperimentOption(WellKnownExperimentNames.TypeImportCompletion, isExperimentEnabled);

ShowImportCompletionItemsOptionValue = true;

var markup = @"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ static void CheckForExperimentStatus(ITextView textView, Document document)
var experimentationService = workspace.Services.GetService<IExperimentationService>();
textView.Properties[TargetTypeFilterExperimentEnabled] = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.TargetTypedCompletionFilter);

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

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

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

Dim workspace = state.Workspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet

Private Property ShowImportCompletionItemsOptionValue As Boolean = True

' -1 would disable timebox, whereas 0 means always timeout.
Private Property TimeoutInMilliseconds As Integer = -1

Protected Overrides Function WithChangedOptions(options As OptionSet) As OptionSet
Return options _
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.VisualBasic, ShowImportCompletionItemsOptionValue).WithChangedOption(CompletionServiceOptions.IsExpandedCompletion, IsExpandedCompletion)
End Function

Protected Overrides Function GetComposition() As TestComposition
Return MyBase.GetComposition().AddParts(GetType(TestExperimentationService))
End Function

Friend Overrides Function GetCompletionProviderType() As Type
Return GetType(ExtensionMethodImportCompletionProvider)
End Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet
.WithChangedOption(CompletionServiceOptions.IsExpandedCompletion, IsExpandedCompletion)
End Function

Protected Overrides Function GetComposition() As TestComposition
Return MyBase.GetComposition().AddParts(GetType(TestExperimentationService))
End Function

Friend Overrides Function GetCompletionProviderType() As Type
Return GetType(TypeImportCompletionProvider)
End Function
Expand Down
3 changes: 1 addition & 2 deletions src/Features/Core/Portable/Completion/CompletionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ internal static class CompletionOptions

//Dev16 options

// Use tri-value so the default state can be used to turn on the feature with experimentation service.
public static readonly PerLanguageOption2<bool?> ShowItemsFromUnimportedNamespaces =
new(nameof(CompletionOptions), nameof(ShowItemsFromUnimportedNamespaces), defaultValue: null,
new(nameof(CompletionOptions), nameof(ShowItemsFromUnimportedNamespaces), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.ShowItemsFromUnimportedNamespaces"));

// Use tri-value so the default state can be used to turn on the feature with experimentation service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.AddImports;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.PooledObjects;
Expand All @@ -32,19 +31,6 @@ internal abstract class AbstractImportCompletionProvider : LSPCompletionProvider

internal override bool IsExpandItemProvider => true;

private bool? _isImportCompletionExperimentEnabled = null;

private bool IsExperimentEnabled(Workspace workspace)
{
if (!_isImportCompletionExperimentEnabled.HasValue)
{
var experimentationService = workspace.Services.GetRequiredService<IExperimentationService>();
_isImportCompletionExperimentEnabled = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.TypeImportCompletion);
}

return _isImportCompletionExperimentEnabled == true;
}

public override async Task ProvideCompletionsAsync(CompletionContext completionContext)
{
var cancellationToken = completionContext.CancellationToken;
Expand All @@ -64,11 +50,8 @@ public override async Task ProvideCompletionsAsync(CompletionContext completionC
var isExpandedCompletion = completionContext.Options.GetOption(CompletionServiceOptions.IsExpandedCompletion);
if (!isExpandedCompletion)
{
var importCompletionOptionValue = completionContext.Options.GetOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, document.Project.Language);

// Don't trigger import completion if the option value is "default" and the experiment is disabled for the user.
if (importCompletionOptionValue == false ||
(importCompletionOptionValue == null && !IsExperimentEnabled(document.Project.Solution.Workspace)))
var isImportCompletionEnabled = completionContext.Options.GetOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, document.Project.Language);
if (isImportCompletionEnabled == false)
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/VisualStudio/CSharp/Impl/CSharpVSResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@
<value>When on multiple lines</value>
</data>
<data name="Show_items_from_unimported_namespaces" xml:space="preserve">
<value>Show items from unimported namespaces (experimental)</value>
<value>Show items from unimported namespaces</value>
</data>
<data name="Inside_namespace" xml:space="preserve">
<value>Inside namespace</value>
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Zobrazit položky z neimportovaných oborů názvů (experimentální)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Zobrazit položky z neimportovaných oborů názvů (experimentální)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Elemente aus nicht importierten Namespaces anzeigen (experimentell)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Elemente aus nicht importierten Namespaces anzeigen (experimentell)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Mostrar elementos de espacios de nombres no importados (experimental)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Mostrar elementos de espacios de nombres no importados (experimental)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Afficher les éléments des espaces de noms qui ne sont pas importés (expérimental)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Afficher les éléments des espaces de noms qui ne sont pas importés (expérimental)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Mostra elementi da spazi dei nomi non importati (sperimentale)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Mostra elementi da spazi dei nomi non importati (sperimentale)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">インポートされていない名前空間の項目を表示する (試験段階)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">インポートされていない名前空間の項目を表示する (試験段階)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">가져오지 않은 네임스페이스의 항목 표시(실험적)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">가져오지 않은 네임스페이스의 항목 표시(실험적)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Pokaż elementy z nieimportowanych przestrzeni nazw (eksperymentalne)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Pokaż elementy z nieimportowanych przestrzeni nazw (eksperymentalne)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Mostrar itens de namespaces não importados (experimental)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Mostrar itens de namespaces não importados (experimental)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Показать элементы из неимпортированных пространств имен (экспериментальная функция)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Показать элементы из неимпортированных пространств имен (экспериментальная функция)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">İçeri aktarılmayan ad alanlarındaki öğeleri göster (deneysel)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">İçeri aktarılmayan ad alanlarındaki öğeleri göster (deneysel)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">显示 unimported 命名空间中的项(实验)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">显示 unimported 命名空间中的项(实验)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">顯示來自未匯入命名空間的項目 (實驗性)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">顯示來自未匯入命名空間的項目 (實驗性)</target>
<note />
</trans-unit>
<trans-unit id="Show_remarks_in_Quick_Info">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ End Class]]></document>

Dim testSnippetInfoService = DirectCast(state.Workspace.Services.GetLanguageServices(LanguageNames.VisualBasic).GetService(Of ISnippetInfoService)(), TestVisualBasicSnippetInfoService)
testSnippetInfoService.SetSnippetShortcuts(snippetShortcuts)

Dim newOptions = state.Workspace.Options.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.VisualBasic, False)
state.Workspace.SetOptions(newOptions)

Return state
End Function
End Class
Expand Down
2 changes: 1 addition & 1 deletion src/VisualStudio/VisualBasic/Impl/BasicVSResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
<value>Unused local</value>
</data>
<data name="Show_items_from_unimported_namespaces" xml:space="preserve">
<value>Show items from unimported namespaces (experimental)</value>
<value>Show items from unimported namespaces</value>
</data>
<data name="Show_remarks_in_Quick_Info" xml:space="preserve">
<value>Show remarks in Quick Info</value>
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/VisualBasic/Impl/xlf/BasicVSResources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Zobrazit položky z neimportovaných oborů názvů (experimentální)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Zobrazit položky z neimportovaných oborů názvů (experimentální)</target>
<note />
</trans-unit>
<trans-unit id="Show_procedure_line_separators">
Expand Down
4 changes: 2 additions & 2 deletions src/VisualStudio/VisualBasic/Impl/xlf/BasicVSResources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<note />
</trans-unit>
<trans-unit id="Show_items_from_unimported_namespaces">
<source>Show items from unimported namespaces (experimental)</source>
<target state="translated">Elemente aus nicht importierten Namespaces anzeigen (experimentell)</target>
<source>Show items from unimported namespaces</source>
<target state="needs-review-translation">Elemente aus nicht importierten Namespaces anzeigen (experimentell)</target>
<note />
</trans-unit>
<trans-unit id="Show_procedure_line_separators">
Expand Down
Loading

0 comments on commit bbd312b

Please sign in to comment.