Visual Studio 2017 IDE provides its own quick refactoring capabilities using Quick Actions and Refactoring. Refactoring is a procedure to reform our code without altering the functional intent and which is easier to maintain, read and support. There are several third-party extension and tool that also allows extended code and editor level refactoring. First of all, performing a quick action using the light bulb inside Visual Studio IDE is not new. Furthermore, to different releases of Visual Studio, new refactoring options for code is getting added within the IDE. In addition, now the IDE support refactoring for convert for-to-foreach and vice versa.
Convert to ‘foreach’ using quick action:
You can find this new feature with the Visual Studio 2017 version 15.7 Preview 4. While you are using for-to-foreach loop, you can just check out for Quick Action icon (Shortcut Ctrl +.) It will show you the potential fixes.
Post the quick action, you can directly apply the changes or validate the overall changes in Preview Changes Windows and post that click on Apply.
Addition to for-to-foreach, you can also make private fields read-only using the quick refactoring in Visual Studio.
Quick Actions let you easily refactor, code with a single action. Quick Action Refactoring in Visual Studio is immensely powerful productivity tool which you can leverage for several aspects. You can quickly add a reference to a NuGet package in Visual Studio use the Quick Actions in Visual Studio to upgrade project’s language version
You can also apply code fix for code analyzer rules violation generating new code and applying another code refactoring.
Hope this helps