How it works...

Code refactoring providers are VS IDE extensions that can register code actions for refactoring code to a recommended pattern without introducing any functional changes. The primary API on CodeRefactoringProvider is:

  • ComputeRefactoringsAsync method (abstract): This is a method to register code actions for refactorings. This method is invoked by the code refactoring engine whenever it needs to compute the refactorings to offer on the current source line in the VS IDE. This method takes a CodeRefactoringContext argument, which contains the current span and document. CodeRefactoringProvider can map the span to syntax node in the document and analyze it to register one more code actions in the context. CodeAction contains the ...

Get Roslyn Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.