August 22nd, 2023

Simplified Code Refinement and Debugging with GitHub Copilot Chat

This March, we announced GitHub Copilot chat for Visual Studio 2022. With Chat, Copilot has moved beyond code completions, offering in-depth analysis and explanations of how code works. It supports the generation of unit tests, and even helps with proposed fixes to bugs, and explaining exceptions. By gathering useful context data from Visual Studio, Copilot Chat helps you form great questions to get useful answers. Using GitHub Copilot with Visual Studio gives you more time for creativity by spending less time on boilerplate manual tasks and diagnosis.

Now, we’ve taken deep integration with Visual Studio a step further. Using the Interactive Code Assistant view, you can seamlessly refine your code with Copilot Chat, without ever needing to leave the comfort of your editor window. Your workflow is uninterrupted – no more going back and forth to the chat window! Get started using “ask Copilot” wherever in your code file you want to work – ask your questions and see answers inline with the code they relate to. Whenever Copilot suggests code changes, you’ll see your code side by side with Copilot’s suggestion – the normal Visual Studio diff view pattern – to help you thoroughly review, correct and refine what is being proposed at your own pace before applying to your code. We’ve taken care to make sure you are always in the driver’s seat, with complete control throughout the process.

Check out the video below to see how Copilot’s Interactive Code Assistant works:

Enhanced diagnostics with Copilot

The team’s also been hard at work bringing Copilot Chat to your fingertips in more places when you are debugging in Visual Studio. The three features below illustrate some of that work:

CPU Usage auto insights in the profiler

A profiler can help you make informed decisions quickly by providing a visual depiction of execution times and CPU usage for your application. Copilot now gives you detailed information via CPU Usage auto insights. It now provides more detailed information and insights for specific methods and properties, including Enum.HasFlag, Enum.ToString, String.StartsWith, ConcurrentDictionary.Count and more. With Copilot, you can ask questions about functions on the identified hot paths in your code, which can help you produce more efficient or cost-effective code. Just click “Ask Copilot” to start exploring.

Copilot Exception Helper

Copilot can provide you with meaningful help when you are debugging your code. For example, when an exception is thrown, it gives you the opportunity to start asking questions. Copilot has access to exceptions, call stack, local variables, and code. By forming good questions based on the right parts of the data Visual Studio has when you’re at an exception, Copilot Chat can provide useful insights and fixes for the issue.

See how this works in this video

Debugger “Rubber Ducking”

Copilot can now understand call stacks, frames, variable names, and values. This means you can pose detailed questions to a debugger-aware Copilot.

Check out the video below to see how this works:

How can I get these Copilot Chat preview features?

All Copilot for Individuals users now have access to the GitHub Copilot Chat preview for Visual Studio! See Shuyin Zhao’s blog post for more details. If you are already a user of Copilot for Individuals, just get the latest version of the extension to see the new features.

We want to hear from you!

We’re really grateful for all the feedback you’ve provided so far as we’ve been creating Copilot Chat, and excited to see where this next wave of AI-assisted productivity takes you as you create great software. Please try the new features and share your feedback – just use Visual Studio “Report a Problem” to send us your suggestions, feedback and issues for GitHub Copilot Chat in Visual Studio.

Author

Mark Wilson-Thomas
Principal Program Manager

Mark is a Program Manager on the Visual Studio IDE team, where he's been building developer tools for over 15 years. Most recently he's been working on AI assisted developer tools like GitHub Copilot Chat for Visual Studio. Prior to that, he worked on the Visual Studio Editor, and on tools for Office, SQL, WPF and Silverlight.

Mark Downie
Principal Program Manager

Mark Downie is a program manager on the Visual Studio Production Diagnostics team. He blogs about how you can use Visual Studio to get to the bottom of gnarly issues in production.

