AI Assisted Intellisense with Visual Studio Intellicode

I tried Visual Studio Intellicode and am super impressed. If you like saving time, this easy to use Visual Studio add in is the way to go.  This Microsoft explanation gives a great overview:  “IntelliCode saves you time by putting what you’re most likely to use at the top of your completion list. IntelliCode recommendations are based on thousands of open source projects on GitHub each with over 100 stars. When combined with the context of your code, the completion list is tailored to promote common practices.”

Image credit Microsoft

Basically Intellicode saves you time by putting the most likely code autocomplete suggestions at the top of your list as determined by Artificial Intelligence to be the most likely correct choice.  The AI behind the decision logic is from a model trained on thousands of GitHub projects.  Until now, that list has been alphabetical, so in the example image above, you would have to scroll down to the E’s if ‘EndsWith’ was what you wanted.  Sounds like not a big deal, but let me tell you, those couple of seconds add up.  I also find it fascinating and perhaps understated that AI is reaching into our code bases!  While autocomplete suggestion prioritization is an early benefit we can enjoy now, the things that make it possible have huge implications.  If you think about it, since we can now do things like identify that .ToList() is used most commonly in certain places, what other patterns can we learn from a collective code base?  Funny you should ask, this blog post from Microsoft research dives pretty heavily into that topic.   One notable future application is scanning for potential issues in code when you check your source code in.

Intellicode can be trained on your own code.  Open the Intellicode menu by choosing View > Other Windows > IntelliCode Model Management.  Next, click ‘Create New Model’.  Intellicode will train using your code as model data  (without sending your code to Microsoft).  It does so by collecting as Microsoft describes “only those elements of the code that are needed to create a model for recommending completion values. For example, it extracts the names of classes and methods and how often they’re called in different circumstances. The data used to train the model on your code is saved in a file which you can view in the “%TEMP%\Visual Studio IntelliCode” directory.  This data is sent to a service where the model is trained and passed back down to Visual Studio.

Give it a shot and start saving those precious seconds!