From 2ad1fe7e3df9971e7f91d0e00e4b8a74b7f2e3ef Mon Sep 17 00:00:00 2001 From: tmat Date: Fri, 12 Jul 2024 16:43:28 -0700 Subject: [PATCH 1/4] Convert SymbolSearchOptions to unsupported editorconfig options --- ...SharpAddMissingReferenceCodeFixProvider.cs | 11 ---- .../AbstractAddImportCodeFixProvider.cs | 4 +- ...tractAddMissingReferenceCodeFixProvider.cs | 10 --- .../AbstractAddPackageCodeFixProvider.cs | 65 ++++++++----------- ...stractAddSpecificPackageCodeFixProvider.cs | 5 +- .../EditorConfigOptionsEnumerator.cs | 2 + .../SymbolSearch/SymbolSearchOptions.cs | 58 +++++++++++++++++ .../Options/CodeActionOptionsStorage.cs | 5 +- .../Options/SymbolSearchOptionsStorage.cs | 28 -------- .../Def/Options/VisualStudioOptionStorage.cs | 4 +- .../SymbolSearch/SymbolSearchOptions.cs | 21 ------ .../Core/CodeFixes/CodeActionOptions.cs | 3 - 12 files changed, 93 insertions(+), 123 deletions(-) create mode 100644 src/Features/Core/Portable/SymbolSearch/SymbolSearchOptions.cs delete mode 100644 src/LanguageServer/Protocol/Features/Options/SymbolSearchOptionsStorage.cs delete mode 100644 src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptions.cs diff --git a/src/Features/CSharp/Portable/AddMissingReference/CSharpAddMissingReferenceCodeFixProvider.cs b/src/Features/CSharp/Portable/AddMissingReference/CSharpAddMissingReferenceCodeFixProvider.cs index abe2730970a06..7e558684bfa07 100644 --- a/src/Features/CSharp/Portable/AddMissingReference/CSharpAddMissingReferenceCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/AddMissingReference/CSharpAddMissingReferenceCodeFixProvider.cs @@ -9,8 +9,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis.AddMissingReference; using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.Packaging; -using Microsoft.CodeAnalysis.SymbolSearch; namespace Microsoft.CodeAnalysis.CSharp.AddMissingReference; @@ -28,13 +26,4 @@ internal class CSharpAddMissingReferenceCodeFixProvider : AbstractAddMissingRefe public CSharpAddMissingReferenceCodeFixProvider() { } - - /// For testing purposes only (so that tests can pass in mock values) - [SuppressMessage("RoslynDiagnosticsReliability", "RS0034:Exported parts should have [ImportingConstructor]", Justification = "Used incorrectly by tests")] - internal CSharpAddMissingReferenceCodeFixProvider( - IPackageInstallerService installerService, - ISymbolSearchService symbolSearchService) - : base(installerService, symbolSearchService) - { - } } diff --git a/src/Features/Core/Portable/AddImport/AbstractAddImportCodeFixProvider.cs b/src/Features/Core/Portable/AddImport/AbstractAddImportCodeFixProvider.cs index e1022a0b6262a..a4e6a7b315b60 100644 --- a/src/Features/Core/Portable/AddImport/AbstractAddImportCodeFixProvider.cs +++ b/src/Features/Core/Portable/AddImport/AbstractAddImportCodeFixProvider.cs @@ -57,9 +57,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) var addImportService = document.GetRequiredLanguageService(); var services = document.Project.Solution.Services; - - var codeActionOptions = context.Options.GetOptions(document.Project.Services); - var searchOptions = codeActionOptions.SearchOptions; + var searchOptions = await document.GetSymbolSearchOptionsAsync(cancellationToken).ConfigureAwait(false); var symbolSearchService = _symbolSearchService ?? services.GetRequiredService(); diff --git a/src/Features/Core/Portable/AddMissingReference/AbstractAddMissingReferenceCodeFixProvider.cs b/src/Features/Core/Portable/AddMissingReference/AbstractAddMissingReferenceCodeFixProvider.cs index 549182e4ffa03..f94b609e766f3 100644 --- a/src/Features/Core/Portable/AddMissingReference/AbstractAddMissingReferenceCodeFixProvider.cs +++ b/src/Features/Core/Portable/AddMissingReference/AbstractAddMissingReferenceCodeFixProvider.cs @@ -20,16 +20,6 @@ namespace Microsoft.CodeAnalysis.AddMissingReference; internal abstract partial class AbstractAddMissingReferenceCodeFixProvider : AbstractAddPackageCodeFixProvider { - /// - /// Values for these parameters can be provided (during testing) for mocking purposes. - /// - protected AbstractAddMissingReferenceCodeFixProvider( - IPackageInstallerService? packageInstallerService = null, - ISymbolSearchService? symbolSearchService = null) - : base(packageInstallerService, symbolSearchService) - { - } - protected override bool IncludePrerelease => false; public override FixAllProvider? GetFixAllProvider() diff --git a/src/Features/Core/Portable/AddPackage/AbstractAddPackageCodeFixProvider.cs b/src/Features/Core/Portable/AddPackage/AbstractAddPackageCodeFixProvider.cs index c6dd016be4013..2cdf37758dd8d 100644 --- a/src/Features/Core/Portable/AddPackage/AbstractAddPackageCodeFixProvider.cs +++ b/src/Features/Core/Portable/AddPackage/AbstractAddPackageCodeFixProvider.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable disable - using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; @@ -18,25 +16,14 @@ namespace Microsoft.CodeAnalysis.AddPackage; +/// +/// Values for parameters can be provided (during testing) for mocking purposes. +/// internal abstract partial class AbstractAddPackageCodeFixProvider : CodeFixProvider { - private readonly IPackageInstallerService _packageInstallerService; - private readonly ISymbolSearchService _symbolSearchService; - - /// - /// Values for these parameters can be provided (during testing) for mocking purposes. - /// - protected AbstractAddPackageCodeFixProvider( - IPackageInstallerService packageInstallerService, - ISymbolSearchService symbolSearchService) - { - _packageInstallerService = packageInstallerService; - _symbolSearchService = symbolSearchService; - } - protected abstract bool IncludePrerelease { get; } - public abstract override FixAllProvider GetFixAllProvider(); + public abstract override FixAllProvider? GetFixAllProvider(); protected async Task> GetAddPackagesCodeActionsAsync( CodeFixContext context, ISet assemblyNames) @@ -46,31 +33,35 @@ protected async Task> GetAddPackagesCodeActionsAsync( var workspaceServices = document.Project.Solution.Services; - var symbolSearchService = _symbolSearchService ?? workspaceServices.GetService(); - var installerService = _packageInstallerService ?? workspaceServices.GetService(); + if (workspaceServices.GetService() is not { } symbolSearchService || + workspaceServices.GetService() is not { } installerService || + !installerService.IsEnabled(document.Project.Id)) + { + return []; + } + + var options = await document.GetSymbolSearchOptionsAsync(cancellationToken).ConfigureAwait(false); + if (!options.SearchNuGetPackages) + { + return []; + } var codeActions = ArrayBuilder.GetInstance(); - if (symbolSearchService != null && - installerService != null && - context.Options.GetOptions(document.Project.Services).SearchOptions.SearchNuGetPackages && - installerService.IsEnabled(document.Project.Id)) + var packageSources = PackageSourceHelper.GetPackageSources(installerService.TryGetPackageSources()); + + foreach (var (name, source) in packageSources) { - var packageSources = PackageSourceHelper.GetPackageSources(installerService.TryGetPackageSources()); + cancellationToken.ThrowIfCancellationRequested(); + + var sortedPackages = await FindMatchingPackagesAsync( + name, symbolSearchService, + assemblyNames, cancellationToken).ConfigureAwait(false); - foreach (var (name, source) in packageSources) + foreach (var package in sortedPackages) { - cancellationToken.ThrowIfCancellationRequested(); - - var sortedPackages = await FindMatchingPackagesAsync( - name, symbolSearchService, - assemblyNames, cancellationToken).ConfigureAwait(false); - - foreach (var package in sortedPackages) - { - codeActions.Add(new InstallPackageParentCodeAction( - installerService, source, - package.PackageName, IncludePrerelease, document)); - } + codeActions.Add(new InstallPackageParentCodeAction( + installerService, source, + package.PackageName, IncludePrerelease, document)); } } diff --git a/src/Features/Core/Portable/AddPackage/AbstractAddSpecificPackageCodeFixProvider.cs b/src/Features/Core/Portable/AddPackage/AbstractAddSpecificPackageCodeFixProvider.cs index f3bc83dce9071..ddebcbe127d78 100644 --- a/src/Features/Core/Portable/AddPackage/AbstractAddSpecificPackageCodeFixProvider.cs +++ b/src/Features/Core/Portable/AddPackage/AbstractAddSpecificPackageCodeFixProvider.cs @@ -17,10 +17,7 @@ internal abstract partial class AbstractAddSpecificPackageCodeFixProvider : Abst /// /// Values for these parameters can be provided (during testing) for mocking purposes. /// - protected AbstractAddSpecificPackageCodeFixProvider( - IPackageInstallerService packageInstallerService = null, - ISymbolSearchService symbolSearchService = null) - : base(packageInstallerService, symbolSearchService) + protected AbstractAddSpecificPackageCodeFixProvider() { } diff --git a/src/Features/Core/Portable/Options/EditorConfig/EditorConfigOptionsEnumerator.cs b/src/Features/Core/Portable/Options/EditorConfig/EditorConfigOptionsEnumerator.cs index 2e7fbb6e9aa0c..22a9096d06c19 100644 --- a/src/Features/Core/Portable/Options/EditorConfig/EditorConfigOptionsEnumerator.cs +++ b/src/Features/Core/Portable/Options/EditorConfig/EditorConfigOptionsEnumerator.cs @@ -14,6 +14,7 @@ using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.ImplementType; +using Microsoft.CodeAnalysis.SymbolSearch; using Microsoft.CodeAnalysis.ValidateFormatString; namespace Microsoft.CodeAnalysis.Options; @@ -40,6 +41,7 @@ internal sealed class EditorConfigOptionsEnumerator( yield return ("unsupported", JsonDetectionOptionsStorage.UnsupportedOptions); yield return ("unsupported", FormatStringValidationOptionStorage.UnsupportedOptions); yield return ("unsupported", RegexOptionsStorage.UnsupportedOptions); + yield return ("unsupported", SymbolSearchOptionsStorage.UnsupportedOptions); } yield return (FeaturesResources.NET_Code_Actions, diff --git a/src/Features/Core/Portable/SymbolSearch/SymbolSearchOptions.cs b/src/Features/Core/Portable/SymbolSearch/SymbolSearchOptions.cs new file mode 100644 index 0000000000000..25697735b5da9 --- /dev/null +++ b/src/Features/Core/Portable/SymbolSearch/SymbolSearchOptions.cs @@ -0,0 +1,58 @@ +// 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.Collections.Immutable; +using System.Runtime.Serialization; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Options; + +namespace Microsoft.CodeAnalysis.SymbolSearch; + +[DataContract] +internal readonly record struct SymbolSearchOptions() +{ + [DataMember] + public bool SearchReferenceAssemblies { get; init; } = true; + + [DataMember] + public bool SearchNuGetPackages { get; init; } = true; + + public static readonly SymbolSearchOptions Default = new(); +} + +internal static class SymbolSearchOptionsStorage +{ + private static readonly OptionGroup s_optionGroup = new(name: "symbol_search", description: ""); + + public static PerLanguageOption2 SearchReferenceAssemblies = new( + "dotnet_unsupported_search_reference_assemblies", + SymbolSearchOptions.Default.SearchReferenceAssemblies, + isEditorConfigOption: true, + group: s_optionGroup); + + public static PerLanguageOption2 SearchNuGetPackages = new( + "dotnet_unsupported_search_nuget_packages", + SymbolSearchOptions.Default.SearchNuGetPackages, + isEditorConfigOption: true, + group: s_optionGroup); + + public static readonly ImmutableArray UnsupportedOptions = [SearchReferenceAssemblies, SearchNuGetPackages]; +} + +internal static class SymbolSearchOptionsProviders +{ + internal static SymbolSearchOptions GetSymbolSearchOptions(this IOptionsReader options, string language) + => new() + { + SearchReferenceAssemblies = options.GetOption(SymbolSearchOptionsStorage.SearchReferenceAssemblies, language), + SearchNuGetPackages = options.GetOption(SymbolSearchOptionsStorage.SearchNuGetPackages, language) + }; + + public static async ValueTask GetSymbolSearchOptionsAsync(this Document document, CancellationToken cancellationToken) + { + var configOptions = await document.GetAnalyzerConfigOptionsAsync(cancellationToken).ConfigureAwait(false); + return configOptions.GetSymbolSearchOptions(document.Project.Language); + } +} diff --git a/src/LanguageServer/Protocol/Features/Options/CodeActionOptionsStorage.cs b/src/LanguageServer/Protocol/Features/Options/CodeActionOptionsStorage.cs index a6b78f13a58e8..cef8fd7c65508 100644 --- a/src/LanguageServer/Protocol/Features/Options/CodeActionOptionsStorage.cs +++ b/src/LanguageServer/Protocol/Features/Options/CodeActionOptionsStorage.cs @@ -15,10 +15,7 @@ namespace Microsoft.CodeAnalysis.CodeActions internal static class CodeActionOptionsStorage { public static CodeActionOptions GetCodeActionOptions(this IGlobalOptionService globalOptions, LanguageServices languageServices) - => new() - { - SearchOptions = globalOptions.GetSymbolSearchOptions(languageServices.Language) - }; + => new(); internal static CodeActionOptionsProvider GetCodeActionOptionsProvider(this IGlobalOptionService globalOptions) { diff --git a/src/LanguageServer/Protocol/Features/Options/SymbolSearchOptionsStorage.cs b/src/LanguageServer/Protocol/Features/Options/SymbolSearchOptionsStorage.cs deleted file mode 100644 index 4e4bb0d4d62cc..0000000000000 --- a/src/LanguageServer/Protocol/Features/Options/SymbolSearchOptionsStorage.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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 Microsoft.CodeAnalysis.Options; - -namespace Microsoft.CodeAnalysis.SymbolSearch -{ - internal static class SymbolSearchOptionsStorage - { - internal static SymbolSearchOptions GetSymbolSearchOptions(this IGlobalOptionService globalOptions, string language) - => new() - { - SearchReferenceAssemblies = globalOptions.GetOption(SearchReferenceAssemblies, language), - SearchNuGetPackages = globalOptions.GetOption(SearchNuGetPackages, language) - }; - - private static readonly OptionGroup s_optionGroup = new(name: "symbol_search", description: ""); - - public static PerLanguageOption2 SearchReferenceAssemblies = - new("dotnet_search_reference_assemblies", - SymbolSearchOptions.Default.SearchReferenceAssemblies, - group: s_optionGroup); - - public static PerLanguageOption2 SearchNuGetPackages = - new("dotnet_search_nuget_packages", SymbolSearchOptions.Default.SearchNuGetPackages, group: s_optionGroup); - } -} diff --git a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs index 29f87408d946e..41e6c705ee9f8 100644 --- a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs +++ b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs @@ -405,8 +405,8 @@ public bool TryFetch(LocalUserRegistryOptionPersister persister, OptionKey2 opti {"visual_studio_disable_document_outline_feature_flag", new FeatureFlagStorage(@"DocumentOutline.DisableFeature")}, {"visual_studio_document_outline_sort_order", new RoamingProfileStorage(@"DocumentOutline.SortOrder")}, {"visual_studio_enable_symbol_search", new LocalUserProfileStorage(@"Roslyn\Features\SymbolSearch", "Enabled")}, - {"dotnet_search_nuget_packages", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInNuGetPackages")}, - {"dotnet_search_reference_assemblies", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInReferenceAssemblies")}, + {"dotnet_unsupported_search_nuget_packages", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInNuGetPackages")}, + {"dotnet_unsupported_search_reference_assemblies", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInReferenceAssemblies")}, #pragma warning disable CS0612 // Type or member is obsolete {"tab_width", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Tab Size", "TextEditor.Basic.Tab Size")}, #pragma warning restore diff --git a/src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptions.cs b/src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptions.cs deleted file mode 100644 index 2ea25038f4b27..0000000000000 --- a/src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptions.cs +++ /dev/null @@ -1,21 +0,0 @@ -// 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.Runtime.Serialization; - -namespace Microsoft.CodeAnalysis.SymbolSearch; - -[DataContract] -internal readonly record struct SymbolSearchOptions -{ - [DataMember] public bool SearchReferenceAssemblies { get; init; } = true; - [DataMember] public bool SearchNuGetPackages { get; init; } = true; - - // required to make sure new SymbolSearchOptions() runs property initializers - public SymbolSearchOptions() - { - } - - public static readonly SymbolSearchOptions Default = new(); -} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeActionOptions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeActionOptions.cs index dcadf01561c48..74d482117181b 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeActionOptions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeActionOptions.cs @@ -20,9 +20,6 @@ internal sealed record class CodeActionOptions public static readonly CodeActionOptions Default = new(); public static readonly CodeActionOptionsProvider DefaultProvider = Default.CreateProvider(); -#if !CODE_STYLE - [DataMember] public SymbolSearchOptions SearchOptions { get; init; } = SymbolSearchOptions.Default; -#endif public CodeActionOptionsProvider CreateProvider() => new DelegatingCodeActionOptionsProvider(_ => this); } From 728a2c9e33386cb48ee67f108eba9e59157b2876 Mon Sep 17 00:00:00 2001 From: tmat Date: Fri, 12 Jul 2024 17:39:53 -0700 Subject: [PATCH 2/4] Eliminate CodeActionOptions --- .../CSharpTest/Formatting/CodeCleanupTests.cs | 6 +- .../FixAll/FixMultipleOccurrencesService.cs | 6 +- .../Suggestions/SuggestedActionsSource.cs | 12 ++-- .../SuggestedActionsSource_Async.cs | 6 +- .../CodeActions/AbstractCodeActionTest.cs | 13 ++-- .../Diagnostics/AbstractUserDiagnosticTest.cs | 12 ++-- .../Test/CodeFixes/CodeFixServiceTests.cs | 28 ++++----- .../CodeRefactoringServiceTest.cs | 15 +++-- .../Test/Options/GlobalOptionsTests.cs | 1 - .../Test2/CodeFixes/CodeFixServiceTests.vb | 7 +-- .../SyncNamespacesServiceTests.vb | 10 ++-- .../Formatting/CodeCleanUpTests.vb | 3 - ...ecursivePatternsCodeRefactoringProvider.cs | 1 - ...ConvertNamespaceCodeRefactoringProvider.cs | 1 - ...tringToRawStringCodeRefactoringProvider.cs | 1 - ...seExpressionBodyCodeRefactoringProvider.cs | 1 - .../Suppression/SuppressionTests.cs | 2 +- ...actAddFileBannerCodeRefactoringProvider.cs | 1 - .../IFixMultipleOccurrencesService.cs | 2 - .../CodeRefactorings/CodeRefactoring.cs | 6 +- .../CodeRefactoringService.cs | 18 +++--- .../ICodeRefactoringService.cs | 8 +-- ...onvertIfToSwitchCodeRefactoringProvider.cs | 1 - .../AbstractSyncNamespacesService.cs | 8 +-- .../SyncNamespaces/ISyncNamespacesService.cs | 2 +- .../CSharpCodeFixVerifier`2+Test.cs | 36 ----------- .../CSharpCodeRefactoringVerifier`1+Test.cs | 11 ---- .../CodeActions/SharedVerifierState.cs | 3 - .../VisualBasicCodeFixVerifier`2+Test.cs | 5 -- ...sualBasicCodeRefactoringVerifier`1+Test.cs | 3 - .../AbstractCodeActionTest_NoEditor.cs | 10 ++-- .../AbstractUserDiagnosticTest_NoEditor.cs | 12 ++-- .../OmniSharpCodeFixContextFactory.cs | 7 +-- .../TestDiagnosticAnalyzerDriver.cs | 7 --- .../CodeCleanup/AbstractCodeCleanupService.cs | 22 ++++--- .../CodeCleanup/ICodeCleanupService.cs | 2 +- .../Features/CodeFixes/CodeFixService.cs | 39 +++++------- .../Features/CodeFixes/ICodeFixService.cs | 24 ++++---- .../Options/CodeActionOptionsStorage.cs | 26 -------- .../GlobalCodeActionOptionsProvider.cs | 27 --------- .../UnifiedSuggestedActionsSource.cs | 12 ++-- .../CodeActionFixAllResolveHandler.cs | 2 - .../Handler/CodeActions/CodeActionHelpers.cs | 11 ++-- .../CodeActions/CodeActionResolveHandler.cs | 2 - .../Handler/CodeActions/CodeActionsHandler.cs | 3 +- .../LanguageService/CSharpCodeCleanupFixer.cs | 4 +- .../CodeCleanup/AbstractCodeCleanUpFixer.cs | 27 +++------ .../SyncNamespacesCommandHandler.cs | 6 +- .../VisualStudioSuppressionFixService.cs | 4 -- .../VisualBasicCodeCleanupFixer.vb | 4 +- .../Core/Portable/CodeFixes/CodeFixContext.cs | 47 +++------------ .../FixAllOccurrences/BatchFixAllProvider.cs | 2 +- .../FixAllOccurrences/FixAllContext.cs | 6 +- .../FixAllOccurrences/FixAllState.cs | 20 +++---- .../CommonFixAllState.cs | 3 - .../CodeFixesAndRefactorings/IFixAllState.cs | 2 - .../CodeRefactoringContext.cs | 8 +-- .../FixAllOccurences/FixAllState.cs | 10 +--- ...yntaxEditorBasedCodeRefactoringProvider.cs | 9 +-- .../CoreTest/Remote/ServiceDescriptorTests.cs | 1 - .../Core/CodeFixes/CodeActionOptions.cs | 59 ------------------- .../Core/WorkspaceExtensions.projitems | 1 - 62 files changed, 161 insertions(+), 487 deletions(-) delete mode 100644 src/LanguageServer/Protocol/Features/Options/CodeActionOptionsStorage.cs delete mode 100644 src/LanguageServer/Protocol/Features/Options/GlobalCodeActionOptionsProvider.cs delete mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeActionOptions.cs diff --git a/src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs b/src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs index df7f3b889c6ed..41e18e4107c17 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs @@ -795,8 +795,6 @@ private static async Task TestThirdPartyCodeFixer(string co using var workspace = EditorTestWorkspace.CreateCSharp(code, composition: EditorTestCompositions.EditorFeaturesWpf.AddParts(typeof(TCodefix))); - var options = CodeActionOptions.DefaultProvider; - var project = workspace.CurrentSolution.Projects.Single(); var analyzer = (DiagnosticAnalyzer)new TAnalyzer(); var diagnosticIds = analyzer.SupportedDiagnostics.SelectAsArray(d => d.Id); @@ -824,7 +822,7 @@ private static async Task TestThirdPartyCodeFixer(string co var enabledDiagnostics = codeCleanupService.GetAllDiagnostics(); var newDoc = await codeCleanupService.CleanupAsync( - document, enabledDiagnostics, CodeAnalysisProgress.None, options, CancellationToken.None); + document, enabledDiagnostics, CodeAnalysisProgress.None, CancellationToken.None); var actual = await newDoc.GetTextAsync(); Assert.Equal(expected, actual.ToString()); @@ -926,7 +924,7 @@ private protected static async Task AssertCodeCleanupResult(string expected, str enabledDiagnostics = VisualStudio.LanguageServices.Implementation.CodeCleanup.AbstractCodeCleanUpFixer.AdjustDiagnosticOptions(enabledDiagnostics, enabledFixIdsFilter); var newDoc = await codeCleanupService.CleanupAsync( - document, enabledDiagnostics, CodeAnalysisProgress.None, workspace.GlobalOptions.CreateProvider(), CancellationToken.None); + document, enabledDiagnostics, CodeAnalysisProgress.None, CancellationToken.None); var actual = await newDoc.GetTextAsync(); diff --git a/src/EditorFeatures/Core.Wpf/Suggestions/FixAll/FixMultipleOccurrencesService.cs b/src/EditorFeatures/Core.Wpf/Suggestions/FixAll/FixMultipleOccurrencesService.cs index a95dba33462e5..5268050b4926c 100644 --- a/src/EditorFeatures/Core.Wpf/Suggestions/FixAll/FixMultipleOccurrencesService.cs +++ b/src/EditorFeatures/Core.Wpf/Suggestions/FixAll/FixMultipleOccurrencesService.cs @@ -35,7 +35,6 @@ public Solution GetFix( Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, - CodeActionOptionsProvider optionsProvider, string equivalenceKey, string waitDialogTitle, string waitDialogMessage, @@ -43,7 +42,7 @@ public Solution GetFix( CancellationToken cancellationToken) { var fixMultipleState = FixAllState.Create( - fixAllProvider, diagnosticsToFix, fixProvider, equivalenceKey, optionsProvider); + fixAllProvider, diagnosticsToFix, fixProvider, equivalenceKey); return GetFixedSolution( fixMultipleState, workspace, waitDialogTitle, waitDialogMessage, progress, cancellationToken); @@ -54,7 +53,6 @@ public Solution GetFix( Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, - CodeActionOptionsProvider optionsProvider, string equivalenceKey, string waitDialogTitle, string waitDialogMessage, @@ -62,7 +60,7 @@ public Solution GetFix( CancellationToken cancellationToken) { var fixMultipleState = FixAllState.Create( - fixAllProvider, diagnosticsToFix, fixProvider, equivalenceKey, optionsProvider); + fixAllProvider, diagnosticsToFix, fixProvider, equivalenceKey); return GetFixedSolution( fixMultipleState, workspace, waitDialogTitle, waitDialogMessage, progress, cancellationToken); diff --git a/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs b/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs index 7a6a29d9512d8..91222cfcb6840 100644 --- a/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs +++ b/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs @@ -188,14 +188,12 @@ private void OnTextViewClosed(object sender, EventArgs e) if (document == null) return null; - var fallbackOptions = GlobalOptions.GetCodeActionOptionsProvider(); - using var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); // Assign over cancellation token so no one accidentally uses the wrong token. cancellationToken = linkedTokenSource.Token; // Kick off the work to get errors. - var errorTask = GetFixLevelAsync(document, range, fallbackOptions, cancellationToken); + var errorTask = GetFixLevelAsync(document, range, cancellationToken); // Make a quick jump back to the UI thread to get the user's selection, then go back to the thread pool.. await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken); @@ -205,7 +203,7 @@ private void OnTextViewClosed(object sender, EventArgs e) // If we have a selection, kick off the work to get refactorings concurrently with the above work to get errors. var refactoringTask = selection != null - ? TryGetRefactoringSuggestedActionCategoryAsync(document, selection, fallbackOptions, cancellationToken) + ? TryGetRefactoringSuggestedActionCategoryAsync(document, selection, cancellationToken) : SpecializedTasks.Null(); // If we happen to get the result of the error task before the refactoring task, @@ -221,7 +219,6 @@ private void OnTextViewClosed(object sender, EventArgs e) private async Task GetFixLevelAsync( TextDocument document, SnapshotSpan range, - CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) { // Ensure we yield the thread that called into us, allowing it to continue onwards. @@ -254,7 +251,7 @@ private void OnTextViewClosed(object sender, EventArgs e) state.Target.SubjectBuffer.SupportsCodeFixes()) { var result = await state.Target.Owner._codeFixService.GetMostSevereFixAsync( - document, range.Span.ToTextSpan(), priorityProvider, fallbackOptions, cancellationToken).ConfigureAwait(false); + document, range.Span.ToTextSpan(), priorityProvider, cancellationToken).ConfigureAwait(false); if (result != null) { @@ -276,7 +273,6 @@ private void OnTextViewClosed(object sender, EventArgs e) private async Task TryGetRefactoringSuggestedActionCategoryAsync( TextDocument document, TextSpan? selection, - CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) { // Ensure we yield the thread that called into us, allowing it to continue onwards. @@ -300,7 +296,7 @@ private void OnTextViewClosed(object sender, EventArgs e) state.Target.SubjectBuffer.SupportsRefactorings()) { if (await state.Target.Owner._codeRefactoringService.HasRefactoringsAsync( - document, selection.Value, fallbackOptions, cancellationToken).ConfigureAwait(false)) + document, selection.Value, cancellationToken).ConfigureAwait(false)) { return PredefinedSuggestedActionCategoryNames.Refactoring; } diff --git a/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource_Async.cs b/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource_Async.cs index e677293685c06..7f4c8382432b9 100644 --- a/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource_Async.cs +++ b/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource_Async.cs @@ -211,8 +211,6 @@ private async IAsyncEnumerable GetCodeFixesAndRefactoringsAs var workspace = document.Project.Solution.Workspace; var supportsFeatureService = workspace.Services.GetRequiredService(); - var options = GlobalOptions.GetCodeActionOptionsProvider(); - var fixesTask = GetCodeFixesAsync(); var refactoringsTask = GetRefactoringsAsync(); @@ -242,7 +240,7 @@ async Task> GetCodeFixesAsync() return await UnifiedSuggestedActionsSource.GetFilterAndOrderCodeFixesAsync( workspace, owner._codeFixService, document, range.Span.ToTextSpan(), - priorityProvider, options, cancellationToken).ConfigureAwait(false); + priorityProvider, cancellationToken).ConfigureAwait(false); } async Task> GetRefactoringsAsync() @@ -273,7 +271,7 @@ async Task> GetRefactoringsAsync() var filterOutsideSelection = !requestedActionCategories.Contains(PredefinedSuggestedActionCategoryNames.Refactoring); return await UnifiedSuggestedActionsSource.GetFilterAndOrderCodeRefactoringsAsync( - workspace, owner._codeRefactoringService, document, selection.Value, priorityProvider.Priority, options, + workspace, owner._codeRefactoringService, document, selection.Value, priorityProvider.Priority, filterOutsideSelection, cancellationToken).ConfigureAwait(false); } diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs index 986ae5ba96667..d9c4f5743c053 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs @@ -61,7 +61,7 @@ protected abstract CodeRefactoringProvider CreateCodeRefactoringProvider( return (actions, actionToInvoke); var fixAllCodeAction = await GetFixAllFixAsync(actionToInvoke, - refactoring.Provider, refactoring.CodeActionOptionsProvider, document, span, fixAllScope.Value).ConfigureAwait(false); + refactoring.Provider, document, span, fixAllScope.Value).ConfigureAwait(false); if (fixAllCodeAction == null) return (ImmutableArray.Empty, null); @@ -71,7 +71,6 @@ protected abstract CodeRefactoringProvider CreateCodeRefactoringProvider( private static async Task GetFixAllFixAsync( CodeAction originalCodeAction, CodeRefactoringProvider provider, - CodeActionOptionsProvider optionsProvider, Document document, TextSpan selectionSpan, FixAllScope scope) @@ -80,7 +79,7 @@ private static async Task GetFixAllFixAsync( if (fixAllProvider == null || !fixAllProvider.GetSupportedFixAllScopes().Contains(scope)) return null; - var fixAllState = new FixAllState(fixAllProvider, document, selectionSpan, provider, optionsProvider, scope, originalCodeAction); + var fixAllState = new FixAllState(fixAllProvider, document, selectionSpan, provider, scope, originalCodeAction); var fixAllContext = new FixAllContext(fixAllState, CodeAnalysisProgress.None, CancellationToken.None); return await fixAllProvider.GetFixAsync(fixAllContext).ConfigureAwait(false); } @@ -105,13 +104,9 @@ internal async Task GetCodeRefactoringAsync( var actions = ArrayBuilder<(CodeAction, TextSpan?)>.GetInstance(); - var codeActionOptionsProvider = parameters.globalOptions?.IsEmpty() == false - ? CodeActionOptionsStorage.GetCodeActionOptionsProvider(workspace.GlobalOptions) - : CodeActionOptions.DefaultProvider; - - var context = new CodeRefactoringContext(document, selectedOrAnnotatedSpan, (a, t) => actions.Add((a, t)), codeActionOptionsProvider, CancellationToken.None); + var context = new CodeRefactoringContext(document, selectedOrAnnotatedSpan, (a, t) => actions.Add((a, t)), CancellationToken.None); await provider.ComputeRefactoringsAsync(context); - var result = actions.Count > 0 ? new CodeRefactoring(provider, actions.ToImmutable(), FixAllProviderInfo.Create(provider), codeActionOptionsProvider) : null; + var result = actions.Count > 0 ? new CodeRefactoring(provider, actions.ToImmutable(), FixAllProviderInfo.Create(provider)) : null; actions.Free(); return result; } diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs index ce53456df18be..97d2aee076071 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs @@ -163,7 +163,6 @@ protected static Document GetDocumentAndSelectSpan(EditorTestWorkspace workspace diagnostic.Location.SourceSpan, ImmutableArray.Create(diagnostic), (a, d) => fixes.Add(new CodeFix(document.Project, a, d)), - testDriver.FallbackOptions, CancellationToken.None); await fixer.RegisterCodeFixesAsync(context); @@ -187,7 +186,7 @@ protected static Document GetDocumentAndSelectSpan(EditorTestWorkspace workspace var fixAllState = GetFixAllState( fixAllProvider, diagnostics, fixer, testDriver, document, - scope.Value, equivalenceKey, testDriver.FallbackOptions); + scope.Value, equivalenceKey); var fixAllContext = new FixAllContext(fixAllState, CodeAnalysisProgress.None, CancellationToken.None); var fixAllFix = await fixAllProvider.GetFixAsync(fixAllContext); @@ -203,8 +202,7 @@ private static FixAllState GetFixAllState( TestDiagnosticAnalyzerDriver testDriver, Document document, FixAllScope scope, - string equivalenceKey, - CodeActionOptionsProvider optionsProvider) + string equivalenceKey) { Assert.NotEmpty(diagnostics); @@ -212,7 +210,7 @@ private static FixAllState GetFixAllState( { // Bulk fixing diagnostics in selected scope. var diagnosticsToFix = ImmutableDictionary.CreateRange([KeyValuePairUtil.Create(document, diagnostics.ToImmutableArray())]); - return FixAllState.Create(fixAllProvider, diagnosticsToFix, fixer, equivalenceKey, optionsProvider); + return FixAllState.Create(fixAllProvider, diagnosticsToFix, fixer, equivalenceKey); } var diagnostic = diagnostics.First(); @@ -220,8 +218,8 @@ private static FixAllState GetFixAllState( var fixAllDiagnosticProvider = new FixAllDiagnosticProvider(testDriver, diagnosticIds); return diagnostic.Location.IsInSource - ? new FixAllState(fixAllProvider, diagnostic.Location.SourceSpan, document, document.Project, fixer, scope, equivalenceKey, diagnosticIds, fixAllDiagnosticProvider, optionsProvider) - : new FixAllState(fixAllProvider, diagnosticSpan: null, document: null, document.Project, fixer, scope, equivalenceKey, diagnosticIds, fixAllDiagnosticProvider, optionsProvider); + ? new FixAllState(fixAllProvider, diagnostic.Location.SourceSpan, document, document.Project, fixer, scope, equivalenceKey, diagnosticIds, fixAllDiagnosticProvider) + : new FixAllState(fixAllProvider, diagnosticSpan: null, document: null, document.Project, fixer, scope, equivalenceKey, diagnosticIds, fixAllDiagnosticProvider); } private protected Task TestActionCountInAllFixesAsync( diff --git a/src/EditorFeatures/Test/CodeFixes/CodeFixServiceTests.cs b/src/EditorFeatures/Test/CodeFixes/CodeFixServiceTests.cs index a59f6172401b1..d2496c4a7dff0 100644 --- a/src/EditorFeatures/Test/CodeFixes/CodeFixServiceTests.cs +++ b/src/EditorFeatures/Test/CodeFixes/CodeFixServiceTests.cs @@ -56,7 +56,7 @@ public async Task TestGetFirstDiagnosticWithFixAsync() var project = workspace.CurrentSolution.Projects.Single().AddAnalyzerReference(reference); var document = project.Documents.Single(); var unused = await fixService.GetMostSevereFixAsync( - document, TextSpan.FromBounds(0, 0), new DefaultCodeActionRequestPriorityProvider(), CodeActionOptions.DefaultProvider, CancellationToken.None); + document, TextSpan.FromBounds(0, 0), new DefaultCodeActionRequestPriorityProvider(), CancellationToken.None); var fixer1 = (MockFixer)fixers.Single().Value; var fixer2 = (MockFixer)reference.Fixers.Single(); @@ -83,7 +83,7 @@ public async Task TestGetFixesAsyncWithDuplicateDiagnostics() GetDocumentAndExtensionManager(tuple.analyzerService, workspace, out var document, out var extensionManager, analyzerReference); // Verify that we do not crash when computing fixes. - _ = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + _ = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), CancellationToken.None); // Verify that code fix is invoked with both the diagnostics in the context, // i.e. duplicate diagnostics are not silently discarded by the CodeFixService. @@ -109,7 +109,7 @@ public async Task TestGetFixesAsyncHasNoDuplicateConfigurationActions() GetDocumentAndExtensionManager(tuple.analyzerService, workspace, out var document, out var extensionManager, analyzerReference); // Verify registered configuration code actions do not have duplicates. - var fixCollections = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + var fixCollections = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), CancellationToken.None); var codeActions = fixCollections.SelectManyAsArray(c => c.Fixes.Select(f => f.Action)); Assert.Equal(7, codeActions.Length); var uniqueTitles = new HashSet(); @@ -141,14 +141,14 @@ public async Task TestGetFixesAsyncForFixableAndNonFixableAnalyzersAsync() // Verify only analyzerWithFix is executed when GetFixesAsync is invoked with 'CodeActionRequestPriority.Normal'. _ = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), - priorityProvider: new DefaultCodeActionRequestPriorityProvider(CodeActionRequestPriority.Default), CodeActionOptions.DefaultProvider, + priorityProvider: new DefaultCodeActionRequestPriorityProvider(CodeActionRequestPriority.Default), cancellationToken: CancellationToken.None); Assert.True(analyzerWithFix.ReceivedCallback); Assert.False(analyzerWithoutFix.ReceivedCallback); // Verify both analyzerWithFix and analyzerWithoutFix are executed when GetFixesAsync is invoked with 'CodeActionRequestPriority.Lowest'. _ = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), - priorityProvider: new DefaultCodeActionRequestPriorityProvider(CodeActionRequestPriority.Lowest), CodeActionOptions.DefaultProvider, + priorityProvider: new DefaultCodeActionRequestPriorityProvider(CodeActionRequestPriority.Lowest), cancellationToken: CancellationToken.None); Assert.True(analyzerWithFix.ReceivedCallback); Assert.True(analyzerWithoutFix.ReceivedCallback); @@ -177,7 +177,7 @@ public async Task TestGetFixesAsyncForDocumentDiagnosticAnalyzerAsync() // Verify both analyzers are executed when GetFixesAsync is invoked with 'CodeActionRequestPriority.Normal'. _ = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), - priorityProvider: new DefaultCodeActionRequestPriorityProvider(CodeActionRequestPriority.Default), CodeActionOptions.DefaultProvider, + priorityProvider: new DefaultCodeActionRequestPriorityProvider(CodeActionRequestPriority.Default), cancellationToken: CancellationToken.None); Assert.True(documentDiagnosticAnalyzer.ReceivedCallback); } @@ -207,7 +207,7 @@ public async Task TestGetFixesAsyncForGeneratorDiagnosticAsync() Assert.False(codeFix.Called); var fixCollectionSet = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), - priorityProvider: new DefaultCodeActionRequestPriorityProvider(CodeActionRequestPriority.Default), CodeActionOptions.DefaultProvider, + priorityProvider: new DefaultCodeActionRequestPriorityProvider(CodeActionRequestPriority.Default), cancellationToken: CancellationToken.None); Assert.True(codeFix.Called); var fixCollection = Assert.Single(fixCollectionSet); @@ -293,7 +293,7 @@ private static async Task> GetAddedFixesAsync( var reference = new MockAnalyzerReference(codefix, ImmutableArray.Create(diagnosticAnalyzer)); var project = workspace.CurrentSolution.Projects.Single().AddAnalyzerReference(reference); document = project.Documents.Single(); - var fixes = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + var fixes = await tuple.codeFixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), CancellationToken.None); if (exception) { @@ -318,7 +318,7 @@ private static async Task GetFirstDiagnosticWithFixWithExceptionValidationAsync( GetDocumentAndExtensionManager(tuple.analyzerService, workspace, out var document, out var extensionManager); var unused = await tuple.codeFixService.GetMostSevereFixAsync( - document, TextSpan.FromBounds(0, 0), new DefaultCodeActionRequestPriorityProvider(), CodeActionOptions.DefaultProvider, CancellationToken.None); + document, TextSpan.FromBounds(0, 0), new DefaultCodeActionRequestPriorityProvider(), CancellationToken.None); Assert.True(extensionManager.IsDisabled(codefix)); Assert.False(extensionManager.IsIgnored(codefix)); Assert.True(errorReported); @@ -778,7 +778,7 @@ private static async Task> GetNuGetAndVsixCode var document = project.Documents.Single(); - return await fixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + return await fixService.GetFixesAsync(document, TextSpan.FromBounds(0, 0), CancellationToken.None); } private sealed class NuGetCodeFixProvider : AbstractNuGetOrVsixCodeFixProvider @@ -879,7 +879,7 @@ public async Task TestAdditionalDocumentCodeFixAsync() var tuple = ServiceSetup(fixers, additionalDocument: new EditorTestHostDocument("Additional Document", filePath: "test.txt")); using var workspace = tuple.workspace; GetDocumentAndExtensionManager(tuple.analyzerService, workspace, out var txtDocument, out var extensionManager, analyzerReference, documentKind: TextDocumentKind.AdditionalDocument); - var txtDocumentCodeFixes = await tuple.codeFixService.GetFixesAsync(txtDocument, TextSpan.FromBounds(0, 1), CodeActionOptions.DefaultProvider, CancellationToken.None); + var txtDocumentCodeFixes = await tuple.codeFixService.GetFixesAsync(txtDocument, TextSpan.FromBounds(0, 1), CancellationToken.None); Assert.Equal(2, txtDocumentCodeFixes.Length); var txtDocumentCodeFixTitles = txtDocumentCodeFixes.Select(s => s.Fixes.Single().Action.Title).ToImmutableArray(); Assert.Contains(fixer1.Title, txtDocumentCodeFixTitles); @@ -896,7 +896,7 @@ public async Task TestAdditionalDocumentCodeFixAsync() tuple = ServiceSetup(fixers, additionalDocument: new EditorTestHostDocument("Additional Document", filePath: "test.log")); using var workspace2 = tuple.workspace; GetDocumentAndExtensionManager(tuple.analyzerService, workspace2, out var logDocument, out extensionManager, analyzerReference, documentKind: TextDocumentKind.AdditionalDocument); - var logDocumentCodeFixes = await tuple.codeFixService.GetFixesAsync(logDocument, TextSpan.FromBounds(0, 1), CodeActionOptions.DefaultProvider, CancellationToken.None); + var logDocumentCodeFixes = await tuple.codeFixService.GetFixesAsync(logDocument, TextSpan.FromBounds(0, 1), CancellationToken.None); var logDocumentCodeFix = Assert.Single(logDocumentCodeFixes); var logDocumentCodeFixTitle = logDocumentCodeFix.Fixes.Single().Action.Title; Assert.Equal(fixer2.Title, logDocumentCodeFixTitle); @@ -1082,9 +1082,9 @@ await diagnosticIncrementalAnalyzer.GetDiagnosticsForIdsAsync( var lowPriorityAnalyzerData = new SuggestedActionPriorityProvider.LowPriorityAnalyzersAndDiagnosticIds(); var priorityProvider = new SuggestedActionPriorityProvider(CodeActionRequestPriority.Default, lowPriorityAnalyzerData); - var normalPriFixes = await tuple.codeFixService.GetFixesAsync(sourceDocument, testSpan, priorityProvider, CodeActionOptions.DefaultProvider, CancellationToken.None); + var normalPriFixes = await tuple.codeFixService.GetFixesAsync(sourceDocument, testSpan, priorityProvider, CancellationToken.None); priorityProvider = new SuggestedActionPriorityProvider(CodeActionRequestPriority.Low, lowPriorityAnalyzerData); - var lowPriFixes = await tuple.codeFixService.GetFixesAsync(sourceDocument, testSpan, priorityProvider, CodeActionOptions.DefaultProvider, CancellationToken.None); + var lowPriFixes = await tuple.codeFixService.GetFixesAsync(sourceDocument, testSpan, priorityProvider, CancellationToken.None); if (expectedNoFixes) { diff --git a/src/EditorFeatures/Test/CodeRefactorings/CodeRefactoringServiceTest.cs b/src/EditorFeatures/Test/CodeRefactorings/CodeRefactoringServiceTest.cs index b350a11eb52c0..7a0b21cc8bae2 100644 --- a/src/EditorFeatures/Test/CodeRefactorings/CodeRefactoringServiceTest.cs +++ b/src/EditorFeatures/Test/CodeRefactorings/CodeRefactoringServiceTest.cs @@ -47,7 +47,7 @@ public async Task TestProjectRefactoringAsync() var reference = new StubAnalyzerReference(); var project = workspace.CurrentSolution.Projects.Single().AddAnalyzerReference(reference); var document = project.Documents.Single(); - var refactorings = await refactoringService.GetRefactoringsAsync(document, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + var refactorings = await refactoringService.GetRefactoringsAsync(document, TextSpan.FromBounds(0, 0), CancellationToken.None); var stubRefactoringAction = refactorings.Single(refactoring => refactoring.CodeActions.FirstOrDefault().action?.Title == nameof(StubRefactoring)); Assert.True(stubRefactoringAction is object); @@ -85,8 +85,7 @@ public async Task TestTypeScriptRefactorings() var refactoringService = workspace.GetService(); var document = workspace.CurrentSolution.Projects.Single().Documents.Single(); - var optionsProvider = workspace.GlobalOptions.GetCodeActionOptionsProvider(); - var refactorings = await refactoringService.GetRefactoringsAsync(document, TextSpan.FromBounds(0, 0), optionsProvider, CancellationToken.None); + var refactorings = await refactoringService.GetRefactoringsAsync(document, TextSpan.FromBounds(0, 0), CancellationToken.None); Assert.Equal($"Blocking=false", refactorings.Single().CodeActions.Single().action.Title); } @@ -107,7 +106,7 @@ private static async Task VerifyRefactoringDisabledAsync() var project = workspace.CurrentSolution.Projects.Single(); var document = project.Documents.Single(); var extensionManager = (EditorLayerExtensionManager.ExtensionManager)document.Project.Solution.Services.GetRequiredService(); - var result = await refactoringService.GetRefactoringsAsync(document, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + var result = await refactoringService.GetRefactoringsAsync(document, TextSpan.FromBounds(0, 0), CancellationToken.None); Assert.True(extensionManager.IsDisabled(codeRefactoring)); Assert.False(extensionManager.IsIgnored(codeRefactoring)); @@ -170,7 +169,7 @@ public async Task TestAdditionalDocumentRefactoringAsync() // Verify available refactorings for .txt additional document var txtAdditionalDocument = project.AdditionalDocuments.Single(t => t.Name == "test.txt"); - var txtRefactorings = await refactoringService.GetRefactoringsAsync(txtAdditionalDocument, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + var txtRefactorings = await refactoringService.GetRefactoringsAsync(txtAdditionalDocument, TextSpan.FromBounds(0, 0), CancellationToken.None); Assert.Equal(2, txtRefactorings.Length); var txtRefactoringTitles = txtRefactorings.Select(s => s.CodeActions.Single().action.Title).ToImmutableArray(); Assert.Contains(refactoring1.Title, txtRefactoringTitles); @@ -185,7 +184,7 @@ public async Task TestAdditionalDocumentRefactoringAsync() // Verify available refactorings for .log additional document var logAdditionalDocument = project.AdditionalDocuments.Single(t => t.Name == "test.log"); - var logRefactorings = await refactoringService.GetRefactoringsAsync(logAdditionalDocument, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + var logRefactorings = await refactoringService.GetRefactoringsAsync(logAdditionalDocument, TextSpan.FromBounds(0, 0), CancellationToken.None); var logRefactoring = Assert.Single(logRefactorings); var logRefactoringTitle = logRefactoring.CodeActions.Single().action.Title; Assert.Equal(refactoring2.Title, logRefactoringTitle); @@ -209,7 +208,7 @@ public async Task TestAnalyzerConfigDocumentRefactoringAsync() // Verify available refactorings for .editorconfig document var editorConfig = project.AnalyzerConfigDocuments.Single(t => t.Name == ".editorconfig"); - var editorConfigRefactorings = await refactoringService.GetRefactoringsAsync(editorConfig, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + var editorConfigRefactorings = await refactoringService.GetRefactoringsAsync(editorConfig, TextSpan.FromBounds(0, 0), CancellationToken.None); Assert.Equal(2, editorConfigRefactorings.Length); var editorConfigRefactoringTitles = editorConfigRefactorings.Select(s => s.CodeActions.Single().action.Title).ToImmutableArray(); Assert.Contains(refactoring1.Title, editorConfigRefactoringTitles); @@ -224,7 +223,7 @@ public async Task TestAnalyzerConfigDocumentRefactoringAsync() // Verify available refactorings for .globalconfig document var globalConfig = project.AnalyzerConfigDocuments.Single(t => t.Name == ".globalconfig"); - var globalConfigRefactorings = await refactoringService.GetRefactoringsAsync(globalConfig, TextSpan.FromBounds(0, 0), CodeActionOptions.DefaultProvider, CancellationToken.None); + var globalConfigRefactorings = await refactoringService.GetRefactoringsAsync(globalConfig, TextSpan.FromBounds(0, 0), CancellationToken.None); var globalConfigRefactoring = Assert.Single(globalConfigRefactorings); var globalConfigRefactoringTitle = globalConfigRefactoring.CodeActions.Single().action.Title; Assert.Equal(refactoring2.Title, globalConfigRefactoringTitle); diff --git a/src/EditorFeatures/Test/Options/GlobalOptionsTests.cs b/src/EditorFeatures/Test/Options/GlobalOptionsTests.cs index 9023f9c1c475e..bea7d5e06d2d1 100644 --- a/src/EditorFeatures/Test/Options/GlobalOptionsTests.cs +++ b/src/EditorFeatures/Test/Options/GlobalOptionsTests.cs @@ -183,7 +183,6 @@ public void ReadingOptionsFromGlobalOptions(string language) using var workspace = CreateWorkspace(out var globalOptions); var languageServices = workspace.Services.SolutionServices.GetLanguageServices(language); - VerifyDataMembersHaveNonDefaultValues(globalOptions.GetCodeActionOptions(languageServices), CodeActionOptions.Default, language); VerifyDataMembersHaveNonDefaultValues(globalOptions.GetBraceMatchingOptions(language), BraceMatchingOptions.Default, language); VerifyDataMembersHaveNonDefaultValues(globalOptions.GetFindUsagesOptions(language), FindUsagesOptions.Default, language); VerifyDataMembersHaveNonDefaultValues(globalOptions.GetInlineHintsOptions(language), InlineHintsOptions.Default, language); diff --git a/src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb b/src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb index 7f13cfe814d6d..fcb96e630d4fb 100644 --- a/src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb +++ b/src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb @@ -76,7 +76,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests Dim fixes = Await codefixService.GetFixesAsync( document, (Await document.GetSyntaxRootAsync()).FullSpan, - CodeActionOptions.DefaultProvider, CancellationToken.None) Assert.Equal(0, fixes.Count()) @@ -92,7 +91,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests fixes = Await codefixService.GetFixesAsync( document, (Await document.GetSyntaxRootAsync()).FullSpan, - CodeActionOptions.DefaultProvider, CancellationToken.None) Assert.Equal(1, fixes.Count()) @@ -102,7 +100,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests fixes = Await codefixService.GetFixesAsync( document, (Await document.GetSyntaxRootAsync()).FullSpan, - CodeActionOptions.DefaultProvider, CancellationToken.None) Assert.Equal(0, fixes.Count()) @@ -151,7 +148,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests Dim fixes = Await codefixService.GetFixesAsync( document, (Await document.GetSyntaxRootAsync()).FullSpan, - CodeActionOptions.DefaultProvider, CancellationToken.None) Assert.Equal(0, fixes.Count()) @@ -167,7 +163,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests fixes = Await codefixService.GetFixesAsync( document, (Await document.GetSyntaxRootAsync()).FullSpan, - CodeActionOptions.DefaultProvider, CancellationToken.None) Assert.Equal(0, fixes.Count()) @@ -299,7 +294,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests ' Make sure we don't crash Dim unused = Await codefixService.GetMostSevereFixAsync( - document, Text.TextSpan.FromBounds(0, 0), New DefaultCodeActionRequestPriorityProvider(), CodeActionOptions.DefaultProvider, CancellationToken.None) + document, Text.TextSpan.FromBounds(0, 0), New DefaultCodeActionRequestPriorityProvider(), CancellationToken.None) End Using End Function diff --git a/src/EditorFeatures/Test2/SyncNamespaces/SyncNamespacesServiceTests.vb b/src/EditorFeatures/Test2/SyncNamespaces/SyncNamespacesServiceTests.vb index 8f06cb1e2d3a5..a2c2d4b2e7ac0 100644 --- a/src/EditorFeatures/Test2/SyncNamespaces/SyncNamespacesServiceTests.vb +++ b/src/EditorFeatures/Test2/SyncNamespaces/SyncNamespacesServiceTests.vb @@ -41,7 +41,7 @@ namespace Test.Namespace.App Dim document = project.Documents.Single() Dim syncService = project.GetLanguageService(Of ISyncNamespacesService)() - Dim newSolution = Await syncService.SyncNamespacesAsync(ImmutableArray.Create(project), CodeActionOptions.DefaultProvider, CodeAnalysisProgress.None, CancellationToken.None) + Dim newSolution = Await syncService.SyncNamespacesAsync(ImmutableArray.Create(project), CodeAnalysisProgress.None, CancellationToken.None) Dim solutionChanges = workspace.CurrentSolution.GetChanges(newSolution) @@ -77,7 +77,7 @@ namespace Test Dim document = project.Documents.Single() Dim syncService = project.GetLanguageService(Of ISyncNamespacesService)() - Dim newSolution = Await syncService.SyncNamespacesAsync(projects, CodeActionOptions.DefaultProvider, CodeAnalysisProgress.None, CancellationToken.None) + Dim newSolution = Await syncService.SyncNamespacesAsync(projects, CodeAnalysisProgress.None, CancellationToken.None) Dim solutionChanges = workspace.CurrentSolution.GetChanges(newSolution) Dim projectChanges = solutionChanges.GetProjectChanges().Single() @@ -134,7 +134,7 @@ namespace Test2.Namespace.App Dim project = projects(0) Dim syncService = project.GetLanguageService(Of ISyncNamespacesService)() - Dim newSolution = Await syncService.SyncNamespacesAsync(projects, CodeActionOptions.DefaultProvider, CodeAnalysisProgress.None, CancellationToken.None) + Dim newSolution = Await syncService.SyncNamespacesAsync(projects, CodeAnalysisProgress.None, CancellationToken.None) Dim solutionChanges = workspace.CurrentSolution.GetChanges(newSolution) @@ -188,7 +188,7 @@ namespace Test2.Namespace.App Dim document = project.Documents.Single() Dim syncService = project.GetLanguageService(Of ISyncNamespacesService)() - Dim newSolution = Await syncService.SyncNamespacesAsync(projects, CodeActionOptions.DefaultProvider, CodeAnalysisProgress.None, CancellationToken.None) + Dim newSolution = Await syncService.SyncNamespacesAsync(projects, CodeAnalysisProgress.None, CancellationToken.None) Dim solutionChanges = workspace.CurrentSolution.GetChanges(newSolution) Dim projectChanges = solutionChanges.GetProjectChanges().Single() @@ -253,7 +253,7 @@ namespace Test2.Namespace Dim document2 = project2.Documents.Single() Dim syncService = project.GetLanguageService(Of ISyncNamespacesService)() - Dim newSolution = Await syncService.SyncNamespacesAsync(projects, CodeActionOptions.DefaultProvider, CodeAnalysisProgress.None, CancellationToken.None) + Dim newSolution = Await syncService.SyncNamespacesAsync(projects, CodeAnalysisProgress.None, CancellationToken.None) Dim solutionChanges = workspace.CurrentSolution.GetChanges(newSolution) Dim projectChanges = solutionChanges.GetProjectChanges().ToImmutableArray() diff --git a/src/EditorFeatures/VisualBasicTest/Formatting/CodeCleanUpTests.vb b/src/EditorFeatures/VisualBasicTest/Formatting/CodeCleanUpTests.vb index 04ef58a719389..e2eff36a2a1c4 100644 --- a/src/EditorFeatures/VisualBasicTest/Formatting/CodeCleanUpTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Formatting/CodeCleanUpTests.vb @@ -510,7 +510,6 @@ End Class Private Shared Async Function TestThirdPartyCodeFixer(Of TCodefix As {CodeFixProvider, New}, TAnalyzer As {DiagnosticAnalyzer, New})(expected As String, code As String, Optional severity As DiagnosticSeverity = DiagnosticSeverity.Warning) As Task Using workspace = TestWorkspace.CreateVisualBasic(code, composition:=EditorTestCompositions.EditorFeaturesWpf.AddParts(GetType(TCodefix))) - Dim options = CodeActionOptions.DefaultProvider Dim project = workspace.CurrentSolution.Projects.Single() Dim map = New Dictionary(Of String, ImmutableArray(Of DiagnosticAnalyzer)) From { @@ -540,7 +539,6 @@ End Class document, enabledDiagnostics, CodeAnalysisProgress.None, - options, CancellationToken.None) Dim actual = Await newDoc.GetTextAsync() @@ -588,7 +586,6 @@ End Class document, enabledDiagnostics, CodeAnalysisProgress.None, - workspace.GlobalOptions.CreateProvider(), CancellationToken.None) Dim actual = Await newDoc.GetTextAsync() diff --git a/src/Features/CSharp/Portable/CodeRefactorings/UseRecursivePatterns/UseRecursivePatternsCodeRefactoringProvider.cs b/src/Features/CSharp/Portable/CodeRefactorings/UseRecursivePatterns/UseRecursivePatternsCodeRefactoringProvider.cs index d87e358100bfb..49757d74e2e07 100644 --- a/src/Features/CSharp/Portable/CodeRefactorings/UseRecursivePatterns/UseRecursivePatternsCodeRefactoringProvider.cs +++ b/src/Features/CSharp/Portable/CodeRefactorings/UseRecursivePatterns/UseRecursivePatternsCodeRefactoringProvider.cs @@ -583,7 +583,6 @@ protected override async Task FixAllAsync( Document document, ImmutableArray fixAllSpans, SyntaxEditor editor, - CodeActionOptionsProvider optionsProvider, string? equivalenceKey, CancellationToken cancellationToken) { diff --git a/src/Features/CSharp/Portable/ConvertNamespace/ConvertNamespaceCodeRefactoringProvider.cs b/src/Features/CSharp/Portable/ConvertNamespace/ConvertNamespaceCodeRefactoringProvider.cs index 5449604678af5..40c6be6b2b608 100644 --- a/src/Features/CSharp/Portable/ConvertNamespace/ConvertNamespaceCodeRefactoringProvider.cs +++ b/src/Features/CSharp/Portable/ConvertNamespace/ConvertNamespaceCodeRefactoringProvider.cs @@ -87,7 +87,6 @@ protected override async Task FixAllAsync( Document document, ImmutableArray fixAllSpans, SyntaxEditor editor, - CodeActionOptionsProvider optionsProvider, string? equivalenceKey, CancellationToken cancellationToken) { diff --git a/src/Features/CSharp/Portable/ConvertToRawString/ConvertStringToRawStringCodeRefactoringProvider.cs b/src/Features/CSharp/Portable/ConvertToRawString/ConvertStringToRawStringCodeRefactoringProvider.cs index 90c1735d4be85..60b4f36e23a24 100644 --- a/src/Features/CSharp/Portable/ConvertToRawString/ConvertStringToRawStringCodeRefactoringProvider.cs +++ b/src/Features/CSharp/Portable/ConvertToRawString/ConvertStringToRawStringCodeRefactoringProvider.cs @@ -136,7 +136,6 @@ protected override async Task FixAllAsync( Document document, ImmutableArray fixAllSpans, SyntaxEditor editor, - CodeActionOptionsProvider optionsProvider, string? equivalenceKey, CancellationToken cancellationToken) { diff --git a/src/Features/CSharp/Portable/UseExpressionBody/UseExpressionBodyCodeRefactoringProvider.cs b/src/Features/CSharp/Portable/UseExpressionBody/UseExpressionBodyCodeRefactoringProvider.cs index f69678a6b1b9c..70ab88f8b6b8c 100644 --- a/src/Features/CSharp/Portable/UseExpressionBody/UseExpressionBodyCodeRefactoringProvider.cs +++ b/src/Features/CSharp/Portable/UseExpressionBody/UseExpressionBodyCodeRefactoringProvider.cs @@ -192,7 +192,6 @@ protected override async Task FixAllAsync( Document document, ImmutableArray fixAllSpans, SyntaxEditor editor, - CodeActionOptionsProvider optionsProvider, string? equivalenceKey, CancellationToken cancellationToken) { diff --git a/src/Features/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs b/src/Features/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs index 09c709fb680cb..0d2493062550d 100644 --- a/src/Features/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs +++ b/src/Features/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs @@ -460,7 +460,7 @@ void Method() var diagnostics = await diagnosticService.GetDiagnosticsForSpanAsync(document, span, CancellationToken.None); Assert.Equal(2, diagnostics.Where(d => d.Id == "CS0219").Count()); - var allFixes = (await fixService.GetFixesAsync(document, span, CodeActionOptions.DefaultProvider, CancellationToken.None)) + var allFixes = (await fixService.GetFixesAsync(document, span, CancellationToken.None)) .SelectMany(fixCollection => fixCollection.Fixes); var cs0219Fixes = allFixes.Where(fix => fix.PrimaryDiagnostic.Id == "CS0219").ToArray(); diff --git a/src/Features/Core/Portable/AddFileBanner/AbstractAddFileBannerCodeRefactoringProvider.cs b/src/Features/Core/Portable/AddFileBanner/AbstractAddFileBannerCodeRefactoringProvider.cs index 8d47511a3bf60..3027288b8bbb8 100644 --- a/src/Features/Core/Portable/AddFileBanner/AbstractAddFileBannerCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/AddFileBanner/AbstractAddFileBannerCodeRefactoringProvider.cs @@ -187,7 +187,6 @@ protected sealed override async Task FixAllAsync( Document document, ImmutableArray fixAllSpans, SyntaxEditor editor, - CodeActionOptionsProvider optionsProvider, string? equivalenceKey, CancellationToken cancellationToken) { diff --git a/src/Features/Core/Portable/CodeFixes/FixAllOccurrences/IFixMultipleOccurrencesService.cs b/src/Features/Core/Portable/CodeFixes/FixAllOccurrences/IFixMultipleOccurrencesService.cs index 20fba9729c20a..68baeb8d06f0d 100644 --- a/src/Features/Core/Portable/CodeFixes/FixAllOccurrences/IFixMultipleOccurrencesService.cs +++ b/src/Features/Core/Portable/CodeFixes/FixAllOccurrences/IFixMultipleOccurrencesService.cs @@ -23,7 +23,6 @@ Solution GetFix( Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, - CodeActionOptionsProvider optionsProvider, string equivalenceKey, string waitDialogTitle, string waitDialogMessage, @@ -39,7 +38,6 @@ Solution GetFix( Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, - CodeActionOptionsProvider optionsProvider, string equivalenceKey, string waitDialogTitle, string waitDialogMessage, diff --git a/src/Features/Core/Portable/CodeRefactorings/CodeRefactoring.cs b/src/Features/Core/Portable/CodeRefactorings/CodeRefactoring.cs index a35daaab4d96b..fa6848fd418c1 100644 --- a/src/Features/Core/Portable/CodeRefactorings/CodeRefactoring.cs +++ b/src/Features/Core/Portable/CodeRefactorings/CodeRefactoring.cs @@ -28,18 +28,14 @@ internal class CodeRefactoring public FixAllProviderInfo? FixAllProviderInfo { get; } - public CodeActionOptionsProvider CodeActionOptionsProvider { get; } - public CodeRefactoring( CodeRefactoringProvider provider, ImmutableArray<(CodeAction, TextSpan?)> actions, - FixAllProviderInfo? fixAllProviderInfo, - CodeActionOptionsProvider codeActionOptionsProvider) + FixAllProviderInfo? fixAllProviderInfo) { Provider = provider; CodeActions = actions.NullToEmpty(); FixAllProviderInfo = fixAllProviderInfo; - CodeActionOptionsProvider = codeActionOptionsProvider; if (CodeActions.IsEmpty) { diff --git a/src/Features/Core/Portable/CodeRefactorings/CodeRefactoringService.cs b/src/Features/Core/Portable/CodeRefactorings/CodeRefactoringService.cs index bed4bf0716d5e..a7ff8d8d18381 100644 --- a/src/Features/Core/Portable/CodeRefactorings/CodeRefactoringService.cs +++ b/src/Features/Core/Portable/CodeRefactorings/CodeRefactoringService.cs @@ -90,7 +90,6 @@ static ProjectCodeRefactoringProvider.ExtensionInfo GetExtensionInfo(ExportCodeR public async Task HasRefactoringsAsync( TextDocument document, TextSpan state, - CodeActionOptionsProvider options, CancellationToken cancellationToken) { // A token for controlling the inner work we do calling out to each provider. Once we have a single provider @@ -104,7 +103,7 @@ public async Task HasRefactoringsAsync( source: this.GetProviders(document), produceItems: static async (provider, callback, args, cancellationToken) => { - var (@this, document, state, options, linkedTokenSource) = args; + var (@this, document, state, linkedTokenSource) = args; // Do no work if either the outer request canceled, or another provider already found a refactoring. if (cancellationToken.IsCancellationRequested || linkedTokenSource.Token.IsCancellationRequested) @@ -115,7 +114,7 @@ public async Task HasRefactoringsAsync( // We want to pass linkedTokenSource.Token here so that we can cancel the inner operation once the // outer ProducerConsumer sees a single refactoring returned by any provider. var refactoring = await @this.GetRefactoringFromProviderAsync( - document, state, provider, options, linkedTokenSource.Token).ConfigureAwait(false); + document, state, provider, linkedTokenSource.Token).ConfigureAwait(false); // If we have a refactoring, send a single VoidResult value to the consumer so it can cancel the // other concurrent operations, and can return 'true' to the caller to indicate that there are @@ -142,7 +141,7 @@ public async Task HasRefactoringsAsync( return false; }, - args: (this, document, state, options, linkedTokenSource), + args: (this, document, state, linkedTokenSource), // intentionally using the outer token here. The linked token is only used to cancel the inner operations. cancellationToken).ConfigureAwait(false); } @@ -151,7 +150,6 @@ public async Task> GetRefactoringsAsync( TextDocument document, TextSpan state, CodeActionRequestPriority? priority, - CodeActionOptionsProvider options, CancellationToken cancellationToken) { using (TelemetryLogging.LogBlockTimeAggregated(FunctionId.CodeRefactoring_Summary, $"Pri{priority.GetPriorityInt()}")) @@ -165,7 +163,7 @@ public async Task> GetRefactoringsAsync( source: orderedProviders, produceItems: static async (provider, callback, args, cancellationToken) => { - var (@this, document, state, options) = args; + var (@this, document, state) = args; // Run all providers in parallel to get the set of refactorings for this document. // Log an individual telemetry event for slow code refactoring computations to @@ -186,12 +184,12 @@ public async Task> GetRefactoringsAsync( using (TelemetryLogging.LogBlockTime(FunctionId.CodeRefactoring_Delay, logMessage, CodeRefactoringTelemetryDelay)) { var refactoring = await @this.GetRefactoringFromProviderAsync( - document, state, provider, options, cancellationToken).ConfigureAwait(false); + document, state, provider, cancellationToken).ConfigureAwait(false); if (refactoring != null) callback((provider, refactoring)); } }, - args: (@this: this, document, state, options), + args: (@this: this, document, state), cancellationToken).ConfigureAwait(false); // Order the refactorings by the order of the providers. @@ -208,7 +206,6 @@ public async Task> GetRefactoringsAsync( TextDocument textDocument, TextSpan state, CodeRefactoringProvider provider, - CodeActionOptionsProvider options, CancellationToken cancellationToken) { RefactoringToMetadataMap.TryGetValue(provider, out var providerMetadata); @@ -237,7 +234,6 @@ public async Task> GetRefactoringsAsync( actions.Add((action, applicableToSpan)); } }, - options, cancellationToken); var task = provider.ComputeRefactoringsAsync(context) ?? Task.CompletedTask; @@ -250,7 +246,7 @@ public async Task> GetRefactoringsAsync( var fixAllProviderInfo = extensionManager.PerformFunction( provider, () => ImmutableInterlocked.GetOrAdd(ref _fixAllProviderMap, provider, FixAllProviderInfo.Create), defaultValue: null); - return new CodeRefactoring(provider, actions.ToImmutable(), fixAllProviderInfo, options); + return new CodeRefactoring(provider, actions.ToImmutable(), fixAllProviderInfo); }, defaultValue: null, cancellationToken); } diff --git a/src/Features/Core/Portable/CodeRefactorings/ICodeRefactoringService.cs b/src/Features/Core/Portable/CodeRefactorings/ICodeRefactoringService.cs index 832ae4c4bb765..73c0e093b368d 100644 --- a/src/Features/Core/Portable/CodeRefactorings/ICodeRefactoringService.cs +++ b/src/Features/Core/Portable/CodeRefactorings/ICodeRefactoringService.cs @@ -12,13 +12,13 @@ namespace Microsoft.CodeAnalysis.CodeRefactorings; internal interface ICodeRefactoringService { - Task HasRefactoringsAsync(TextDocument document, TextSpan textSpan, CodeActionOptionsProvider options, CancellationToken cancellationToken); + Task HasRefactoringsAsync(TextDocument document, TextSpan textSpan, CancellationToken cancellationToken); - Task> GetRefactoringsAsync(TextDocument document, TextSpan textSpan, CodeActionRequestPriority? priority, CodeActionOptionsProvider options, CancellationToken cancellationToken); + Task> GetRefactoringsAsync(TextDocument document, TextSpan textSpan, CodeActionRequestPriority? priority, CancellationToken cancellationToken); } internal static class ICodeRefactoringServiceExtensions { - public static Task> GetRefactoringsAsync(this ICodeRefactoringService service, TextDocument document, TextSpan state, CodeActionOptionsProvider options, CancellationToken cancellationToken) - => service.GetRefactoringsAsync(document, state, priority: null, options, cancellationToken); + public static Task> GetRefactoringsAsync(this ICodeRefactoringService service, TextDocument document, TextSpan state, CancellationToken cancellationToken) + => service.GetRefactoringsAsync(document, state, priority: null, cancellationToken); } diff --git a/src/Features/Core/Portable/ConvertIfToSwitch/AbstractConvertIfToSwitchCodeRefactoringProvider.cs b/src/Features/Core/Portable/ConvertIfToSwitch/AbstractConvertIfToSwitchCodeRefactoringProvider.cs index 22bfe93345261..2b215f791388a 100644 --- a/src/Features/Core/Portable/ConvertIfToSwitch/AbstractConvertIfToSwitchCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/ConvertIfToSwitch/AbstractConvertIfToSwitchCodeRefactoringProvider.cs @@ -180,7 +180,6 @@ protected sealed override async Task FixAllAsync( Document document, ImmutableArray fixAllSpans, SyntaxEditor editor, - CodeActionOptionsProvider optionsProvider, string? equivalenceKey, CancellationToken cancellationToken) { diff --git a/src/Features/Core/Portable/SyncNamespaces/AbstractSyncNamespacesService.cs b/src/Features/Core/Portable/SyncNamespaces/AbstractSyncNamespacesService.cs index ecf0c6fcdbb95..5e5d63aaa56a4 100644 --- a/src/Features/Core/Portable/SyncNamespaces/AbstractSyncNamespacesService.cs +++ b/src/Features/Core/Portable/SyncNamespaces/AbstractSyncNamespacesService.cs @@ -30,7 +30,6 @@ internal abstract class AbstractSyncNamespacesService public async Task SyncNamespacesAsync( ImmutableArray projects, - CodeActionOptionsProvider options, IProgress progressTracker, CancellationToken cancellationToken) { @@ -48,7 +47,7 @@ public async Task SyncNamespacesAsync( } var fixAllContext = await GetFixAllContextAsync( - solution, CodeFixProvider, diagnosticsByProject, options, progressTracker, cancellationToken).ConfigureAwait(false); + solution, CodeFixProvider, diagnosticsByProject, progressTracker, cancellationToken).ConfigureAwait(false); var fixAllProvider = CodeFixProvider.GetFixAllProvider(); RoslynDebug.AssertNotNull(fixAllProvider); @@ -94,7 +93,6 @@ private static async Task GetFixAllContextAsync( Solution solution, CodeFixProvider codeFixProvider, ImmutableDictionary> diagnosticsByProject, - CodeActionOptionsProvider options, IProgress progressTracker, CancellationToken cancellationToken) { @@ -114,7 +112,6 @@ private static async Task GetFixAllContextAsync( firstDiagnostic.Location.SourceSpan, [firstDiagnostic], (a, _) => action ??= a, - options, cancellationToken); await codeFixProvider.RegisterCodeFixesAsync(context).ConfigureAwait(false); @@ -128,8 +125,7 @@ private static async Task GetFixAllContextAsync( FixAllScope.Solution, codeActionEquivalenceKey: action?.EquivalenceKey!, // FixAllState supports null equivalence key. This should still be supported. diagnosticIds: codeFixProvider.FixableDiagnosticIds, - fixAllDiagnosticProvider: diagnosticProvider, - options), + fixAllDiagnosticProvider: diagnosticProvider), progressTracker, cancellationToken); } diff --git a/src/Features/Core/Portable/SyncNamespaces/ISyncNamespacesService.cs b/src/Features/Core/Portable/SyncNamespaces/ISyncNamespacesService.cs index f6b694ba5d4c8..a64225f234aab 100644 --- a/src/Features/Core/Portable/SyncNamespaces/ISyncNamespacesService.cs +++ b/src/Features/Core/Portable/SyncNamespaces/ISyncNamespacesService.cs @@ -18,5 +18,5 @@ internal interface ISyncNamespacesService : ILanguageService /// and their relative folder path. /// Task SyncNamespacesAsync( - ImmutableArray projects, CodeActionOptionsProvider options, IProgress progressTracker, CancellationToken cancellationToken); + ImmutableArray projects, IProgress progressTracker, CancellationToken cancellationToken); } diff --git a/src/Features/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs b/src/Features/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs index 954848cdf0828..152ef7427e734 100644 --- a/src/Features/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs +++ b/src/Features/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs @@ -68,13 +68,6 @@ public Test() [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] public new string FixedCode { set => base.FixedCode = value; } -#if !CODE_STYLE - internal CodeActionOptionsProvider CodeActionOptions - { - get => _sharedState.CodeActionOptions; - set => _sharedState.CodeActionOptions = value; - } -#endif /// public string? EditorConfig { @@ -109,35 +102,6 @@ protected override CompilationOptions CreateCompilationOptions() return compilationOptions.WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); } -#if !CODE_STYLE - protected override CodeFixContext CreateCodeFixContext(Document document, TextSpan span, ImmutableArray diagnostics, Action> registerCodeFix, CancellationToken cancellationToken) - => new(document, span, diagnostics, registerCodeFix, _sharedState.CodeActionOptions, cancellationToken); - - protected override FixAllContext CreateFixAllContext( - Document? document, - TextSpan? diagnosticSpan, - Project project, - CodeFixProvider codeFixProvider, - FixAllScope scope, - string? codeActionEquivalenceKey, - IEnumerable diagnosticIds, - DiagnosticSeverity minimumSeverity, - FixAllContext.DiagnosticProvider fixAllDiagnosticProvider, - CancellationToken cancellationToken) - => new(new FixAllState( - fixAllProvider: NoOpFixAllProvider.Instance, - diagnosticSpan, - document, - project, - codeFixProvider, - scope, - codeActionEquivalenceKey, - diagnosticIds, - fixAllDiagnosticProvider, - _sharedState.CodeActionOptions), - CodeAnalysisProgress.None, cancellationToken); -#endif - protected override Diagnostic? TrySelectDiagnosticToFix(ImmutableArray fixableDiagnostics) { return DiagnosticSelector?.Invoke(fixableDiagnostics) diff --git a/src/Features/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs b/src/Features/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs index d73b99c5dc1d6..6fd4da954a54d 100644 --- a/src/Features/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs +++ b/src/Features/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs @@ -66,14 +66,6 @@ public Test() [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] public new string FixedCode { set => base.FixedCode = value; } -#if !CODE_STYLE - internal CodeActionOptionsProvider CodeActionOptions - { - get => _sharedState.CodeActionOptions; - set => _sharedState.CodeActionOptions = value; - } -#endif - /// public string? EditorConfig { @@ -118,9 +110,6 @@ protected override CompilationOptions CreateCompilationOptions() } #if !CODE_STYLE - protected override CodeRefactoringContext CreateCodeRefactoringContext(Document document, TextSpan span, Action registerRefactoring, CancellationToken cancellationToken) - => new CodeRefactoringContext(document, span, (action, textSpan) => registerRefactoring(action), _sharedState.CodeActionOptions, cancellationToken); - /// /// The we want this test to run in. Defaults to if unspecified. /// diff --git a/src/Features/DiagnosticsTestUtilities/CodeActions/SharedVerifierState.cs b/src/Features/DiagnosticsTestUtilities/CodeActions/SharedVerifierState.cs index a22caa9cf08c8..7a8ddc3c69d2e 100644 --- a/src/Features/DiagnosticsTestUtilities/CodeActions/SharedVerifierState.cs +++ b/src/Features/DiagnosticsTestUtilities/CodeActions/SharedVerifierState.cs @@ -47,9 +47,6 @@ public SharedVerifierState(AnalyzerTest test, string defaultFil /// internal OptionsCollection Options { get; } -#if !CODE_STYLE - internal CodeActionOptionsProvider CodeActionOptions { get; set; } = CodeAnalysis.CodeActions.CodeActionOptions.DefaultProvider; -#endif internal void Apply() { var analyzerConfigSource = CodeFixVerifierHelper.ConvertOptionsToAnalyzerConfig(_defaultFileExt, EditorConfig, Options); diff --git a/src/Features/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeFixVerifier`2+Test.cs b/src/Features/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeFixVerifier`2+Test.cs index 688a1a0267fb7..8d6a064c5614a 100644 --- a/src/Features/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeFixVerifier`2+Test.cs +++ b/src/Features/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeFixVerifier`2+Test.cs @@ -87,11 +87,6 @@ protected override ParseOptions CreateParseOptions() return parseOptions.WithLanguageVersion(LanguageVersion); } -#if !CODE_STYLE - protected override CodeFixContext CreateCodeFixContext(Document document, TextSpan span, ImmutableArray diagnostics, Action> registerCodeFix, CancellationToken cancellationToken) - => new(document, span, diagnostics, registerCodeFix, _sharedState.CodeActionOptions, cancellationToken); -#endif - protected override Diagnostic? TrySelectDiagnosticToFix(ImmutableArray fixableDiagnostics) { return DiagnosticSelector?.Invoke(fixableDiagnostics) diff --git a/src/Features/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs b/src/Features/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs index 184faebe03e87..04e8e02286e81 100644 --- a/src/Features/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs +++ b/src/Features/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs @@ -97,9 +97,6 @@ protected override ParseOptions CreateParseOptions() } #if !CODE_STYLE - protected override CodeRefactoringContext CreateCodeRefactoringContext(Document document, TextSpan span, Action registerRefactoring, CancellationToken cancellationToken) - => new CodeRefactoringContext(document, span, (action, textSpan) => registerRefactoring(action), _sharedState.CodeActionOptions, cancellationToken); - /// /// The we want this test to run in. Defaults to /// if unspecified. diff --git a/src/Features/DiagnosticsTestUtilities/CodeActionsLegacy/AbstractCodeActionTest_NoEditor.cs b/src/Features/DiagnosticsTestUtilities/CodeActionsLegacy/AbstractCodeActionTest_NoEditor.cs index 2fafd2e1e644e..6bdc87a7bb3f0 100644 --- a/src/Features/DiagnosticsTestUtilities/CodeActionsLegacy/AbstractCodeActionTest_NoEditor.cs +++ b/src/Features/DiagnosticsTestUtilities/CodeActionsLegacy/AbstractCodeActionTest_NoEditor.cs @@ -62,7 +62,7 @@ protected abstract CodeRefactoringProvider CreateCodeRefactoringProvider( return (actions, actionToInvoke); var fixAllCodeAction = await GetFixAllFixAsync(actionToInvoke, - refactoring.Provider, refactoring.CodeActionOptionsProvider, document, span, fixAllScope.Value).ConfigureAwait(false); + refactoring.Provider, document, span, fixAllScope.Value).ConfigureAwait(false); if (fixAllCodeAction == null) return ([], null); @@ -72,7 +72,6 @@ protected abstract CodeRefactoringProvider CreateCodeRefactoringProvider( private static async Task GetFixAllFixAsync( CodeAction originalCodeAction, CodeRefactoringProvider provider, - CodeActionOptionsProvider optionsProvider, Document document, TextSpan selectionSpan, FixAllScope scope) @@ -81,7 +80,7 @@ private static async Task GetFixAllFixAsync( if (fixAllProvider == null || !fixAllProvider.GetSupportedFixAllScopes().Contains(scope)) return null; - var fixAllState = new FixAllState(fixAllProvider, document, selectionSpan, provider, optionsProvider, scope, originalCodeAction); + var fixAllState = new FixAllState(fixAllProvider, document, selectionSpan, provider, scope, originalCodeAction); var fixAllContext = new FixAllContext(fixAllState, CodeAnalysisProgress.None, CancellationToken.None); return await fixAllProvider.GetFixAsync(fixAllContext).ConfigureAwait(false); } @@ -106,10 +105,9 @@ internal async Task GetCodeRefactoringAsync( using var _ = ArrayBuilder<(CodeAction, TextSpan?)>.GetInstance(out var actions); - var codeActionOptionsProvider = CodeActionOptions.DefaultProvider; - var context = new CodeRefactoringContext(document, selectedOrAnnotatedSpan, (a, t) => actions.Add((a, t)), codeActionOptionsProvider, CancellationToken.None); + var context = new CodeRefactoringContext(document, selectedOrAnnotatedSpan, (a, t) => actions.Add((a, t)), CancellationToken.None); await provider.ComputeRefactoringsAsync(context); - var result = actions.Count > 0 ? new CodeRefactoring(provider, actions.ToImmutable(), FixAllProviderInfo.Create(provider), codeActionOptionsProvider) : null; + var result = actions.Count > 0 ? new CodeRefactoring(provider, actions.ToImmutable(), FixAllProviderInfo.Create(provider)) : null; return result; } diff --git a/src/Features/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_NoEditor.cs b/src/Features/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_NoEditor.cs index 2a8744972f341..24c875aa18842 100644 --- a/src/Features/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_NoEditor.cs +++ b/src/Features/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_NoEditor.cs @@ -163,7 +163,6 @@ protected static Document GetDocumentAndSelectSpan(TestWorkspace workspace, out diagnostic.Location.SourceSpan, ImmutableArray.Create(diagnostic), (a, d) => fixes.Add(new CodeFix(document.Project, a, d)), - testDriver.FallbackOptions, CancellationToken.None); await fixer.RegisterCodeFixesAsync(context); @@ -187,7 +186,7 @@ protected static Document GetDocumentAndSelectSpan(TestWorkspace workspace, out var fixAllState = GetFixAllState( fixAllProvider, diagnostics, fixer, testDriver, document, - scope.Value, equivalenceKey, testDriver.FallbackOptions); + scope.Value, equivalenceKey); var fixAllContext = new FixAllContext(fixAllState, CodeAnalysisProgress.None, CancellationToken.None); var fixAllFix = await fixAllProvider.GetFixAsync(fixAllContext); @@ -203,8 +202,7 @@ private static FixAllState GetFixAllState( TestDiagnosticAnalyzerDriver testDriver, Document document, FixAllScope scope, - string equivalenceKey, - CodeActionOptionsProvider optionsProvider) + string equivalenceKey) { Assert.NotEmpty(diagnostics); @@ -212,7 +210,7 @@ private static FixAllState GetFixAllState( { // Bulk fixing diagnostics in selected scope. var diagnosticsToFix = ImmutableDictionary.CreateRange([KeyValuePairUtil.Create(document, diagnostics.ToImmutableArray())]); - return FixAllState.Create(fixAllProvider, diagnosticsToFix, fixer, equivalenceKey, optionsProvider); + return FixAllState.Create(fixAllProvider, diagnosticsToFix, fixer, equivalenceKey); } var diagnostic = diagnostics.First(); @@ -220,8 +218,8 @@ private static FixAllState GetFixAllState( var fixAllDiagnosticProvider = new FixAllDiagnosticProvider(testDriver, diagnosticIds); return diagnostic.Location.IsInSource - ? new FixAllState(fixAllProvider, diagnostic.Location.SourceSpan, document, document.Project, fixer, scope, equivalenceKey, diagnosticIds, fixAllDiagnosticProvider, optionsProvider) - : new FixAllState(fixAllProvider, diagnosticSpan: null, document: null, document.Project, fixer, scope, equivalenceKey, diagnosticIds, fixAllDiagnosticProvider, optionsProvider); + ? new FixAllState(fixAllProvider, diagnostic.Location.SourceSpan, document, document.Project, fixer, scope, equivalenceKey, diagnosticIds, fixAllDiagnosticProvider) + : new FixAllState(fixAllProvider, diagnosticSpan: null, document: null, document.Project, fixer, scope, equivalenceKey, diagnosticIds, fixAllDiagnosticProvider); } private protected Task TestActionCountInAllFixesAsync( diff --git a/src/Features/ExternalAccess/OmniSharp/CodeActions/OmniSharpCodeFixContextFactory.cs b/src/Features/ExternalAccess/OmniSharp/CodeActions/OmniSharpCodeFixContextFactory.cs index 36df7d600bbcd..4e7271697ec57 100644 --- a/src/Features/ExternalAccess/OmniSharp/CodeActions/OmniSharpCodeFixContextFactory.cs +++ b/src/Features/ExternalAccess/OmniSharp/CodeActions/OmniSharpCodeFixContextFactory.cs @@ -23,7 +23,7 @@ public static CodeFixContext CreateCodeFixContext( OmniSharpCodeActionOptions options, #pragma warning restore IDE0060 // Remove unused parameter CancellationToken cancellationToken) - => new(document, span, diagnostics, registerCodeFix, CodeActionOptions.DefaultProvider, cancellationToken); + => new(document, span, diagnostics, registerCodeFix, cancellationToken); public static CodeAnalysis.CodeRefactorings.CodeRefactoringContext CreateCodeRefactoringContext( Document document, @@ -33,7 +33,7 @@ public static CodeAnalysis.CodeRefactorings.CodeRefactoringContext CreateCodeRef OmniSharpCodeActionOptions options, #pragma warning restore IDE0060 // Remove unused parameter CancellationToken cancellationToken) - => new(document, span, registerRefactoring, CodeActionOptions.DefaultProvider, cancellationToken); + => new(document, span, registerRefactoring, cancellationToken); public static FixAllContext CreateFixAllContext( Document? document, @@ -57,8 +57,7 @@ public static FixAllContext CreateFixAllContext( scope, codeActionEquivalenceKey, diagnosticIds, - fixAllDiagnosticProvider, - CodeActionOptions.DefaultProvider), + fixAllDiagnosticProvider), CodeAnalysisProgress.None, cancellationToken); } } diff --git a/src/Features/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs b/src/Features/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs index f5767ebb02d68..8627649d954d6 100644 --- a/src/Features/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs +++ b/src/Features/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs @@ -25,18 +25,11 @@ public class TestDiagnosticAnalyzerDriver private readonly bool _includeSuppressedDiagnostics; private readonly bool _includeNonLocalDocumentDiagnostics; - internal readonly IGlobalOptionService GlobalOptions; - internal readonly CodeActionOptionsProvider FallbackOptions; - public TestDiagnosticAnalyzerDriver(Workspace workspace, bool includeSuppressedDiagnostics = false, bool includeNonLocalDocumentDiagnostics = false) { var mefServices = workspace.Services.SolutionServices.ExportProvider; _diagnosticAnalyzerService = Assert.IsType(mefServices.GetExportedValue()); - - GlobalOptions = mefServices.GetExportedValue(); - FallbackOptions = GlobalOptions.CreateProvider(); - _diagnosticAnalyzerService.CreateIncrementalAnalyzer(workspace); _includeSuppressedDiagnostics = includeSuppressedDiagnostics; _includeNonLocalDocumentDiagnostics = includeNonLocalDocumentDiagnostics; diff --git a/src/LanguageServer/Protocol/Features/CodeCleanup/AbstractCodeCleanupService.cs b/src/LanguageServer/Protocol/Features/CodeCleanup/AbstractCodeCleanupService.cs index 20adf787ac759..0030292e7994e 100644 --- a/src/LanguageServer/Protocol/Features/CodeCleanup/AbstractCodeCleanupService.cs +++ b/src/LanguageServer/Protocol/Features/CodeCleanup/AbstractCodeCleanupService.cs @@ -39,7 +39,6 @@ public async Task CleanupAsync( Document document, EnabledDiagnosticOptions enabledDiagnostics, IProgress progressTracker, - CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) { // add one item for the code fixers we get from nuget, we'll do last @@ -70,12 +69,12 @@ public async Task CleanupAsync( } document = await ApplyCodeFixesAsync( - document, enabledDiagnostics.Diagnostics, progressTracker, fallbackOptions, cancellationToken).ConfigureAwait(false); + document, enabledDiagnostics.Diagnostics, progressTracker, cancellationToken).ConfigureAwait(false); if (enabledDiagnostics.RunThirdPartyFixers) { document = await ApplyThirdPartyCodeFixesAsync( - document, thirdPartyDiagnosticIdsAndTitles, progressTracker, fallbackOptions, cancellationToken).ConfigureAwait(false); + document, thirdPartyDiagnosticIdsAndTitles, progressTracker, cancellationToken).ConfigureAwait(false); } // do the remove usings after code fix, as code fix might remove some code which can results in unused usings. @@ -102,7 +101,7 @@ public async Task CleanupAsync( if (enabledDiagnostics.RunThirdPartyFixers) { document = await ApplyThirdPartyCodeFixesAsync( - document, thirdPartyDiagnosticIdsAndTitles, progressTracker, fallbackOptions, cancellationToken).ConfigureAwait(false); + document, thirdPartyDiagnosticIdsAndTitles, progressTracker, cancellationToken).ConfigureAwait(false); } return document; @@ -136,7 +135,7 @@ private static async Task RemoveSortUsingsAsync( private async Task ApplyCodeFixesAsync( Document document, ImmutableArray enabledDiagnosticSets, - IProgress progressTracker, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) + IProgress progressTracker, CancellationToken cancellationToken) { // Add a progressTracker item for each enabled option we're going to fixup. foreach (var diagnosticSet in enabledDiagnosticSets) @@ -145,7 +144,7 @@ private async Task ApplyCodeFixesAsync( progressTracker.Report(CodeAnalysisProgress.Description(diagnosticSet.Description)); document = await ApplyCodeFixesForSpecificDiagnosticIdsAsync( - document, diagnosticSet.DiagnosticIds, diagnosticSet.IsAnyDiagnosticIdExplicitlyEnabled, progressTracker, fallbackOptions, cancellationToken).ConfigureAwait(false); + document, diagnosticSet.DiagnosticIds, diagnosticSet.IsAnyDiagnosticIdExplicitlyEnabled, progressTracker, cancellationToken).ConfigureAwait(false); // Mark this option as being completed. progressTracker.ItemCompleted(); @@ -155,7 +154,7 @@ private async Task ApplyCodeFixesAsync( } private async Task ApplyCodeFixesForSpecificDiagnosticIdsAsync( - Document document, ImmutableArray diagnosticIds, bool isAnyDiagnosticIdExplicitlyEnabled, IProgress progressTracker, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) + Document document, ImmutableArray diagnosticIds, bool isAnyDiagnosticIdExplicitlyEnabled, IProgress progressTracker, CancellationToken cancellationToken) { // Enable fixes for all diagnostic severities if any of the diagnostic IDs has been explicitly enabled in Code Cleanup. // Otherwise, only enable fixes for Warning and Error severity diagnostics. @@ -166,7 +165,7 @@ private async Task ApplyCodeFixesForSpecificDiagnosticIdsAsync( using (Logger.LogBlock(FunctionId.CodeCleanup_ApplyCodeFixesAsync, diagnosticId, cancellationToken)) { document = await ApplyCodeFixesForSpecificDiagnosticIdAsync( - document, diagnosticId, minimumSeverity, progressTracker, fallbackOptions, cancellationToken).ConfigureAwait(false); + document, diagnosticId, minimumSeverity, progressTracker, cancellationToken).ConfigureAwait(false); } } @@ -174,13 +173,13 @@ private async Task ApplyCodeFixesForSpecificDiagnosticIdsAsync( } private async Task ApplyCodeFixesForSpecificDiagnosticIdAsync( - Document document, string diagnosticId, DiagnosticSeverity minimumSeverity, IProgress progressTracker, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) + Document document, string diagnosticId, DiagnosticSeverity minimumSeverity, IProgress progressTracker, CancellationToken cancellationToken) { var tree = await document.GetRequiredSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); var textSpan = new TextSpan(0, tree.Length); var fixCollection = await _codeFixService.GetDocumentFixAllForIdInSpanAsync( - document, textSpan, diagnosticId, minimumSeverity, fallbackOptions, cancellationToken).ConfigureAwait(false); + document, textSpan, diagnosticId, minimumSeverity, cancellationToken).ConfigureAwait(false); if (fixCollection == null) { return document; @@ -221,7 +220,6 @@ private async Task ApplyThirdPartyCodeFixesAsync( Document document, ImmutableArray<(string diagnosticId, string? title)> diagnosticIds, IProgress progressTracker, - CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) { foreach (var (diagnosticId, title) in diagnosticIds) @@ -231,7 +229,7 @@ private async Task ApplyThirdPartyCodeFixesAsync( progressTracker.Report(CodeAnalysisProgress.Description(string.Format(FeaturesResources.Fixing_0, title ?? diagnosticId))); // Apply codefixes for diagnostics with a severity of warning or higher var updatedDocument = await _codeFixService.ApplyCodeFixesForSpecificDiagnosticIdAsync( - document, diagnosticId, DiagnosticSeverity.Warning, progressTracker, fallbackOptions, cancellationToken).ConfigureAwait(false); + document, diagnosticId, DiagnosticSeverity.Warning, progressTracker, cancellationToken).ConfigureAwait(false); // If changes were made to the solution snap shot outside the current document discard the changes. // The assumption here is that if we are applying a third party code fix to a document it only affects the document. diff --git a/src/LanguageServer/Protocol/Features/CodeCleanup/ICodeCleanupService.cs b/src/LanguageServer/Protocol/Features/CodeCleanup/ICodeCleanupService.cs index 4da7f236a1211..64ac9a965739c 100644 --- a/src/LanguageServer/Protocol/Features/CodeCleanup/ICodeCleanupService.cs +++ b/src/LanguageServer/Protocol/Features/CodeCleanup/ICodeCleanupService.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.CodeCleanup { internal interface ICodeCleanupService : ILanguageService { - Task CleanupAsync(Document document, EnabledDiagnosticOptions enabledDiagnostics, IProgress progressTracker, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken); + Task CleanupAsync(Document document, EnabledDiagnosticOptions enabledDiagnostics, IProgress progressTracker, CancellationToken cancellationToken); EnabledDiagnosticOptions GetAllDiagnostics(); } } diff --git a/src/LanguageServer/Protocol/Features/CodeFixes/CodeFixService.cs b/src/LanguageServer/Protocol/Features/CodeFixes/CodeFixService.cs index 7ad0124d5fb6b..b76abcf95ec86 100644 --- a/src/LanguageServer/Protocol/Features/CodeFixes/CodeFixService.cs +++ b/src/LanguageServer/Protocol/Features/CodeFixes/CodeFixService.cs @@ -99,7 +99,7 @@ public CodeFixService( } public async Task GetMostSevereFixAsync( - TextDocument document, TextSpan range, ICodeActionRequestPriorityProvider priorityProvider, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) + TextDocument document, TextSpan range, ICodeActionRequestPriorityProvider priorityProvider, CancellationToken cancellationToken) { using var _ = TelemetryLogging.LogBlockTimeAggregated(FunctionId.CodeFix_Summary, $"Pri{priorityProvider.Priority.GetPriorityInt()}.{nameof(GetMostSevereFixAsync)}"); @@ -156,7 +156,7 @@ public CodeFixService( await foreach (var collection in StreamFixesAsync( document, spanToDiagnostics, fixAllForInSpan: false, - priorityProvider, fallbackOptions, cancellationToken).ConfigureAwait(false)) + priorityProvider, cancellationToken).ConfigureAwait(false)) { // Stop at the result error we see. return collection; @@ -170,7 +170,6 @@ public async IAsyncEnumerable StreamFixesAsync( TextDocument document, TextSpan range, ICodeActionRequestPriorityProvider priorityProvider, - CodeActionOptionsProvider fallbackOptions, [EnumeratorCancellation] CancellationToken cancellationToken) { using var _ = TelemetryLogging.LogBlockTimeAggregated(FunctionId.CodeFix_Summary, $"Pri{priorityProvider.Priority.GetPriorityInt()}"); @@ -215,7 +214,7 @@ public async IAsyncEnumerable StreamFixesAsync( { await foreach (var collection in StreamFixesAsync( document, spanToDiagnostics, fixAllForInSpan: false, - priorityProvider, fallbackOptions, cancellationToken).ConfigureAwait(false)) + priorityProvider, cancellationToken).ConfigureAwait(false)) { yield return collection; } @@ -234,7 +233,7 @@ public async IAsyncEnumerable StreamFixesAsync( foreach (var (span, diagnosticList) in spanToDiagnostics) { await foreach (var codeFixCollection in StreamConfigurationFixesAsync( - document, span, diagnosticList, registeredConfigurationFixTitles, fallbackOptions, cancellationToken).ConfigureAwait(false)) + document, span, diagnosticList, registeredConfigurationFixTitles, cancellationToken).ConfigureAwait(false)) { yield return codeFixCollection; } @@ -279,11 +278,11 @@ private static SortedDictionary> ConvertToMap( } public Task GetDocumentFixAllForIdInSpanAsync( - TextDocument document, TextSpan range, string diagnosticId, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) - => GetDocumentFixAllForIdInSpanAsync(document, range, diagnosticId, DiagnosticSeverity.Hidden, fallbackOptions, cancellationToken); + TextDocument document, TextSpan range, string diagnosticId, CancellationToken cancellationToken) + => GetDocumentFixAllForIdInSpanAsync(document, range, diagnosticId, DiagnosticSeverity.Hidden, cancellationToken); public async Task GetDocumentFixAllForIdInSpanAsync( - TextDocument document, TextSpan range, string diagnosticId, DiagnosticSeverity minimumSeverity, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) + TextDocument document, TextSpan range, string diagnosticId, DiagnosticSeverity minimumSeverity, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -309,7 +308,7 @@ private static SortedDictionary> ConvertToMap( await foreach (var collection in StreamFixesAsync( document, spanToDiagnostics, fixAllForInSpan: true, new DefaultCodeActionRequestPriorityProvider(), - fallbackOptions, cancellationToken).ConfigureAwait(false)) + cancellationToken).ConfigureAwait(false)) { if (collection.FixAllState is not null && collection.SupportedScopes.Contains(FixAllScope.Document)) { @@ -322,15 +321,14 @@ private static SortedDictionary> ConvertToMap( return null; } - public Task ApplyCodeFixesForSpecificDiagnosticIdAsync(TDocument document, string diagnosticId, IProgress progressTracker, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) where TDocument : TextDocument - => ApplyCodeFixesForSpecificDiagnosticIdAsync(document, diagnosticId, DiagnosticSeverity.Hidden, progressTracker, fallbackOptions, cancellationToken); + public Task ApplyCodeFixesForSpecificDiagnosticIdAsync(TDocument document, string diagnosticId, IProgress progressTracker, CancellationToken cancellationToken) where TDocument : TextDocument + => ApplyCodeFixesForSpecificDiagnosticIdAsync(document, diagnosticId, DiagnosticSeverity.Hidden, progressTracker, cancellationToken); public async Task ApplyCodeFixesForSpecificDiagnosticIdAsync( TDocument document, string diagnosticId, DiagnosticSeverity severity, IProgress progressTracker, - CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) where TDocument : TextDocument { @@ -340,7 +338,7 @@ public async Task ApplyCodeFixesForSpecificDiagnosticIdAsync StreamFixesAsync( SortedDictionary> spanToDiagnostics, bool fixAllForInSpan, ICodeActionRequestPriorityProvider priorityProvider, - CodeActionOptionsProvider fallbackOptions, [EnumeratorCancellation] CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -547,18 +544,17 @@ private async IAsyncEnumerable StreamFixesAsync( if (fixAllForInSpan) { var primaryDiagnostic = dxs.First(); - return GetCodeFixesAsync(document, primaryDiagnostic.Location.SourceSpan, fixer, fixerMetadata, fallbackOptions, + return GetCodeFixesAsync(document, primaryDiagnostic.Location.SourceSpan, fixer, fixerMetadata, [primaryDiagnostic], uniqueDiagosticToEquivalenceKeysMap, diagnosticAndEquivalenceKeyToFixersMap, cancellationToken); } else { - return GetCodeFixesAsync(document, span, fixer, fixerMetadata, fallbackOptions, dxs, + return GetCodeFixesAsync(document, span, fixer, fixerMetadata, dxs, uniqueDiagosticToEquivalenceKeysMap, diagnosticAndEquivalenceKeyToFixersMap, cancellationToken); } } }, - fallbackOptions, cancellationToken).ConfigureAwait(false); if (codeFixCollection != null) @@ -619,7 +615,7 @@ static void AddAllFixers( } private static async Task> GetCodeFixesAsync( - TextDocument document, TextSpan span, CodeFixProvider fixer, CodeChangeProviderMetadata? fixerMetadata, CodeActionOptionsProvider fallbackOptions, + TextDocument document, TextSpan span, CodeFixProvider fixer, CodeChangeProviderMetadata? fixerMetadata, ImmutableArray diagnostics, Dictionary> uniqueDiagosticToEquivalenceKeysMap, Dictionary<(Diagnostic diagnostic, string? equivalenceKey), CodeFixProvider> diagnosticAndEquivalenceKeyToFixersMap, @@ -650,7 +646,6 @@ private static async Task> GetCodeFixesAsync( } } }, - fallbackOptions, cancellationToken); var task = fixer.RegisterCodeFixesAsync(context) ?? Task.CompletedTask; @@ -704,7 +699,6 @@ private async IAsyncEnumerable StreamConfigurationFixesAsync( TextSpan diagnosticsSpan, IEnumerable diagnostics, PooledHashSet registeredConfigurationFixTitles, - CodeActionOptionsProvider fallbackOptions, [EnumeratorCancellation] CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -728,7 +722,6 @@ private async IAsyncEnumerable StreamConfigurationFixesAsync( var fixes = await provider.GetFixesAsync(document, diagnosticsSpan, dxs, cancellationToken).ConfigureAwait(false); return fixes.WhereAsArray(f => registeredConfigurationFixTitles.Add(f.Action.Title)); }, - fallbackOptions, cancellationToken).ConfigureAwait(false); if (codeFixCollection != null) yield return codeFixCollection; @@ -744,7 +737,6 @@ private async IAsyncEnumerable StreamConfigurationFixesAsync( TCodeFixProvider fixer, Func hasFix, Func, Task>> getFixes, - CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) where TCodeFixProvider : notnull { @@ -795,8 +787,7 @@ await diagnosticsWithSameSpan.OrderByDescending(d => d.Severity) FixAllScope.Document, fixes[0].Action.EquivalenceKey, diagnosticIds, - diagnosticProvider, - fallbackOptions); + diagnosticProvider); supportedScopes = fixAllProviderInfo.SupportedScopes; } diff --git a/src/LanguageServer/Protocol/Features/CodeFixes/ICodeFixService.cs b/src/LanguageServer/Protocol/Features/CodeFixes/ICodeFixService.cs index 30bbcb2d73e8b..5ad72d5bf0095 100644 --- a/src/LanguageServer/Protocol/Features/CodeFixes/ICodeFixService.cs +++ b/src/LanguageServer/Protocol/Features/CodeFixes/ICodeFixService.cs @@ -15,33 +15,33 @@ namespace Microsoft.CodeAnalysis.CodeFixes { internal interface ICodeFixService { - IAsyncEnumerable StreamFixesAsync(TextDocument document, TextSpan textSpan, ICodeActionRequestPriorityProvider priorityProvider, CodeActionOptionsProvider options, CancellationToken cancellationToken); + IAsyncEnumerable StreamFixesAsync(TextDocument document, TextSpan textSpan, ICodeActionRequestPriorityProvider priorityProvider, CancellationToken cancellationToken); /// /// Similar to except that instead of streaming all results, this ends with the /// first. This will also attempt to return a fix for an error first, but will fall back to any fix if that /// does not succeed. /// - Task GetMostSevereFixAsync(TextDocument document, TextSpan range, ICodeActionRequestPriorityProvider priorityProvider, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken); + Task GetMostSevereFixAsync(TextDocument document, TextSpan range, ICodeActionRequestPriorityProvider priorityProvider, CancellationToken cancellationToken); - Task GetDocumentFixAllForIdInSpanAsync(TextDocument document, TextSpan textSpan, string diagnosticId, DiagnosticSeverity severity, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken); - Task ApplyCodeFixesForSpecificDiagnosticIdAsync(TDocument document, string diagnosticId, DiagnosticSeverity severity, IProgress progressTracker, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) + Task GetDocumentFixAllForIdInSpanAsync(TextDocument document, TextSpan textSpan, string diagnosticId, DiagnosticSeverity severity, CancellationToken cancellationToken); + Task ApplyCodeFixesForSpecificDiagnosticIdAsync(TDocument document, string diagnosticId, DiagnosticSeverity severity, IProgress progressTracker, CancellationToken cancellationToken) where TDocument : TextDocument; CodeFixProvider? GetSuppressionFixer(string language, IEnumerable diagnosticIds); } internal static class ICodeFixServiceExtensions { - public static IAsyncEnumerable StreamFixesAsync(this ICodeFixService service, TextDocument document, TextSpan range, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) - => service.StreamFixesAsync(document, range, new DefaultCodeActionRequestPriorityProvider(), fallbackOptions, cancellationToken); + public static IAsyncEnumerable StreamFixesAsync(this ICodeFixService service, TextDocument document, TextSpan range, CancellationToken cancellationToken) + => service.StreamFixesAsync(document, range, new DefaultCodeActionRequestPriorityProvider(), cancellationToken); - public static Task> GetFixesAsync(this ICodeFixService service, TextDocument document, TextSpan range, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) - => service.StreamFixesAsync(document, range, fallbackOptions, cancellationToken).ToImmutableArrayAsync(cancellationToken); + public static Task> GetFixesAsync(this ICodeFixService service, TextDocument document, TextSpan range, CancellationToken cancellationToken) + => service.StreamFixesAsync(document, range, cancellationToken).ToImmutableArrayAsync(cancellationToken); - public static Task> GetFixesAsync(this ICodeFixService service, TextDocument document, TextSpan textSpan, ICodeActionRequestPriorityProvider priorityProvider, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) - => service.StreamFixesAsync(document, textSpan, priorityProvider, fallbackOptions, cancellationToken).ToImmutableArrayAsync(cancellationToken); + public static Task> GetFixesAsync(this ICodeFixService service, TextDocument document, TextSpan textSpan, ICodeActionRequestPriorityProvider priorityProvider, CancellationToken cancellationToken) + => service.StreamFixesAsync(document, textSpan, priorityProvider, cancellationToken).ToImmutableArrayAsync(cancellationToken); - public static Task ApplyCodeFixesForSpecificDiagnosticIdAsync(this ICodeFixService service, TDocument document, string diagnosticId, IProgress progressTracker, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) where TDocument : TextDocument - => service.ApplyCodeFixesForSpecificDiagnosticIdAsync(document, diagnosticId, DiagnosticSeverity.Hidden, progressTracker, fallbackOptions, cancellationToken); + public static Task ApplyCodeFixesForSpecificDiagnosticIdAsync(this ICodeFixService service, TDocument document, string diagnosticId, IProgress progressTracker, CancellationToken cancellationToken) where TDocument : TextDocument + => service.ApplyCodeFixesForSpecificDiagnosticIdAsync(document, diagnosticId, DiagnosticSeverity.Hidden, progressTracker, cancellationToken); } } diff --git a/src/LanguageServer/Protocol/Features/Options/CodeActionOptionsStorage.cs b/src/LanguageServer/Protocol/Features/Options/CodeActionOptionsStorage.cs deleted file mode 100644 index cef8fd7c65508..0000000000000 --- a/src/LanguageServer/Protocol/Features/Options/CodeActionOptionsStorage.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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.Collections.Immutable; -using Microsoft.CodeAnalysis.CodeCleanup; -using Microsoft.CodeAnalysis.CodeGeneration; -using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.ImplementType; -using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.SymbolSearch; - -namespace Microsoft.CodeAnalysis.CodeActions -{ - internal static class CodeActionOptionsStorage - { - public static CodeActionOptions GetCodeActionOptions(this IGlobalOptionService globalOptions, LanguageServices languageServices) - => new(); - - internal static CodeActionOptionsProvider GetCodeActionOptionsProvider(this IGlobalOptionService globalOptions) - { - var cache = ImmutableDictionary.Empty; - return new DelegatingCodeActionOptionsProvider(languageService => ImmutableInterlocked.GetOrAdd(ref cache, languageService.Language, (_, options) => GetCodeActionOptions(options, languageService), globalOptions)); - } - } -} diff --git a/src/LanguageServer/Protocol/Features/Options/GlobalCodeActionOptionsProvider.cs b/src/LanguageServer/Protocol/Features/Options/GlobalCodeActionOptionsProvider.cs deleted file mode 100644 index a9b5000a69e25..0000000000000 --- a/src/LanguageServer/Protocol/Features/Options/GlobalCodeActionOptionsProvider.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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 Microsoft.CodeAnalysis.CodeActions; -using Microsoft.CodeAnalysis.Host; - -namespace Microsoft.CodeAnalysis.Options; - -internal static class CodeActionOptionsStorage -{ - public static Provider CreateProvider(this IGlobalOptionService globalOptions) - => new(globalOptions); - - // TODO: we can implement providers directly on IGlobalOptionService once it moves to LSP layer - public sealed class Provider : - CodeActionOptionsProvider - { - private readonly IGlobalOptionService _globalOptions; - - public Provider(IGlobalOptionService globalOptions) - => _globalOptions = globalOptions; - - CodeActionOptions CodeActionOptionsProvider.GetOptions(LanguageServices languageServices) - => _globalOptions.GetCodeActionOptions(languageServices); - } -} diff --git a/src/LanguageServer/Protocol/Features/UnifiedSuggestions/UnifiedSuggestedActionsSource.cs b/src/LanguageServer/Protocol/Features/UnifiedSuggestions/UnifiedSuggestedActionsSource.cs index 233808fd063d1..323323d041cd9 100644 --- a/src/LanguageServer/Protocol/Features/UnifiedSuggestions/UnifiedSuggestedActionsSource.cs +++ b/src/LanguageServer/Protocol/Features/UnifiedSuggestions/UnifiedSuggestedActionsSource.cs @@ -38,7 +38,6 @@ public static async ValueTask> GetFilt TextDocument document, TextSpan selection, ICodeActionRequestPriorityProvider priorityProvider, - CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken) { var originalSolution = document.Project.Solution; @@ -50,7 +49,6 @@ public static async ValueTask> GetFilt document, selection, priorityProvider, - fallbackOptions, cancellationToken).ConfigureAwait(false); var filteredFixes = fixes.WhereAsArray(c => c.Fixes.Length > 0); @@ -438,7 +436,6 @@ public static async Task> GetFilterAnd TextDocument document, TextSpan selection, CodeActionRequestPriority? priority, - CodeActionOptionsProvider options, bool filterOutsideSelection, CancellationToken cancellationToken) { @@ -446,7 +443,7 @@ public static async Task> GetFilterAnd // this on the UI thread and potentially allow any code to take a dependency on that. await TaskScheduler.Default; var refactorings = await codeRefactoringService.GetRefactoringsAsync( - document, selection, priority, options, + document, selection, priority, cancellationToken).ConfigureAwait(false); var filteredRefactorings = FilterOnAnyThread(refactorings, selection, filterOutsideSelection); @@ -477,7 +474,7 @@ private static ImmutableArray FilterOnAnyThread( ? null : actions.Length == refactoring.CodeActions.Length ? refactoring - : new CodeRefactoring(refactoring.Provider, actions, refactoring.FixAllProviderInfo, refactoring.CodeActionOptionsProvider); + : new CodeRefactoring(refactoring.Provider, actions, refactoring.FixAllProviderInfo); bool IsActionAndSpanApplicable((CodeAction action, TextSpan? applicableSpan) actionAndSpan) { @@ -565,7 +562,7 @@ async Task GetUnifiedSuggestedActionSetAsync(CodeAction { var fixAllSuggestedActionSet = await GetUnifiedFixAllSuggestedActionSetAsync(codeAction, refactoring.CodeActions.Length, document as Document, selection, refactoring.Provider, - refactoring.FixAllProviderInfo, refactoring.CodeActionOptionsProvider, + refactoring.FixAllProviderInfo, workspace, cancellationToken).ConfigureAwait(false); return new UnifiedCodeRefactoringSuggestedAction( @@ -584,7 +581,6 @@ async Task GetUnifiedSuggestedActionSetAsync(CodeAction TextSpan selection, CodeRefactoringProvider provider, FixAllProviderInfo? fixAllProviderInfo, - CodeActionOptionsProvider optionsProvider, Workspace workspace, CancellationToken cancellationToken) { @@ -608,7 +604,7 @@ async Task GetUnifiedSuggestedActionSetAsync(CodeAction { var fixAllState = new CodeRefactorings.FixAllState( (CodeRefactorings.FixAllProvider)fixAllProviderInfo.FixAllProvider, - document, selection, provider, optionsProvider, scope, action); + document, selection, provider, scope, action); if (scope is FixAllScope.ContainingMember or FixAllScope.ContainingType) { diff --git a/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionFixAllResolveHandler.cs b/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionFixAllResolveHandler.cs index 103dd05fba686..2677137bf9096 100644 --- a/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionFixAllResolveHandler.cs +++ b/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionFixAllResolveHandler.cs @@ -44,11 +44,9 @@ public async Task HandleRequestAsync(RoslynFixAllCodeAct var data = GetCodeActionResolveData(request); Assumes.Present(data); - var options = _globalOptions.GetCodeActionOptionsProvider(); var codeActions = await CodeActionHelpers.GetCodeActionsAsync( document, data.Range, - options, _codeFixService, _codeRefactoringService, request.Scope, diff --git a/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs b/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs index 9395fe55c338b..cbfd9f869d226 100644 --- a/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs +++ b/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs @@ -31,14 +31,13 @@ internal static class CodeActionHelpers public static async Task GetVSCodeActionsAsync( CodeActionParams request, TextDocument document, - CodeActionOptionsProvider fallbackOptions, ICodeFixService codeFixService, ICodeRefactoringService codeRefactoringService, bool hasVsLspCapability, CancellationToken cancellationToken) { var actionSets = await GetActionSetsAsync( - document, fallbackOptions, codeFixService, codeRefactoringService, request.Range, cancellationToken).ConfigureAwait(false); + document, codeFixService, codeRefactoringService, request.Range, cancellationToken).ConfigureAwait(false); if (actionSets.IsDefaultOrEmpty) return []; @@ -305,14 +304,13 @@ static VSInternalCodeAction[] GenerateNestedVSCodeActions( public static async Task> GetCodeActionsAsync( TextDocument document, LSP.Range selection, - CodeActionOptionsProvider fallbackOptions, ICodeFixService codeFixService, ICodeRefactoringService codeRefactoringService, string? fixAllScope, CancellationToken cancellationToken) { var actionSets = await GetActionSetsAsync( - document, fallbackOptions, codeFixService, codeRefactoringService, selection, cancellationToken).ConfigureAwait(false); + document, codeFixService, codeRefactoringService, selection, cancellationToken).ConfigureAwait(false); if (actionSets.IsDefaultOrEmpty) return []; @@ -383,7 +381,6 @@ private static void GetFixAllActionsFromActionSet(IUnifiedSuggestedAction sugges private static async ValueTask> GetActionSetsAsync( TextDocument document, - CodeActionOptionsProvider fallbackOptions, ICodeFixService codeFixService, ICodeRefactoringService codeRefactoringService, LSP.Range selection, @@ -395,10 +392,10 @@ private static async ValueTask> GetAct var codeFixes = await UnifiedSuggestedActionsSource.GetFilterAndOrderCodeFixesAsync( document.Project.Solution.Workspace, codeFixService, document, textSpan, new DefaultCodeActionRequestPriorityProvider(), - fallbackOptions, cancellationToken).ConfigureAwait(false); + cancellationToken).ConfigureAwait(false); var codeRefactorings = await UnifiedSuggestedActionsSource.GetFilterAndOrderCodeRefactoringsAsync( - document.Project.Solution.Workspace, codeRefactoringService, document, textSpan, priority: null, fallbackOptions, + document.Project.Solution.Workspace, codeRefactoringService, document, textSpan, priority: null, filterOutsideSelection: false, cancellationToken).ConfigureAwait(false); var actionSets = UnifiedSuggestedActionsSource.FilterAndOrderActionSets( diff --git a/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs b/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs index 154fb50d1ef60..be6077f5ed3b7 100644 --- a/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs +++ b/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs @@ -76,11 +76,9 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(LSP.CodeAction request) var document = context.GetRequiredTextDocument(); var solution = document.Project.Solution; - var options = _globalOptions.GetCodeActionOptionsProvider(); var codeActions = await CodeActionHelpers.GetCodeActionsAsync( document, data.Range, - options, _codeFixService, _codeRefactoringService, fixAllScope: null, diff --git a/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs b/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs index c13a4e7e1d649..87ef08b73bbcb 100644 --- a/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs +++ b/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs @@ -54,10 +54,9 @@ public CodeActionsHandler( public async Task HandleRequestAsync(LSP.CodeActionParams request, RequestContext context, CancellationToken cancellationToken) { var document = context.GetRequiredTextDocument(); - var options = _globalOptions.GetCodeActionOptionsProvider(); var clientCapability = context.GetRequiredClientCapabilities(); var codeActions = await CodeActionHelpers.GetVSCodeActionsAsync( - request, document, options, _codeFixService, _codeRefactoringService, hasVsLspCapability: clientCapability.HasVisualStudioLspCapability(), cancellationToken).ConfigureAwait(false); + request, document, _codeFixService, _codeRefactoringService, hasVsLspCapability: clientCapability.HasVisualStudioLspCapability(), cancellationToken).ConfigureAwait(false); return codeActions; } diff --git a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpCodeCleanupFixer.cs b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpCodeCleanupFixer.cs index 07fc6cd967c95..95869ad79ed84 100644 --- a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpCodeCleanupFixer.cs +++ b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpCodeCleanupFixer.cs @@ -21,8 +21,8 @@ internal sealed class CSharpCodeCleanUpFixer : AbstractCodeCleanUpFixer { [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public CSharpCodeCleanUpFixer(IThreadingContext threadingContext, VisualStudioWorkspaceImpl workspace, IVsHierarchyItemManager vsHierarchyItemManager, IGlobalOptionService globalOptions) - : base(threadingContext, workspace, vsHierarchyItemManager, globalOptions) + public CSharpCodeCleanUpFixer(IThreadingContext threadingContext, VisualStudioWorkspaceImpl workspace, IVsHierarchyItemManager vsHierarchyItemManager) + : base(threadingContext, workspace, vsHierarchyItemManager) { } } diff --git a/src/VisualStudio/Core/Def/CodeCleanup/AbstractCodeCleanUpFixer.cs b/src/VisualStudio/Core/Def/CodeCleanup/AbstractCodeCleanUpFixer.cs index 705ad57775991..407b0d6dffce1 100644 --- a/src/VisualStudio/Core/Def/CodeCleanup/AbstractCodeCleanUpFixer.cs +++ b/src/VisualStudio/Core/Def/CodeCleanup/AbstractCodeCleanUpFixer.cs @@ -39,18 +39,15 @@ internal abstract partial class AbstractCodeCleanUpFixer : ICodeCleanUpFixer private readonly IThreadingContext _threadingContext; private readonly VisualStudioWorkspaceImpl _workspace; private readonly IVsHierarchyItemManager _vsHierarchyItemManager; - private readonly IGlobalOptionService _globalOptions; protected AbstractCodeCleanUpFixer( IThreadingContext threadingContext, VisualStudioWorkspaceImpl workspace, - IVsHierarchyItemManager vsHierarchyItemManager, - IGlobalOptionService globalOptions) + IVsHierarchyItemManager vsHierarchyItemManager) { _threadingContext = threadingContext; _workspace = workspace; _vsHierarchyItemManager = vsHierarchyItemManager; - _globalOptions = globalOptions; } public Task FixAsync(ICodeCleanUpScope scope, ICodeCleanUpExecutionContext context) @@ -71,7 +68,7 @@ private async Task FixHierarchyContentAsync(IVsHierarchyCodeCleanupScope h _workspace, // Just defer to FixProjectsAsync, passing in all fixable projects in the solution. (progress, cancellationToken) => FixProjectsAsync( - _globalOptions, solution, solution.Projects.Where(p => p.SupportsCompilation).ToImmutableArray(), context.EnabledFixIds, progress, cancellationToken), + solution, solution.Projects.Where(p => p.SupportsCompilation).ToImmutableArray(), context.EnabledFixIds, progress, cancellationToken), context).ConfigureAwait(false); } @@ -109,7 +106,7 @@ private async Task FixHierarchyContentAsync(IVsHierarchyCodeCleanupScope h _workspace, // Just defer to FixProjectsAsync, passing in this single project to fix. (progress, cancellationToken) => FixProjectsAsync( - _globalOptions, project.Solution, [project], context.EnabledFixIds, progress, cancellationToken), + project.Solution, [project], context.EnabledFixIds, progress, cancellationToken), context).ConfigureAwait(false); } else if (hierarchy.GetCanonicalName(itemId, out var path) == 0) @@ -133,13 +130,12 @@ private async Task FixHierarchyContentAsync(IVsHierarchyCodeCleanupScope h return false; var document = solution.GetRequiredDocument(documentId); - var options = _globalOptions.GetCodeActionOptions(document.Project.Services); return await FixAsync( _workspace, async (progress, cancellationToken) => { - var newDocument = await FixDocumentAsync(document, context.EnabledFixIds, progress, options, cancellationToken).ConfigureAwait(true); + var newDocument = await FixDocumentAsync(document, context.EnabledFixIds, progress, cancellationToken).ConfigureAwait(true); return newDocument.Project.Solution; }, context).ConfigureAwait(false); @@ -175,8 +171,7 @@ async Task ApplyFixAsync(IProgress progress, Can var document = buffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); Contract.ThrowIfNull(document); - var options = _globalOptions.GetCodeActionOptions(document.Project.Services); - var newDoc = await FixDocumentAsync(document, context.EnabledFixIds, progress, options, cancellationToken).ConfigureAwait(true); + var newDoc = await FixDocumentAsync(document, context.EnabledFixIds, progress, cancellationToken).ConfigureAwait(true); return newDoc.Project.Solution; } } @@ -207,7 +202,6 @@ private async Task FixAsync( } private static async Task FixProjectsAsync( - IGlobalOptionService globalOptions, Solution solution, ImmutableArray projects, FixIdContainer enabledFixIds, @@ -224,11 +218,9 @@ private static async Task FixProjectsAsync( { Contract.ThrowIfFalse(project.SupportsCompilation); - var (globalOptions, solution, enabledFixIds, progressTracker) = args; + var (solution, enabledFixIds, progressTracker) = args; cancellationToken.ThrowIfCancellationRequested(); - var ideOptions = globalOptions.GetCodeActionOptions(project.Services); - // And for each project, process all the documents in parallel. await RoslynParallel.ForEachAsync( source: project.Documents, @@ -240,14 +232,14 @@ await RoslynParallel.ForEachAsync( // FixDocumentAsync reports progress within a document, but we only want to report progress at // the document granularity. So we pass CodeAnalysisProgress.None here so that inner progress // updates don't affect us. - var fixedDocument = await FixDocumentAsync(document, enabledFixIds, CodeAnalysisProgress.None, ideOptions, cancellationToken).ConfigureAwait(false); + var fixedDocument = await FixDocumentAsync(document, enabledFixIds, CodeAnalysisProgress.None, cancellationToken).ConfigureAwait(false); if (fixedDocument == document) return; callback((document.Id, await fixedDocument.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false))); }).ConfigureAwait(false); }, - args: (globalOptions, solution, enabledFixIds, progressTracker), + args: (solution, enabledFixIds, progressTracker), cancellationToken).ConfigureAwait(false); return solution.WithDocumentSyntaxRoots(changedRoots); @@ -257,7 +249,6 @@ private static async Task FixDocumentAsync( Document document, FixIdContainer enabledFixIds, IProgress progressTracker, - CodeActionOptions ideOptions, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -270,6 +261,6 @@ private static async Task FixDocumentAsync( enabledDiagnostics = AdjustDiagnosticOptions(enabledDiagnostics, enabledFixIds.IsFixIdEnabled); return await codeCleanupService.CleanupAsync( - document, enabledDiagnostics, progressTracker, ideOptions.CreateProvider(), cancellationToken).ConfigureAwait(false); + document, enabledDiagnostics, progressTracker, cancellationToken).ConfigureAwait(false); } } diff --git a/src/VisualStudio/Core/Def/SyncNamespaces/SyncNamespacesCommandHandler.cs b/src/VisualStudio/Core/Def/SyncNamespaces/SyncNamespacesCommandHandler.cs index 05e609484355c..bbf961860df10 100644 --- a/src/VisualStudio/Core/Def/SyncNamespaces/SyncNamespacesCommandHandler.cs +++ b/src/VisualStudio/Core/Def/SyncNamespaces/SyncNamespacesCommandHandler.cs @@ -32,7 +32,6 @@ internal sealed class SyncNamespacesCommandHandler { private readonly VisualStudioWorkspace _workspace; private readonly IUIThreadOperationExecutor _threadOperationExecutor; - private readonly IGlobalOptionService _globalOptions; private readonly IThreadingContext _threadingContext; private IServiceProvider? _serviceProvider; @@ -41,12 +40,10 @@ internal sealed class SyncNamespacesCommandHandler public SyncNamespacesCommandHandler( IUIThreadOperationExecutor threadOperationExecutor, VisualStudioWorkspace workspace, - IGlobalOptionService globalOptions, IThreadingContext threadingContext) { _threadOperationExecutor = threadOperationExecutor; _workspace = workspace; - _globalOptions = globalOptions; _threadingContext = threadingContext; } @@ -134,7 +131,6 @@ private void SyncNamespaces(ImmutableArray projects) } var syncService = projects[0].GetRequiredLanguageService(); - var options = _globalOptions.GetCodeActionOptionsProvider(); Solution? solution = null; var status = _threadOperationExecutor.Execute( @@ -142,7 +138,7 @@ private void SyncNamespaces(ImmutableArray projects) operationContext => { solution = _threadingContext.JoinableTaskFactory.Run( - () => syncService.SyncNamespacesAsync(projects, options, operationContext.GetCodeAnalysisProgress(), operationContext.UserCancellationToken)); + () => syncService.SyncNamespacesAsync(projects, operationContext.GetCodeAnalysisProgress(), operationContext.UserCancellationToken)); }); if (status != UIThreadOperationStatus.Canceled && solution is not null) diff --git a/src/VisualStudio/Core/Def/TableDataSource/Suppression/VisualStudioSuppressionFixService.cs b/src/VisualStudio/Core/Def/TableDataSource/Suppression/VisualStudioSuppressionFixService.cs index b376dc5c68319..700d475b415b7 100644 --- a/src/VisualStudio/Core/Def/TableDataSource/Suppression/VisualStudioSuppressionFixService.cs +++ b/src/VisualStudio/Core/Def/TableDataSource/Suppression/VisualStudioSuppressionFixService.cs @@ -270,8 +270,6 @@ private async Task ApplySuppressionFixAsync( cancellationToken.ThrowIfCancellationRequested(); var language = languageService.Language; - var options = _globalOptions.GetCodeActionOptions(languageService); - var optionsProvider = options.CreateProvider(); var documentDiagnosticsPerLanguage = GetDocumentDiagnosticsMappedToNewSolution(documentDiagnosticsToFixMap, newSolution, language); if (!documentDiagnosticsPerLanguage.IsEmpty) @@ -285,7 +283,6 @@ private async Task ApplySuppressionFixAsync( _workspace, suppressionFixer, suppressionFixAllProvider, - optionsProvider, equivalenceKey, title, waitDialogMessage, @@ -311,7 +308,6 @@ private async Task ApplySuppressionFixAsync( _workspace, suppressionFixer, suppressionFixAllProvider, - optionsProvider, equivalenceKey, title, waitDialogMessage, diff --git a/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicCodeCleanupFixer.vb b/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicCodeCleanupFixer.vb index 8fbe39d3e6eb2..68349b1b937ba 100644 --- a/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicCodeCleanupFixer.vb +++ b/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicCodeCleanupFixer.vb @@ -21,8 +21,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.LanguageService - Public Sub New(threadingContext As IThreadingContext, workspace As VisualStudioWorkspaceImpl, vsHierarchyItemManager As IVsHierarchyItemManager, globalOptions As IGlobalOptionService) - MyBase.New(threadingContext, workspace, vsHierarchyItemManager, globalOptions) + Public Sub New(threadingContext As IThreadingContext, workspace As VisualStudioWorkspaceImpl, vsHierarchyItemManager As IVsHierarchyItemManager) + MyBase.New(threadingContext, workspace, vsHierarchyItemManager) End Sub End Class End Namespace diff --git a/src/Workspaces/Core/Portable/CodeFixes/CodeFixContext.cs b/src/Workspaces/Core/Portable/CodeFixes/CodeFixContext.cs index 1a5be65d58641..e47e746809b41 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/CodeFixContext.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/CodeFixContext.cs @@ -68,17 +68,6 @@ public Document Document /// public CancellationToken CancellationToken => _cancellationToken; - /// - /// IDE supplied options to use for settings not specified in the corresponding editorconfig file. - /// These are not available in Code Style layer. Use extension method - /// to access these options in code shared with Code Style layer. - /// - /// - /// This is a (rather than directly) - /// to allow code fix to update documents across multiple projects that differ in language (and hence language specific options). - /// - internal readonly CodeActionOptionsProvider Options; - /// /// Creates a code fix context to be passed into method. /// @@ -103,11 +92,10 @@ public CodeFixContext( ImmutableArray diagnostics, Action> registerCodeFix, CancellationToken cancellationToken) - : this(document, + : this((TextDocument)document, span, diagnostics, registerCodeFix, - CodeActionOptions.DefaultProvider, cancellationToken) { } @@ -135,13 +123,14 @@ public CodeFixContext( ImmutableArray diagnostics, Action> registerCodeFix, CancellationToken cancellationToken) - : this(document, - span, - diagnostics, - registerCodeFix, - CodeActionOptions.DefaultProvider, - cancellationToken) { + VerifyDiagnosticsArgument(diagnostics, span); + + _document = document ?? throw new ArgumentNullException(nameof(document)); + _span = span; + _diagnostics = diagnostics; + _registerCodeFix = registerCodeFix ?? throw new ArgumentNullException(nameof(registerCodeFix)); + _cancellationToken = cancellationToken; } /// @@ -165,7 +154,6 @@ public CodeFixContext( (diagnostic ?? throw new ArgumentNullException(nameof(diagnostic))).Location.SourceSpan, [diagnostic], registerCodeFix, - CodeActionOptions.DefaultProvider, cancellationToken) { } @@ -190,29 +178,10 @@ public CodeFixContext( (diagnostic ?? throw new ArgumentNullException(nameof(diagnostic))).Location.SourceSpan, [diagnostic], registerCodeFix, - CodeActionOptions.DefaultProvider, cancellationToken) { } - internal CodeFixContext( - TextDocument document, - TextSpan span, - ImmutableArray diagnostics, - Action> registerCodeFix, - CodeActionOptionsProvider options, - CancellationToken cancellationToken) - { - VerifyDiagnosticsArgument(diagnostics, span); - - _document = document ?? throw new ArgumentNullException(nameof(document)); - _span = span; - _diagnostics = diagnostics; - _registerCodeFix = registerCodeFix ?? throw new ArgumentNullException(nameof(registerCodeFix)); - Options = options; - _cancellationToken = cancellationToken; - } - /// /// Add supplied to the list of fixes that will be offered to the user. /// diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs index 2ab4e712c68eb..757b2fac65e17 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs @@ -153,7 +153,7 @@ private static async Task> GetAllChangedDocumentsInDiag // Create a context that will add the reported code actions into this using var _2 = ArrayBuilder.GetInstance(out var codeActions); var action = GetRegisterCodeFixAction(fixAllContext.CodeActionEquivalenceKey, codeActions); - var context = new CodeFixContext(document, diagnostic.Location.SourceSpan, [diagnostic], action, fixAllContext.State.CodeActionOptionsProvider, cancellationToken); + var context = new CodeFixContext(document, diagnostic.Location.SourceSpan, [diagnostic], action, cancellationToken); // Wait for the all the code actions to be reported for this diagnostic. var registerTask = fixAllContext.CodeFixProvider.RegisterCodeFixesAsync(context) ?? Task.CompletedTask; diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.cs index af773f09721a4..fe17d090ba470 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.cs @@ -164,8 +164,7 @@ public FixAllContext( scope, codeActionEquivalenceKey, PublicContract.RequireNonNullItems(diagnosticIds, nameof(diagnosticIds)), - fixAllDiagnosticProvider ?? throw new ArgumentNullException(nameof(fixAllDiagnosticProvider)), - CodeActionOptions.DefaultProvider), + fixAllDiagnosticProvider ?? throw new ArgumentNullException(nameof(fixAllDiagnosticProvider))), CodeAnalysisProgress.None, cancellationToken) { } @@ -200,8 +199,7 @@ public FixAllContext( scope, codeActionEquivalenceKey, PublicContract.RequireNonNullItems(diagnosticIds, nameof(diagnosticIds)), - fixAllDiagnosticProvider ?? throw new ArgumentNullException(nameof(fixAllDiagnosticProvider)), - CodeActionOptions.DefaultProvider), + fixAllDiagnosticProvider ?? throw new ArgumentNullException(nameof(fixAllDiagnosticProvider))), CodeAnalysisProgress.None, cancellationToken) { if (scope is FixAllScope.ContainingMember or FixAllScope.ContainingType) diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs index 5b5b0ab65977d..3239e0cee06e1 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs @@ -33,9 +33,8 @@ internal FixAllState( FixAllScope scope, string? codeActionEquivalenceKey, IEnumerable diagnosticIds, - FixAllContext.DiagnosticProvider fixAllDiagnosticProvider, - CodeActionOptionsProvider codeActionOptionsProvider) - : base(fixAllProvider, document, project, codeFixProvider, codeActionOptionsProvider, scope, codeActionEquivalenceKey) + FixAllContext.DiagnosticProvider fixAllDiagnosticProvider) + : base(fixAllProvider, document, project, codeFixProvider, scope, codeActionEquivalenceKey) { // We need the trigger diagnostic span for span based fix all scopes, i.e. FixAllScope.ContainingMember and FixAllScope.ContainingType Debug.Assert(diagnosticSpan.HasValue || scope is not FixAllScope.ContainingMember or FixAllScope.ContainingType); @@ -57,8 +56,7 @@ protected override FixAllState With(Document? document, Project project, FixAllS scope, codeActionEquivalenceKey, DiagnosticIds, - DiagnosticProvider, - CodeActionOptionsProvider); + DiagnosticProvider); #region FixMultiple @@ -66,8 +64,7 @@ internal static FixAllState Create( FixAllProvider fixAllProvider, ImmutableDictionary> diagnosticsToFix, CodeFixProvider codeFixProvider, - string? codeActionEquivalenceKey, - CodeActionOptionsProvider codeActionOptionsProvider) + string? codeActionEquivalenceKey) { var triggerDocument = diagnosticsToFix.First().Key; var diagnosticSpan = diagnosticsToFix.First().Value.FirstOrDefault()?.Location.SourceSpan; @@ -82,16 +79,14 @@ internal static FixAllState Create( FixAllScope.Custom, codeActionEquivalenceKey, diagnosticIds, - diagnosticProvider, - codeActionOptionsProvider); + diagnosticProvider); } internal static FixAllState Create( FixAllProvider fixAllProvider, ImmutableDictionary> diagnosticsToFix, CodeFixProvider codeFixProvider, - string? codeActionEquivalenceKey, - CodeActionOptionsProvider codeActionOptionsProvider) + string? codeActionEquivalenceKey) { var triggerProject = diagnosticsToFix.First().Key; var diagnosticIds = GetDiagnosticsIds(diagnosticsToFix.Values); @@ -105,8 +100,7 @@ internal static FixAllState Create( FixAllScope.Custom, codeActionEquivalenceKey, diagnosticIds, - diagnosticProvider, - codeActionOptionsProvider); + diagnosticProvider); } private static ImmutableHashSet GetDiagnosticsIds(IEnumerable> diagnosticsCollection) diff --git a/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/CommonFixAllState.cs b/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/CommonFixAllState.cs index eacf8559e2b03..7681dc9c307e9 100644 --- a/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/CommonFixAllState.cs +++ b/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/CommonFixAllState.cs @@ -22,14 +22,12 @@ internal abstract partial class CommonFixAllState Project.Solution; public FixAllScope Scope { get; } public abstract FixAllKind FixAllKind { get; } - public CodeActionOptionsProvider CodeActionOptionsProvider { get; } protected CommonFixAllState( TFixAllProvider fixAllProvider, Document? document, Project project, TProvider provider, - CodeActionOptionsProvider optionsProvider, FixAllScope scope, string? codeActionEquivalenceKey) { @@ -39,7 +37,6 @@ protected CommonFixAllState( Document = document; Project = project; Provider = provider; - CodeActionOptionsProvider = optionsProvider; Scope = scope; CodeActionEquivalenceKey = codeActionEquivalenceKey; } diff --git a/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/IFixAllState.cs b/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/IFixAllState.cs index 9d9591ddf69e5..66083f1d4ac32 100644 --- a/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/IFixAllState.cs +++ b/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/IFixAllState.cs @@ -26,8 +26,6 @@ internal interface IFixAllState /// object Provider { get; } - CodeActionOptionsProvider CodeActionOptionsProvider { get; } - IFixAllState With( Optional<(Document? document, Project project)> documentAndProject = default, Optional scope = default, diff --git a/src/Workspaces/Core/Portable/CodeRefactorings/CodeRefactoringContext.cs b/src/Workspaces/Core/Portable/CodeRefactorings/CodeRefactoringContext.cs index 8b4f1ce55f3da..87f7d13d753d4 100644 --- a/src/Workspaces/Core/Portable/CodeRefactorings/CodeRefactoringContext.cs +++ b/src/Workspaces/Core/Portable/CodeRefactorings/CodeRefactoringContext.cs @@ -53,8 +53,6 @@ public Document Document /// public CancellationToken CancellationToken { get; } - internal readonly CodeActionOptionsProvider Options; - private readonly Action _registerRefactoring; /// @@ -66,7 +64,7 @@ public CodeRefactoringContext( TextSpan span, Action registerRefactoring, CancellationToken cancellationToken) - : this(document, span, (action, textSpan) => registerRefactoring(action), CodeActionOptions.DefaultProvider, cancellationToken) + : this(document, span, (action, textSpan) => registerRefactoring(action), cancellationToken) { } /// @@ -77,7 +75,7 @@ public CodeRefactoringContext( TextSpan span, Action registerRefactoring, CancellationToken cancellationToken) - : this(document, span, (action, textSpan) => registerRefactoring(action), CodeActionOptions.DefaultProvider, cancellationToken) + : this(document, span, (action, textSpan) => registerRefactoring(action), cancellationToken) { } /// @@ -87,7 +85,6 @@ internal CodeRefactoringContext( TextDocument document, TextSpan span, Action registerRefactoring, - CodeActionOptionsProvider options, CancellationToken cancellationToken) { // NOTE/TODO: Don't make this overload public & obsolete the `Action registerRefactoring` @@ -95,7 +92,6 @@ internal CodeRefactoringContext( TextDocument = document ?? throw new ArgumentNullException(nameof(document)); Span = span; _registerRefactoring = registerRefactoring ?? throw new ArgumentNullException(nameof(registerRefactoring)); - Options = options; CancellationToken = cancellationToken; } diff --git a/src/Workspaces/Core/Portable/CodeRefactorings/FixAllOccurences/FixAllState.cs b/src/Workspaces/Core/Portable/CodeRefactorings/FixAllOccurences/FixAllState.cs index b4f7f3c5fe8bc..c100f75be9641 100644 --- a/src/Workspaces/Core/Portable/CodeRefactorings/FixAllOccurences/FixAllState.cs +++ b/src/Workspaces/Core/Portable/CodeRefactorings/FixAllOccurences/FixAllState.cs @@ -36,11 +36,10 @@ public FixAllState( Document document, TextSpan selectionSpan, CodeRefactoringProvider codeRefactoringProvider, - CodeActionOptionsProvider optionsProvider, FixAllScope fixAllScope, CodeAction codeAction) : this(fixAllProvider, document ?? throw new ArgumentNullException(nameof(document)), document.Project, selectionSpan, codeRefactoringProvider, - optionsProvider, fixAllScope, codeAction.Title, codeAction.EquivalenceKey) + fixAllScope, codeAction.Title, codeAction.EquivalenceKey) { } @@ -49,11 +48,10 @@ public FixAllState( Project project, TextSpan selectionSpan, CodeRefactoringProvider codeRefactoringProvider, - CodeActionOptionsProvider optionsProvider, FixAllScope fixAllScope, CodeAction codeAction) : this(fixAllProvider, document: null, project ?? throw new ArgumentNullException(nameof(project)), selectionSpan, codeRefactoringProvider, - optionsProvider, fixAllScope, codeAction.Title, codeAction.EquivalenceKey) + fixAllScope, codeAction.Title, codeAction.EquivalenceKey) { } @@ -63,11 +61,10 @@ private FixAllState( Project project, TextSpan selectionSpan, CodeRefactoringProvider codeRefactoringProvider, - CodeActionOptionsProvider optionsProvider, FixAllScope fixAllScope, string codeActionTitle, string? codeActionEquivalenceKey) - : base(fixAllProvider, document, project, codeRefactoringProvider, optionsProvider, fixAllScope, codeActionEquivalenceKey) + : base(fixAllProvider, document, project, codeRefactoringProvider, fixAllScope, codeActionEquivalenceKey) { _selectionSpan = selectionSpan; this.CodeActionTitle = codeActionTitle; @@ -81,7 +78,6 @@ protected override FixAllState With(Document? document, Project project, FixAllS project, _selectionSpan, this.Provider, - this.CodeActionOptionsProvider, scope, this.CodeActionTitle, codeActionEquivalenceKey); diff --git a/src/Workspaces/Core/Portable/CodeRefactorings/SyntaxEditorBasedCodeRefactoringProvider.cs b/src/Workspaces/Core/Portable/CodeRefactorings/SyntaxEditorBasedCodeRefactoringProvider.cs index 07905dc7e269f..3064aa9009685 100644 --- a/src/Workspaces/Core/Portable/CodeRefactorings/SyntaxEditorBasedCodeRefactoringProvider.cs +++ b/src/Workspaces/Core/Portable/CodeRefactorings/SyntaxEditorBasedCodeRefactoringProvider.cs @@ -29,7 +29,7 @@ internal abstract partial class SyntaxEditorBasedCodeRefactoringProvider : CodeR return FixAllProvider.Create( async (fixAllContext, document, fixAllSpans) => { - return await this.FixAllAsync(document, fixAllSpans, fixAllContext.GetOptionsProvider(), fixAllContext.CodeActionEquivalenceKey, fixAllContext.CancellationToken).ConfigureAwait(false); + return await this.FixAllAsync(document, fixAllSpans, fixAllContext.CodeActionEquivalenceKey, fixAllContext.CancellationToken).ConfigureAwait(false); }, SupportedFixAllScopes); } @@ -37,19 +37,17 @@ internal abstract partial class SyntaxEditorBasedCodeRefactoringProvider : CodeR protected Task FixAsync( Document document, TextSpan fixAllSpan, - CodeActionOptionsProvider optionsProvider, string? equivalenceKey, CancellationToken cancellationToken) { return FixAllWithEditorAsync(document, - editor => FixAllAsync(document, [fixAllSpan], editor, optionsProvider, equivalenceKey, cancellationToken), + editor => FixAllAsync(document, [fixAllSpan], editor, equivalenceKey, cancellationToken), cancellationToken); } protected Task FixAllAsync( Document document, Optional> fixAllSpans, - CodeActionOptionsProvider optionsProvider, string? equivalenceKey, CancellationToken cancellationToken) { @@ -60,7 +58,7 @@ Task FixAllAsync(SyntaxEditor editor) { // Fix the entire document if there are no sub-spans to fix. var spans = fixAllSpans.HasValue ? fixAllSpans.Value : [editor.OriginalRoot.FullSpan]; - return this.FixAllAsync(document, spans, editor, optionsProvider, equivalenceKey, cancellationToken); + return this.FixAllAsync(document, spans, editor, equivalenceKey, cancellationToken); } } @@ -82,7 +80,6 @@ protected abstract Task FixAllAsync( Document document, ImmutableArray fixAllSpans, SyntaxEditor editor, - CodeActionOptionsProvider optionsProvider, string? equivalenceKey, CancellationToken cancellationToken); } diff --git a/src/Workspaces/CoreTest/Remote/ServiceDescriptorTests.cs b/src/Workspaces/CoreTest/Remote/ServiceDescriptorTests.cs index 1b771b5110037..f67ab44a54236 100644 --- a/src/Workspaces/CoreTest/Remote/ServiceDescriptorTests.cs +++ b/src/Workspaces/CoreTest/Remote/ServiceDescriptorTests.cs @@ -235,7 +235,6 @@ public void OptionsAreMessagePackSerializable(string language) SyntaxFormattingOptions.GetDefault(languageServices), CodeCleanupOptions.GetDefault(languageServices), CodeGenerationOptions.GetDefault(languageServices), - CodeActionOptions.Default, IndentationOptions.GetDefault(languageServices), ExtractMethodGenerationOptions.GetDefault(languageServices), diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeActionOptions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeActionOptions.cs deleted file mode 100644 index 74d482117181b..0000000000000 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeActionOptions.cs +++ /dev/null @@ -1,59 +0,0 @@ -// 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.Runtime.Serialization; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CodeFixesAndRefactorings; -using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.SymbolSearch; - -namespace Microsoft.CodeAnalysis.CodeActions; - -/// -/// Options available to code fixes that are supplied by the IDE (i.e. not stored in editorconfig). -/// -[DataContract] -internal sealed record class CodeActionOptions -{ - public static readonly CodeActionOptions Default = new(); - public static readonly CodeActionOptionsProvider DefaultProvider = Default.CreateProvider(); - - public CodeActionOptionsProvider CreateProvider() - => new DelegatingCodeActionOptionsProvider(_ => this); -} - -internal interface CodeActionOptionsProvider -{ - CodeActionOptions GetOptions(LanguageServices languageService); -} - -internal abstract class AbstractCodeActionOptionsProvider : CodeActionOptionsProvider -{ - public abstract CodeActionOptions GetOptions(LanguageServices languageServices); -} - -internal sealed class DelegatingCodeActionOptionsProvider(Func @delegate) : AbstractCodeActionOptionsProvider -{ - public override CodeActionOptions GetOptions(LanguageServices languageService) - => @delegate(languageService); -} - -internal static class CodeActionOptionsProviders -{ - internal static CodeActionOptionsProvider GetOptionsProvider(this CodeFixContext context) -#if CODE_STYLE - => CodeActionOptions.DefaultProvider; -#else - => context.Options; -#endif - -#if CODE_STYLE - internal static CodeActionOptionsProvider GetOptionsProvider(this FixAllContext _) - => CodeActionOptions.DefaultProvider; -#else - internal static CodeActionOptionsProvider GetOptionsProvider(this IFixAllContext context) - => context.State.CodeActionOptionsProvider; -#endif -} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems index c99af6a5983c7..9da175ee39a6b 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems @@ -14,7 +14,6 @@ - From 1a62060eca3fd602ff6475bfae3d57ec48e1430d Mon Sep 17 00:00:00 2001 From: Tomas Matousek Date: Tue, 16 Jul 2024 14:07:40 -0700 Subject: [PATCH 3/4] Make dotnet_search_reference_assemblies supported, it's used in VS Code --- src/Features/Core/Portable/FeaturesResources.resx | 3 +++ .../Options/EditorConfig/EditorConfigOptionsEnumerator.cs | 3 ++- .../Core/Portable/SymbolSearch/SymbolSearchOptions.cs | 7 ++++--- src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.de.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.es.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.it.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf | 5 +++++ src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf | 5 +++++ .../Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 5 +++++ .../Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 5 +++++ .../Core/Def/Options/VisualStudioOptionStorage.cs | 2 +- .../Core/Test/Options/CSharpEditorConfigGeneratorTests.vb | 6 ++++++ 18 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index f892d1bed8689..2a56f3ef0c777 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -3270,4 +3270,7 @@ Zero-width positive lookbehind assertions are typically used at the beginning of .NET Code Actions + + Symbol search + \ No newline at end of file diff --git a/src/Features/Core/Portable/Options/EditorConfig/EditorConfigOptionsEnumerator.cs b/src/Features/Core/Portable/Options/EditorConfig/EditorConfigOptionsEnumerator.cs index 22a9096d06c19..9a6cc0a29b86b 100644 --- a/src/Features/Core/Portable/Options/EditorConfig/EditorConfigOptionsEnumerator.cs +++ b/src/Features/Core/Portable/Options/EditorConfig/EditorConfigOptionsEnumerator.cs @@ -47,7 +47,8 @@ internal sealed class EditorConfigOptionsEnumerator( yield return (FeaturesResources.NET_Code_Actions, [ .. ImplementTypeOptionsStorage.EditorConfigOptions, - .. MemberDisplayOptionsStorage.EditorConfigOptions + .. MemberDisplayOptionsStorage.EditorConfigOptions, + .. SymbolSearchOptionsStorage.EditorConfigOptions, ]); yield return (WorkspacesResources.dot_NET_Coding_Conventions, diff --git a/src/Features/Core/Portable/SymbolSearch/SymbolSearchOptions.cs b/src/Features/Core/Portable/SymbolSearch/SymbolSearchOptions.cs index 25697735b5da9..5d9e25068de4e 100644 --- a/src/Features/Core/Portable/SymbolSearch/SymbolSearchOptions.cs +++ b/src/Features/Core/Portable/SymbolSearch/SymbolSearchOptions.cs @@ -24,10 +24,10 @@ internal readonly record struct SymbolSearchOptions() internal static class SymbolSearchOptionsStorage { - private static readonly OptionGroup s_optionGroup = new(name: "symbol_search", description: ""); + private static readonly OptionGroup s_optionGroup = new(name: "symbol_search", description: FeaturesResources.Symbol_search); public static PerLanguageOption2 SearchReferenceAssemblies = new( - "dotnet_unsupported_search_reference_assemblies", + "dotnet_search_reference_assemblies", SymbolSearchOptions.Default.SearchReferenceAssemblies, isEditorConfigOption: true, group: s_optionGroup); @@ -38,7 +38,8 @@ internal static class SymbolSearchOptionsStorage isEditorConfigOption: true, group: s_optionGroup); - public static readonly ImmutableArray UnsupportedOptions = [SearchReferenceAssemblies, SearchNuGetPackages]; + public static readonly ImmutableArray EditorConfigOptions = [SearchReferenceAssemblies]; + public static readonly ImmutableArray UnsupportedOptions = [SearchNuGetPackages]; } internal static class SymbolSearchOptionsProviders diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index 80b2136a163bb..8de55574a34a4 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -2725,6 +2725,11 @@ Pozitivní kontrolní výrazy zpětného vyhledávání s nulovou délkou se obv V cestě sestavení {0} byl nalezen symbol. + + Symbol search + Symbol search + + Symbols Symboly diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 3e9ed612bd629..0134ce9b7884e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -2725,6 +2725,11 @@ Positive Lookbehindassertionen mit Nullbreite werden normalerweise am Anfang reg Das Symbol wurde unter dem Assemblypfad „{0}“ gefunden + + Symbol search + Symbol search + + Symbols Symbole diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index 076317affdb1a..12763b22e7fac 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -2725,6 +2725,11 @@ Las aserciones de búsqueda retrasada (lookbehind) positivas de ancho cero se us Símbolo encontrado en la ruta de acceso del ensamblado '{0}' + + Symbol search + Symbol search + + Symbols Símbolos diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 63d7c23de2a9d..493dab8aadc7e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -2725,6 +2725,11 @@ Les assertions arrière positives de largeur nulle sont généralement utilisée Symbole trouvé dans le chemin d’accès de l’assembly '{0}' + + Symbol search + Symbol search + + Symbols Symboles diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index 99110700674ac..8dc9d8ee14cde 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -2725,6 +2725,11 @@ Le asserzioni lookbehind positive di larghezza zero vengono usate in genere all' Simbolo trovato nel percorso assembly '{0}' + + Symbol search + Symbol search + + Symbols Simboli diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index be4d32f6ba45f..419e7002402cd 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -2725,6 +2725,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of アセンブリ パス '{0}' にシンボルが見つかりました + + Symbol search + Symbol search + + Symbols シンボル diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 5dc90d79ad7b2..2dfaf29cfbb79 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -2725,6 +2725,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 어셈블리 경로 '{0}'에서 기호를 찾음 + + Symbol search + Symbol search + + Symbols 기호 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 8eab32df69692..c4079c2570689 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -2725,6 +2725,11 @@ Pozytywne asercje wsteczne o zerowej szerokości są zwykle używane na początk Znaleziono symbol w ścieżce zestawu „{0}” + + Symbol search + Symbol search + + Symbols Symbole diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index 4c59a203b786e..b092679b8ac85 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -2725,6 +2725,11 @@ As declarações de lookbehind positivas de largura zero normalmente são usadas Símbolo encontrado no caminho de montagem '{0}' + + Symbol search + Symbol search + + Symbols Símbolos diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index e18ca3476aca1..1dbe5acb553b3 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -2725,6 +2725,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Найден символ в пути сборки "{0}" + + Symbol search + Symbol search + + Symbols Символы diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index 2d2ed5ed366e8..ffd2f5a6894e9 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -2725,6 +2725,11 @@ Sıfır genişlikli pozitif geri yönlü onaylamalar genellikle normal ifadeleri “{0}” derleme yolunda sembol bulundu + + Symbol search + Symbol search + + Symbols Semboller diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index c03a012df542b..0b454746e0186 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -2725,6 +2725,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 在程序集路径 "{0}" 中找到符号 + + Symbol search + Symbol search + + Symbols 符号 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index 9dec3caef3487..74a134341b268 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -2725,6 +2725,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 在組件路徑 '{0}' 中找到符號 + + Symbol search + Symbol search + + Symbols 符號 diff --git a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs index 41e6c705ee9f8..1d2a5bc7ac25b 100644 --- a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs +++ b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs @@ -406,7 +406,7 @@ public bool TryFetch(LocalUserRegistryOptionPersister persister, OptionKey2 opti {"visual_studio_document_outline_sort_order", new RoamingProfileStorage(@"DocumentOutline.SortOrder")}, {"visual_studio_enable_symbol_search", new LocalUserProfileStorage(@"Roslyn\Features\SymbolSearch", "Enabled")}, {"dotnet_unsupported_search_nuget_packages", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInNuGetPackages")}, - {"dotnet_unsupported_search_reference_assemblies", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInReferenceAssemblies")}, + {"dotnet_search_reference_assemblies", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInReferenceAssemblies")}, #pragma warning disable CS0612 // Type or member is obsolete {"tab_width", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Tab Size", "TextEditor.Basic.Tab Size")}, #pragma warning restore diff --git a/src/VisualStudio/Core/Test/Options/CSharpEditorConfigGeneratorTests.vb b/src/VisualStudio/Core/Test/Options/CSharpEditorConfigGeneratorTests.vb index 6162a1350730b..e3be0cb90efd8 100644 --- a/src/VisualStudio/Core/Test/Options/CSharpEditorConfigGeneratorTests.vb +++ b/src/VisualStudio/Core/Test/Options/CSharpEditorConfigGeneratorTests.vb @@ -41,6 +41,9 @@ dotnet_hide_advanced_members = false dotnet_member_insertion_location = with_other_members_of_the_same_kind dotnet_property_generation_behavior = prefer_throwing_properties +# Symbol search +dotnet_search_reference_assemblies = true + #### .NET Coding Conventions #### # Organize usings @@ -297,6 +300,9 @@ dotnet_hide_advanced_members = false dotnet_member_insertion_location = with_other_members_of_the_same_kind dotnet_property_generation_behavior = prefer_throwing_properties +# Symbol search +dotnet_search_reference_assemblies = true + #### .NET Coding Conventions #### # Organize usings From 553be8289c769239a7ff17e3f00b8a578a2565c3 Mon Sep 17 00:00:00 2001 From: Tomas Matousek Date: Tue, 16 Jul 2024 16:01:43 -0700 Subject: [PATCH 4/4] FIx --- .../Core/Test/Options/BasicEditorConfigGeneratorTests.vb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/VisualStudio/Core/Test/Options/BasicEditorConfigGeneratorTests.vb b/src/VisualStudio/Core/Test/Options/BasicEditorConfigGeneratorTests.vb index d90125d210f88..33c67f60f3bd7 100644 --- a/src/VisualStudio/Core/Test/Options/BasicEditorConfigGeneratorTests.vb +++ b/src/VisualStudio/Core/Test/Options/BasicEditorConfigGeneratorTests.vb @@ -43,6 +43,9 @@ dotnet_hide_advanced_members = false dotnet_member_insertion_location = with_other_members_of_the_same_kind dotnet_property_generation_behavior = prefer_throwing_properties +# Symbol search +dotnet_search_reference_assemblies = true + #### .NET Coding Conventions #### # Organize usings @@ -193,6 +196,9 @@ dotnet_hide_advanced_members = false dotnet_member_insertion_location = with_other_members_of_the_same_kind dotnet_property_generation_behavior = prefer_throwing_properties +# Symbol search +dotnet_search_reference_assemblies = true + #### .NET Coding Conventions #### # Organize usings