From fea946693e60888e438819e6ea8ddb2e7d65dc00 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Thu, 19 Oct 2023 13:43:22 +1100 Subject: [PATCH] Remove unused symbol rename code --- spelling.dic | 1 + .../ProjectSystem/VS/IRoslynServices.cs | 2 -- .../ProjectSystem/VS/RoslynServices.cs | 7 ------- .../ProjectSystem/VS/Rename/CSharp/RenamerTests.cs | 6 ------ .../ProjectSystem/VS/Rename/VisualBasic/RenamerTests.cs | 5 ----- 5 files changed, 1 insertion(+), 20 deletions(-) diff --git a/spelling.dic b/spelling.dic index 884734bfea9..cbf4088ac5b 100644 --- a/spelling.dic +++ b/spelling.dic @@ -50,6 +50,7 @@ projectsystem projitems readonly referencesource +renamer resw resx rgdw diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/IRoslynServices.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/IRoslynServices.cs index ca4207bbc67..bccf56ca244 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/IRoslynServices.cs +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/IRoslynServices.cs @@ -7,8 +7,6 @@ namespace Microsoft.VisualStudio.ProjectSystem.VS [ProjectSystemContract(ProjectSystemContractScope.UnconfiguredProject, ProjectSystemContractProvider.Private, Cardinality = ImportCardinality.ExactlyOne)] internal interface IRoslynServices { - Task RenameSymbolAsync(Solution solution, ISymbol symbol, string newName, CancellationToken token = default); - bool ApplyChangesToSolution(Workspace ws, Solution renamedSolution); bool IsValidIdentifier(string identifierName); diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/RoslynServices.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/RoslynServices.cs index 64483812bcf..38c6b635014 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/RoslynServices.cs +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/RoslynServices.cs @@ -1,7 +1,6 @@ // 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.md file in the project root for more information. using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Rename; using Microsoft.VisualStudio.ProjectSystem.LanguageServices; using Workspace = Microsoft.CodeAnalysis.Workspace; @@ -11,7 +10,6 @@ namespace Microsoft.VisualStudio.ProjectSystem.VS [Export(typeof(IRoslynServices))] internal class RoslynServices : IRoslynServices { - private static readonly SymbolRenameOptions s_renameOptions = new(); private readonly IProjectThreadingService _threadingService; [ImportingConstructor] @@ -28,11 +26,6 @@ public RoslynServices( private ISyntaxFactsService? SyntaxFactsService => SyntaxFactsServicesImpl.FirstOrDefault()?.Value; - public Task RenameSymbolAsync(Solution solution, ISymbol symbol, string newName, CancellationToken token = default) - { - return Renamer.RenameSymbolAsync(solution, symbol, s_renameOptions, newName, token); - } - public bool ApplyChangesToSolution(Workspace ws, Solution renamedSolution) { _threadingService.VerifyOnUIThread(); diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Rename/CSharp/RenamerTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Rename/CSharp/RenamerTests.cs index 3333ac30da7..0036bed828b 100644 --- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Rename/CSharp/RenamerTests.cs +++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Rename/CSharp/RenamerTests.cs @@ -30,7 +30,6 @@ public async Task Rename_Symbol_Should_TriggerUserConfirmationAsync(string sourc bool checkBoxSelection; Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny(), out checkBoxSelection), Times.Once); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); } [Theory] @@ -52,7 +51,6 @@ public async Task Rename_Symbol_ShouldNot_TriggerUserConfirmationAsync(string so bool checkBoxSelection; Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny(), out checkBoxSelection), Times.Never); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); } [Theory] @@ -77,7 +75,6 @@ public async Task Rename_Symbol_Should_Not_HappenAsync(string sourceCode, string await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineServices, LanguageNames.CSharp, settingsManagerService).TimeoutAfter(TimeSpan.FromSeconds(1)); Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny()), Times.Never); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny(), It.IsAny()), Times.Never); } @@ -96,7 +93,6 @@ public async Task Rename_Symbol_Should_ExitEarlyInVSOnlineAsync() await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineService, LanguageNames.CSharp, settingsManagerService); Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny()), Times.Never); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny(), It.IsAny()), Times.Never); } @@ -116,7 +112,6 @@ public async Task Rename_Symbol_Should_ExitEarlyInFileExtensionChange(string old await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineService, LanguageNames.CSharp, settingsManagerService); bool disablePromptMessage; Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny(), out disablePromptMessage), Times.Never); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny(), It.IsAny()), Times.Never); } @@ -135,7 +130,6 @@ public async Task Rename_Symbol_Should_ExitEarlyWhenFileDoesntChangeName() await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineService, LanguageNames.CSharp, settingsManagerService); bool disablePromptMessage; Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny(), out disablePromptMessage), Times.Never); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny(), It.IsAny()), Times.Never); } diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Rename/VisualBasic/RenamerTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Rename/VisualBasic/RenamerTests.cs index 192433803c5..3f8955a5433 100644 --- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Rename/VisualBasic/RenamerTests.cs +++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Rename/VisualBasic/RenamerTests.cs @@ -99,7 +99,6 @@ public async Task Rename_Symbol_Should_Not_HappenAsync(string oldFilePath, strin await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineServices, LanguageNames.VisualBasic, settingsManagerService); Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny()), Times.Never); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny(), It.IsAny()), Times.Never); } @@ -162,7 +161,6 @@ public async Task Rename_Symbol_Should_TriggerUserConfirmationAsync(string oldFi bool checkBoxSelection; Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny(), out checkBoxSelection), Times.Once); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -184,7 +182,6 @@ End Class await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineService, LanguageNames.VisualBasic, settingsManagerService); Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny()), Times.Never); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny(), It.IsAny()), Times.Never); } @@ -207,7 +204,6 @@ End Class await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineService, LanguageNames.VisualBasic, settingsManagerService); bool disablePromptMessage; Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny(), out disablePromptMessage), Times.Never); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny(), It.IsAny()), Times.Never); } @@ -230,7 +226,6 @@ End Class await RenameAsync(sourceCode, oldFilePath, newFilePath, userNotificationServices, roslynServices, vsOnlineService, LanguageNames.VisualBasic, settingsManagerService); bool disablePromptMessage; Mock.Get(userNotificationServices).Verify(h => h.Confirm(It.IsAny(), out disablePromptMessage), Times.Never); - Mock.Get(roslynServices).Verify(h => h.RenameSymbolAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); Mock.Get(roslynServices).Verify(h => h.ApplyChangesToSolution(It.IsAny(), It.IsAny()), Times.Never); }