16 comments

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

  • Steve Tabler

    Is this available for any version of Visual Studio? Becuase I need to generate .NET 3.5 code all the time, and my most comfortable environment is Visual Studio 2008 for this. I use ChatGPT V2, occasionally for this, more for a sounding board to get ideas when I'm kinda stuck on how to approach something, and ChatGPT keeps forgetting that I specified .NET 3.5 coding, and outputs uncompileable solutions that I have to...

    Read more
    • Mark Wilson-ThomasMicrosoft employee Author

      Hi Steve

      The GitHub Copilot Chat Preview is currently only available for Visual Studio 2022 17.6 and higher, and as well as being admitted to the preview you'll need a subscription to the GitHub Copilot service (see GitHub's documentation) to use it.

      Regarding help docs: whilst Visual Studio 2012 and earlier are out of support, you can still see docs in the following locations:

      1. Visual Studio 2008 docs are on /previous-versions here
      2. .NET 3.5 docs are...

      Read more
  • The Werewolf · Edited

    I assume this can be disabled because God knows there's nothing I want more than a half-baked back seat driver looking over my shoulder and making questionable suggestions on how to code better and triggering my ADHD.

    Guys, maybe fix the problems VS actually has before gluing more stuff literally NO ONE asked for into it?

    But I DO have to say THANK YOU for putting a feature to move the menu bar out of the title...

    Read more
    • Mark DownieMicrosoft employee · Edited

      Hey there!
      This feature is currently in preview and requires an explicit sign-up step to get involved, so you certainly do not have to use it.

      While I do not imagine that all developers will find this equally helpful, I am seeing a lot of early evidence that some developers are already relying on conversational assistance while coding. We just want to make sure we have the right tools available for the many kinds of...

      Read more
  • George Belletty

    I'm liking Copilot a lot, I've had it in Visual Studio for about 5 weeks now and I didn't really use at the beginning. I started using it by replacing my searches on google and stack overflow for syntax or finding the best way to do something.

    The suggested code has saved me probably thousands of key taps a day! You know when you start writing a class and like intellisense, it suggests properties given...

    Read more
    • Mark Wilson-ThomasMicrosoft employee Author

      I’m glad to hear Copilot is helping you so far! Would love to hear how your experiment goes; we are looking at further improvements to context going forward and your case is an interesting one. Please do share - you can drop me a line anytime mwthomas at Microsoft dot com or raise suggestions and feedback via “report a problem” in Visual Studio.

      Let us know what you think of the new inline refinement experience?

      RegardsRead more

  • MgSam · Edited

    I've been using the preview Copilot / Copilot Chat since Build and unfortunately it has been a massive disappointment. It doesn't work anything like it does in Microsoft's demos.

    - The in-context Copilot features just don't work at all. I almost never get code suggestions and it doesn't attempt to suggest code based on comments. Even when it does offer suggestions, its simple stuff like a semicolon. I've never had it offer to complete an...

    Read more
    • Mark Wilson-ThomasMicrosoft employee Author

      Hi MgSam

      We have been updating Visual Studio Copilot and have made a number of changes since Build in the preview bits. Based on testing and feedback we have a number of improvements planned in the area of context management too. The new inline chat feature makes context easier to control too - I encourage you to try it.

      We are still in the preview phase, and would very much welcome your bug reports from Visual Studio...

      Read more
  • Melissa P

    I tried Copilot a few months ago and was not impressed. The AI drifts too much, I said "don't use types, use 'var'". And the AI changed. Then I said refactor this and that. And boom, types were back. I said "make all local variable names lowercased pascal". And the AI did that. Then I asked for another refactor and boom the new variables where uppercased pascal. 1 step forward, 2 steps back. When ever...

    Read more
    • Mark Wilson-ThomasMicrosoft employee Author · Edited

      Hi Melissa

      Thanks for taking the time to try Copilot Chat, and for your feedback.

      We are just getting started with Copilot Chat, and will be working on improvements to make the system more useful over time. Whilst it does have limitations, we believe it can be useful for many cases. Thanks for giving us a sense of your priorities with this post; I'm hearing you'd appreciate the following features:

      1. If you have (or express)...

      Read more
      • Melissa P

        I nowadays mostly use GPT4, but to my knowledge Copilot is using that in the background. With GPT I usually start a session and give instructions, which I now can pre-define. Short answers, reduced comments and compact/condensed code. And I tell GPT if I currently work using C#, C++ or HLSL. It works quite well but still from time to time I have to remind GPT to get back to my settings.

        I think for me...

        Read more
      • Andreas Saurwein

        Addendum: for enterprise use it needs more context, like on the solution level, it must be able to understand the WHOLE solution code not only the opened files, or whatever is its current context level. Most often Copilot does not understand how some of the classes used actually work, and it does not suggest them in new code even if previous code did use them.

      • Andreas Saurwein

        Mark, for what its worth, the most use of AI in debugging scenarios would probably come from having it analize the call stack and variable flow, not only the exception context. But this is probably a bit off the capabilities of the current implementation.

        I definitely would appreciate being able to set an "experience level" lets say, so Copilot will reduce redundant information and present a appropriately terse response. Add "explain more" or add links to...

        Read more
      • Mark Wilson-ThomasMicrosoft employee Author

        Thanks for this feedback Andreas. We are definitely aware of this requirement for whole solution context. If you can share some cases that would be particularly important to your usage in this regard that would be great and help the team prioritize the most useful cases. It sounds like you're looking for understanding/explanation/diagnosis that spans multiple files in the solution as your main case?

        Also noting
        1. Your comments about increasing debugger help usefulness -...

        Read more
      • Andreas Saurwein

        Totally agree here, been using Copilot since it was available, both private and at work. Seeing pretty much the same issues. Where I find it most useful is actually filling in the blanks, like completing tests, inserting logical or calculated values in tests, also in writing comments and documentation, it pretty nicely completes the info.
        As a debugging helper I really couldn't get it to do anything remotely useful. Exception explanations may possibly be useful...

        Read more
      • Mark Wilson-ThomasMicrosoft employee Author

        Thanks so much for the extra detail. It helps us understand where to invest next.

        Mark