3

Just-in-time refactoring made even easier with IntelliCode auto suggested code f...

 2 years ago
source link: https://devblogs.microsoft.com/visualstudio/just-in-time-refactoring-intellicode-suggestions/?WT_mc_id=DOP-MVP-4025064
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Just-in-time refactoring made even easier with IntelliCode auto suggested code for C#

ae2413fa36be26243ebd120e4751645f?s=58&d=mm&r=g

Peter G

May 11th, 20224

Have you ever wondered if there was a tool to help you with routine code tasks like writing common constructors or inserting similar code to a few different spots? Maybe you even know some code actions or refactorings that can help you. But at the time you could have used the code action, you typed the change instead, because you remembered the code action too late or forgot about it.”

Since the release of Visual Studio 2022, IntelliCode has code actions and refactorings for common tasks in the IntelliSense list. In Visual Studio 17.3, these code actions and refactorings are now offered as auto suggestion code upon typing. You can accept auto suggested code by pressing [Tab].

How it works

In the video, you’ll see how IntelliCode detects three common patterns: 

  • Creating a constructor 
  • Adding parameters to that constructor 
  • Repetitive code changes that only involve adding new code 

IntelliCode suggests the code change as an auto suggested code insertion. If the suggestion is correct, you can use [TAB] to insert the code change. if the suggestion is not the code you intended to write, you can either continue typing, or press [ESC]. Under the hood, intent detection is made possible by the PROSE engine. The code suggestion offered is generated either by PROSE, or by the .NET compiler platform (“Roslyn”).  

Try it now

These new IntelliCode suggestions will be enabled in the latest version of Visual Studio 2022. Visual Studio will support more refactorings in future versions. Let us know in the comments or on social media which scenarios would help you! 

Peter Groenewegen Senior Software Engineer, Visual Studio IntelliCode

Follow


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK