August 6th, 2020

Making repeated edits easier with IntelliCode suggestions

Peter Groenewegen
Senior Software Engineer

What if your developer tools could track your edits and learn while you are making changes? What if they could offer to do remaining edits for you?

Your repeated edit experience is now enhanced by IntelliCode suggestions in Visual Studio 2019 16.7. IntelliCode spots repetitions and suggests other places in your code where you could apply that same change.

 

Try it now

IntelliCode suggestions is available for C# from Visual Studio 2019 16.7. Check out the release notes for all the details. 

How it works

Under the hood, IntelliCode looks at each of your edits as you type. Using PROSE (PROgram Synthesis by Example), IntelliCode synthesizes generalized edit scripts that take your code from the “before editing” state to the “after”. When IntelliCode suggestions discovers that it can apply one of these scripts in your code, IntelliCode lets you know via the Visual Studio lightbulb in the margin and when you hover over the affected code. In both the lightbulb and by hovering over the affected code, IntelliCode offers actions to apply the suggestion for you. The underlying technology is like the Excel’s Flash Fill feature and is described in this research paper.

This is not just tracking text changes – IntelliCode is aware of the syntactic structure of your code. Syntactic awareness allows IntelliCode to detect cases where the variable names in your refactoring examples differ, but the essential structure of the change is the same.

If you do not like a suggested change you can select the ignore option on the lightbulb, and we will not bother you about that detected pattern again.

Let us know what you think!

We would love to hear about your experiences as you try this new feature. Your feedback, good or bad, will help us improve. Please raise issues Visual Studio “report a problem”.

 

Author

Peter Groenewegen
Senior Software Engineer

Peter is a Software Engineer on the Visual Studio IDE team, where he's been integrating ML and AI in developer tools. He currently working on AI tools for developers.

