Roslyn: Port and enable NamingStyleCodeFixProvider in CodeStyle layer

Created on 6 Mar 2020  路  5Comments  路  Source: dotnet/roslyn

NamingStyleCodeFixProvider current depends on an IWorkspaceService, ISymbolRenamedCodeActionOperationFactoryWorkspaceService. See https://github.com/dotnet/roslyn/blob/ace0fdea9733b9b6842495a17873acf6c9bf0d60/src/Features/Core/Portable/CodeFixes/NamingStyle/NamingStyleCodeFixProvider.cs#L133-L142

This prevents it from being ported into a NuGet package. We should remove this dependency to unblock this port.

Area-IDE Bug

All 5 comments

Can we just use Renamer?

Yes, but it seems like that will stop the following code from being invoked: https://github.com/dotnet/roslyn/blob/ace0fdea9733b9b6842495a17873acf6c9bf0d60/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolRenamedCodeActionOperationFactoryWorkspaceService.cs#L64-L79

We will stop notifying all the IRefactorNotifyService implementations, so we need some different mechanism for it.

Essentially every other symbol rename refactoring uses Renamer. We should switch this code fix to also use Renamer, and if something is broken then we need to fix the public Renamer API.

It turns out the code fix does use the Renamer in its primary code action: https://github.com/dotnet/roslyn/blob/ace0fdea9733b9b6842495a17873acf6c9bf0d60/src/Features/Core/Portable/CodeFixes/NamingStyle/NamingStyleCodeFixProvider.cs#L93-L100

It just registers an additional code action CreateSymbolRenamedOperation whose purpose is just to invoke the IRefactorNotifyService implementations. I think we should likely move the latter functionality to the Renamer.

This will be fixed with #47048

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vbcodec picture vbcodec  路  3Comments

OndrejPetrzilka picture OndrejPetrzilka  路  3Comments

ashmind picture ashmind  路  3Comments

marler8997 picture marler8997  路  3Comments

codingonHP picture codingonHP  路  3Comments