I have been scouring all possible documentation I could find about the Roslyn APIs but I could not find an answer to this simple question.
I know a CodeFix inherits from CodeFixProvider and provides a Code Fix. I also know that a Refactoring inherits from CodeRefactoringProvider and provides a Refactoring. One difference I found is that for some reason you cannot redistribute Refactorings using Nuget, only through a VSIX, while you can redistribute a CodeFix using both.
But what exactly is a Code Fix and what is a Refactoring? What can one do that the other cannot?
Go Up to The Code Editor Index (IDE Tutorial) Refactoring is the process of improving your code without changing its external functionality. For example, you can turn a selected code fragment into a method by using the extract refactoring method.
Press Option (⌥)+Enter anywhere on a line to see a list of available Quick Actions and refactorings.
A Code Fix is for where you've identified an error or mistake in the code and can deduce how to correct the code.
A Refactoring is a change to the code that usually will make it neither more nor less correct. It's not unusual to offer multiple refactorings that will transform the code between various forms, including, often, back to the form it was in before someone accepted any refactoring. In contrast, it would be rare in the extreme to find another Code Fix (in the same package) that transformed code into a form that another Code Fix could apply to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With