Skip to content

Commit

Permalink
Merge pull request #68095 from Cosifne/dev/shech/portSymbolRenamedCod…
Browse files Browse the repository at this point in the history
…eActionOptionFactoryService

Check ISymbolRenamedCodeActionOperationFactoryWorkspaceService is null when rename
  • Loading branch information
Cosifne committed May 4, 2023
2 parents 806dba8 + 9b6958b commit 5ec6d1a
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Microsoft.CodeAnalysis.Rename;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.Shared.Collections;

#if !CODE_STYLE // https://github.com/dotnet/roslyn/issues/42218 removing dependency on WorkspaceServices.
using Microsoft.CodeAnalysis.CodeActions.WorkspaceServices;
Expand Down Expand Up @@ -163,12 +164,17 @@ protected override async Task<IEnumerable<CodeActionOperation>> ComputeOperation
#if CODE_STYLE // https://github.com/dotnet/roslyn/issues/42218 tracks removing this conditional code.
return SpecializedCollections.SingletonEnumerable(codeAction);
#else
var factory = _startingSolution.Services.GetRequiredService<ISymbolRenamedCodeActionOperationFactoryWorkspaceService>();
return new CodeActionOperation[]

using var operations = TemporaryArray<CodeActionOperation>.Empty;

operations.Add(codeAction);
var factory = _startingSolution.Services.GetService<ISymbolRenamedCodeActionOperationFactoryWorkspaceService>();
if (factory is not null)
{
codeAction,
factory.CreateSymbolRenamedOperation(_symbol, _newName, _startingSolution, newSolution)
};
operations.Add(factory.CreateSymbolRenamedOperation(_symbol, _newName, _startingSolution, newSolution));
}

return operations.ToImmutableAndClear();
#endif
}

Expand Down

0 comments on commit 5ec6d1a

Please sign in to comment.