Debug your app with GitHub Copilot in Visual Studio

Applies to: yesVisual Studio noVisual Studio for Mac noVisual Studio Code

The private preview of GitHub Copilot chat for Visual Studio 2022 supports many interactive debugging scenarios, including AI-assisted chat for debugging questions related to your variables, the call stack, and other code elements, along with highly targeted help associated with an Ask Copilot link.

For related videos, see the blog post announcement.

Prerequisites

To use the private preview of Copilot with the debugging features, you must have Visual Studio 2022 version 17.7.4 or later, a GitHub Copilot subscription, and the Copilot extensions for Visual Studio installed:

Screenshot of Copilot extensions.

AI-assisted auto insights

Copilot provides detailed information in the CPU Usage auto insights. It provides detailed information and insights for specific methods and properties, such as String.Concat and many other methods. With Copilot, ask questions about functions on the identified hot paths in your code, which can help you produce more efficient or cost-effective code.

When the CPU Usage tool provides auto insights in the Top Insights section, select Ask Copilot to learn from Copilot and start asking questions.

Animation of using Copilot with CPU Usage.

AI-assisted exceptions

Copilot has access to exceptions, call stack, local variables, and code. By asking good questions based on the relevant exception data that Visual Studio has when you’re at an exception, Copilot Chat can provide useful insights and fixes for the issue.

When you see an exception, select the Ask Copilot link to get AI-generated answers related to the specific exception and context.

Screenshot of Ask Copilot option in Exception Helper.

If you have more questions, just ask Copilot!

Screenshot of Chat window after choosing Ask Copilot.

AI-assisted debugging

Copilot understands call stacks, frames, variable names, and values. As a result, you can pose detailed questions to the debugger-aware Copilot.

Screenshot of asking a debugging question.

And Copilot answers!

Screenshot of answered question.