Skip to content

Commit bbe7b4f

Browse files
committed
Replaces the use of the deprecated overload for RenameDocumentAsync.
1 parent 638438f commit bbe7b4f

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Rename/FileMoveNotificationListener.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace Microsoft.VisualStudio.ProjectSystem.VS.Rename
1717
[AppliesTo(ProjectCapability.CSharpOrVisualBasicLanguageService)]
1818
internal class FileMoveNotificationListener : IFileMoveNotificationListener
1919
{
20+
private static readonly DocumentRenameOptions s_renameOptions = new();
21+
2022
private readonly UnconfiguredProject _unconfiguredProject;
2123
private readonly IUserNotificationServices _userNotificationServices;
2224
private readonly IUnconfiguredProjectVsServices _projectVsServices;
@@ -136,10 +138,7 @@ void RecursiveTryGetFilesToMove(IFileMoveItem? item, ref List<(string file, stri
136138
}
137139

138140
// This is a file item to another directory, it should only detect this a Update Namespace action.
139-
// TODO Upgrade this api to get rid of the exclamation sign
140-
#pragma warning disable CS0618 // Type or member is obsolete https://github.com/dotnet/project-system/issues/8591
141-
Renamer.RenameDocumentActionSet documentAction = await Renamer.RenameDocumentAsync(oldDocument, null!, documentFolders);
142-
#pragma warning restore CS0618 // Type or member is obsolete
141+
Renamer.RenameDocumentActionSet documentAction = await Renamer.RenameDocumentAsync(oldDocument, s_renameOptions, null, documentFolders);
143142

144143
if (documentAction.ApplicableActions.IsEmpty ||
145144
documentAction.ApplicableActions.Any(a => !a.GetErrors().IsEmpty))

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Rename/RenamerProjectTreeActionHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ namespace Microsoft.VisualStudio.ProjectSystem.VS.Rename
2020
[AppliesTo(ProjectCapability.CSharpOrVisualBasicLanguageService)]
2121
internal partial class RenamerProjectTreeActionHandler : ProjectTreeActionHandlerBase
2222
{
23+
private static readonly DocumentRenameOptions s_renameOptions = new();
24+
2325
private readonly IEnvironmentOptions _environmentOptions;
2426
private readonly IUnconfiguredProjectVsServices _projectVsServices;
2527
private readonly IProjectThreadingService _threadingService;
@@ -166,9 +168,7 @@ private async Task<Solution> PublishLatestSolutionAsync(CancellationToken cancel
166168
}
167169

168170
// Get the list of possible actions to execute
169-
#pragma warning disable CS0618 // Type or member is obsolete https://github.com/dotnet/project-system/issues/8591
170-
Renamer.RenameDocumentActionSet documentRenameResult = await Renamer.RenameDocumentAsync(oldDocument, newFileWithExtension);
171-
#pragma warning restore CS0618 // Type or member is obsolete
171+
Renamer.RenameDocumentActionSet documentRenameResult = await Renamer.RenameDocumentAsync(oldDocument, s_renameOptions, newFileWithExtension);
172172

173173
// Check if there are any symbols that need to be renamed
174174
if (documentRenameResult.ApplicableActions.IsEmpty)

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/RoslynServices.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
// 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.
22

33
using Microsoft.CodeAnalysis;
4+
using Microsoft.CodeAnalysis.Rename;
45
using Microsoft.VisualStudio.ProjectSystem.LanguageServices;
56

6-
using RoslynRenamer = Microsoft.CodeAnalysis.Rename;
77
using Workspace = Microsoft.CodeAnalysis.Workspace;
88

99
namespace Microsoft.VisualStudio.ProjectSystem.VS
1010
{
1111
[Export(typeof(IRoslynServices))]
1212
internal class RoslynServices : IRoslynServices
1313
{
14+
private static readonly SymbolRenameOptions s_renameOptions = new();
1415
private readonly IProjectThreadingService _threadingService;
1516

1617
[ImportingConstructor]
@@ -25,19 +26,11 @@ public RoslynServices(
2526
[ImportMany]
2627
protected OrderPrecedenceImportCollection<ISyntaxFactsService> SyntaxFactsServicesImpl { get; }
2728

28-
private ISyntaxFactsService? SyntaxFactsService
29-
{
30-
get
31-
{
32-
return SyntaxFactsServicesImpl.FirstOrDefault()?.Value;
33-
}
34-
}
29+
private ISyntaxFactsService? SyntaxFactsService => SyntaxFactsServicesImpl.FirstOrDefault()?.Value;
3530

3631
public Task<Solution> RenameSymbolAsync(Solution solution, ISymbol symbol, string newName, CancellationToken token = default)
3732
{
38-
#pragma warning disable CS0618 // Type or member is obsolete https://github.com/dotnet/project-system/issues/8591
39-
return RoslynRenamer.Renamer.RenameSymbolAsync(solution, symbol, newName, solution.Workspace.Options, token);
40-
#pragma warning restore CS0618 // Type or member is obsolete
33+
return Renamer.RenameSymbolAsync(solution, symbol, s_renameOptions, newName, token);
4134
}
4235

4336
public bool ApplyChangesToSolution(Workspace ws, Solution renamedSolution)

0 commit comments

Comments
 (0)