August 22nd, 2023
heart7 reactions

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 Product Manager

Mark Downie is a Lead Product Manager on the Visual Studio 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.

Sort by :
  • 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 figure out. This would be less of an issue if someone wasn't making it a point of erasing all the old VS2008 and .NET...

    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 here

      I hope that helps
      Mark

      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 bar. Been begging for that for so long…

    • 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 developers we encounter.

      The goal is to fix bugs and respond to community requests while also delivering new features for the broadest variety of Visual Studio...

      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 the name of the class.

    My next project is going to have a lot of handler classes... I wonder if I could write a couple of...

    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?

      Regards
      Mark

  • 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 entire method as is shown in the demos.
    - Copilot Chat is frankly awful. It is incapable of analyzing even the most simple of methods...

    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 via the "report a problem" feature, including the Copilot Chat logs from your Output Window's "Copilot Chat" pane - if you have cases like...

      Read more