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

Peter Groenewegen

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! 


Discussion is closed. Login to edit/delete existing comments.

  • Lân Bùi Tấn 0

    Thanks, I want VisualStudio can auto suggest class, method, when its namespace is not imported in file

    • Mika DumontMicrosoft employee 0

      Thanks for taking the time to provide this feedback! We do have this but it is currently disabled by default. We hope to enable it soon by default but in the mean time you can enable it in Tools > Options > Text Editor > C# > IntelliSense and check off `Show items from unimported namespaces`.

      • Guillermo Mazzari 0

        Hi Mika! Does this work with Github Copilot?

        • Peter GroenewegenMicrosoft employee 0

          When Copilot is on in Visual Studio we do not do disable displaying of IntelliCode code suggestions in the editor. You can toggle this by disabling and enabling Copilot at the bottom of the editor.

  • Boggs, Daniel 0

    17.3 or 17.2?

    • Peter GroenewegenMicrosoft employee 0

      This is in 17.2.

  • Guillermo Mazzari 0

    Does Intellcode offer any advantage over copilot? If so, which ones? Thanks!

    • Aaron YimMicrosoft employee 1

      Hey! Aaron from the IntelliCode team here – the key differentiator between the two autocomplete experiences is that Copilot leverages CODEX & cloud inferencing to provide multi-line autocomplete. IntelliCode relies on GPT-C model inferenced entirely locally, can complete up to one line of code at once.

  • Krzysztof Kalukin 0

    Is it going to be available in Visual Studio for Mac 2022?

  • James Rolfe 0

    Any plans to port this convenient feature to VB.NET? If you don’t have enough VB code to train IntelliCode, you can use C#->VB converters.

  • A L 0


    is the other way around also possible? Most of the time you want to inject an existing Service into an Constructor, when the Constructor is already there.

Feedback usabilla icon