20 comments

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

  • Sala, Bojan

    I’m here because this rascal started showing up some really silly suggestions, didn’t really know what it was supposed to do until I read your post, so it makes sense now. It sounds like a pretty cool idea actually and would love to see where it goes. Luckily it’s not really intrusive and I haven’t noticed any performance loss either.

    • Mark Wilson-ThomasMicrosoft employee

      Hi Bojan! Thanks for your comment and for trying this feature out. Sorry about the silly suggestions; I'm glad they have not been intrusive or performance-impacting. We are aware of some cases where we make suggestions that do not compile, and we're working on improving our filtering logic for an upcoming update to catch those cases better. Can you tell me, in the silly suggestions cases you have seen, would the "after suggestion" cases have...

      Read more
  • H H

    Except repeat edited one-line-code, project template, add class or menber et.al,
    Suggesting your team can develop tools to one-click-add base-code-frame( like Code snippets ?) using for target-function like Thread, Print, user-message handle, localization, XML-paser, internet-comm….. though some canbe find in project examples.
    you knoe, construct relations between classes is the most inportant and difficult work.

    Please give some relation information if these tool had been supplied , like Code snippets ?

    • Mark Wilson-ThomasMicrosoft employee

      Hi HH

      If I am understanding your suggestion, you’d like us to build a feature that provides intelligent code snippets for performing particular tasks in your code/project context.

      I’d love to understand what you’re looking for in more detail, so please drop me a line at mwthomas at microsoft dot com so we can discuss further?

      Thanks
      mark

  • AlanW

    I found this enabled in a recent VS update. And I noticed the dotted underlines here and there. After a short while I got a basic feeling for how they work. But all in all, it wasn't a useful experience. The suggested edits were inappropriate most of the time, for example trying to duplicate typed code at any opening brace in the most impossible places. And even when I found a suggestion useful, it took...

    Read more
    • Mark Wilson-ThomasMicrosoft employee

      Hi @Marcos

      Thanks for trying IntelliCode Suggestions.

      I'd love to gather more data on the cases where we suggested poor suggestions so we can improve. If you have time could you turn on the feature again and reproduce the bad cases then raise a Report-a-problem bug in Visual Studio? We'll then help you to attach your suggestions logs so we can debug.

      On the question of a record-and-playback feature, we are considering the possibility of a manual...

      Read more
  • Chiramisu

    HUGE fan of the IntelliCode. I only wish it was a little more intelligent with the suggestions. For example, sometimes it suggests changes I've been making, but at the same time suggests changing them back. It also would be nice if the suggestions could be applied across the entire solution rather than just the current file as well. Currently I have to make the same changes for each file before it will recommend making the...

    Read more
    • Mark Wilson-ThomasMicrosoft employee

      Thanks for the shout out Chiramisu, and for raising the issue. Much appreciated.

      In order of your comment:
      1. We'd love to hear more about the bad case of suggestions suggesting reversal of it's own actions - if you can reproduce that, could you raise an issue via Visual Studio report-a-problem and drop me a line at mwthomas at microsoft dot com to let me know you've done it? It will be good to gather more...

      Read more
      • AlanW

        this comment has been deleted.

  • Shivaराम Kriष्णं

    Wish this feature comes to VB also.

    • Mark Wilson-ThomasMicrosoft employee

      Thanks a lot for the request and the vote of confidence – you can raise suggestions for other folks to vote on here , which helps us prioritize.

  • Felipe Fujiy Pessoto

    It will make refactoring much more enjoyable.
    I’m wondering if it can help to change a sync code to async, where we usually have to change the calls like File.Write to File.WriteAsync().ConfigureAwait(false), make our own method async (add the “async” keyword, change the return type to Task) and repeat the same to all methods that call the method we converted. It is very boring and error prone.

    • Peter GroenewegenMicrosoft employee Author

      Yes, IntelliCode can learn such suggestions. Do 2 edits and the 3th place should show the suggestion. If it does not learn the pattern, feel free to contact me directly to see why it does not learn the suggestion. An extra tip: if you want a list of all places in the current file where you can apply the refactoring, open the IntelliCode suggestion window (View -> Other Windows -> IntelliCode suggestions). By double clicking...

      Read more
      • Alex

        I was looking for a way to disable it. It become annoying since the suggestions it gave never applied.
        Thank you for making this option available.

  • Eric Helin

    More general question…will there always be an ‘off’ option for suggestions? I like using suggestions during specific periods like code polishing or final versions. When I am prototyping (or just thinking with the keyboard), I find suggestions break my thought process.

    • Peter GroenewegenMicrosoft employee Author

      Yes, you can turn suggestion off by going to Tools -> Options -> IntelliCode -> General -> section IntelliCode Suggestion -> C#.

  • Ian Marteens

    I gave the feature a try. Actually, it popped up without being called first. And the suggestion it’s making are pretty silly. I was editing a method for matrix transposing: load this from here, load that from there, store that here, store this there. It got confused by this very simple pattern. I wouldn’t put a cent for buying this if it were on sale.

    • Peter GroenewegenMicrosoft employee Author

      Thank you for trying out IntelliCode Suggestions! We appreciate your feedback and it would be great if you could give us more details so that we can improve this feature. Could you report this issue to “Report a Problem in Visual Studio”. Please, include the step-by-step process to reproduce it. You can also include the IntelliCode logs on your machine. These logs record the code changes that you did. Please be aware any code you...

      Read more
  • Keith Burgoyne

    This is a really neat feature. I'll definitely have to give it a try.

    It does, however, bring up the point of the IntelliCode pop-up menus becoming their own time consuming navigation problem with all the things they can contain these days.

    Here is an efficiency improvement idea...

    Maintain a list of the (five?) most recent actions the developer has performed withOUT the developer having used a hotkey to invoke the action. Obviously which entries in this...

    Read more
    • Peter GroenewegenMicrosoft employee Author

      Thank you for the feedback. We are looking for ways to improve the experience. Send me a message if you are interested in a chat (pegroene at microsoft dot com).