GitHub Copilot in Visual Studio: A Recap of 2023

Amy Nguyen

In the rapidly evolving world of software development, staying ahead of the curve is crucial. The introduction of AI in Visual Studio, particularly GitHub Copilot, has revolutionized the way developers code. With Copilot integrated into Visual Studio, you can leverage AI to streamline your workflows, manage large codebases, analyze exceptions, and even generate commit messages. It’s like having a knowledgeable pair programmer right beside you, helping you to be more productive, iterate quicker, and make your applications more reliable. Here are a few GitHub Copilot innovations in Visual Studio that we want to highlight from this past year. 

 

Inline Chat View 

Ever wish you could just take the code that your generative AI chatbot gives you and put it right in your editor? With the inline chat, you can interact with GitHub Copilot right within your editor! This feature allows you to refine your code within the editor, which is perfect for asking specific questions about your active file, and seeing diff views when GitHub Copilot gives you code suggestions.

To access the inline chat, you need an active GitHub Copilot subscription and the extension installed in Visual Studio 17.8 or higher. To access the inline chat, right click within the editor > Ask Copilot, or through the shortcut (Alt+/).  

     Image inline chat

Learn more about inline code refinement here: Simplified Code Refinement and Debugging with GitHub Copilot Chat – Visual Studio Blog (microsoft.com) 

Submit Feedback for Inline Chat 

 

Slash Commands to State Intent 

Being misunderstood is the worst! Slash commands allow you to clearly state your intention behind your prompt so that there are no misunderstandings with GitHub Copilot. When learning to use generative AI chatbots, it’s always frustrating when it doesn’t understand what you’re asking for. By using slash commands, they allow you to clearly state the intention behind your prompt so that there are no misunderstandings with Copilot.

Slash commands exist within the chat window. Type ‘/’ to pop open a list of commands that you can use to state your intent, such as “/explain” to explain code, “/doc” to document a method or file, and many more!  

Image slash commands

Learn more about available slash commands, and ways to create better prompts here: Tips & Tricks for GitHub Copilot Chat in Visual Studio – Visual Studio (Windows) | Microsoft Learn 

Submit Feedback for Slash Commands 

 

Context Variables to Refine Your Scope 

Ever wonder what GitHub Copilot is referencing when answering your questions? The context variables feature allows you to specify files from your solution in your questions by using the # symbol. When you reference a file, Copilot can access its content and provide specific answers related to it.  

[TIP] Utilize our latest and greatest with #Solution to include the context of all the files in your open solution, allowing you to root your answers in it. Note: #Solution only supports C#. 

Example: “What parts of this #Solution is designated to be a command line interface?”  

For instance, you can ask questions like “How does the #Main.cs file work?” or “What is the purpose of the #Calculator.cs file?” Copilot Chat will then provide relevant answers based on the content of those files. This feature streamlines the process by eliminating the need for manual copying and pasting. Feel free to include multiple files in a single question for even greater efficiency!  

Image context variables

Learn more about context variables here: Code Faster and Better with GitHub Copilot’s New Features: Slash Commands and Context Variables – Visual Studio Blog (microsoft.com) 

Submit Feedback for Context Variables 

 

Analyze and Fix Test Window Failures 

With GitHub Copilot, failure and exception analysis has never been easier. This AI assisted feature helps the user in analyzing and fixing test failure due to failed test assumptions or exceptions that occur during test execution. This feature can be found in the Test Explorer and creates a discussion thread that allows you to interact with GitHub Copilot, providing you access to both explanations and code fixes. When a failed test is present, the “Ask Copilot” link will appear in the test failure summary explanation, allowing you to follow up with Copilot. 

Image test window fialure

Submit Feedback for Test Explorer 

 

AI Assisted Exception Analysis 

Ever rattled your brain on why an exception occurred? Now, GitHub Copilot can be used to assist with exception analysis, helping developers understand why an exception occurred and suggests ways to resolve it. It collects relevant information about the exception, including its type, message, snippets of code from the stack trace, and local variable values. This data is then sent to Copilot for an initial analysis. Subsequently, users can engage in further conversation with Copilot to discuss the error and explore potential solutions.  

Image Screenshot 2024 03 14 055032

Learn more about how to use this feature here: Debug with GitHub Copilot – Visual Studio (Windows) | Microsoft Learn 

Submit Feedback for AI Assisted Exception Analysis 

 

Auto Insights in Profiling Tools 

Auto insights flagged by the CPU Usage and Instrumentation profiler allows you to get insights on your code, typically related to a known problematic pattern. When presented with an auto insight, users can now use the “Ask Copilot” link to get more detailed information on the insight. GitHub Copilot takes the context from the insight and uses it to prompt Copilot again so you can get more information on the insight you’ve been given and ask follow up questions! 

Image Screenshot 2024 03 14 055200

Learn more about how GitHub Copilot can help you debug here: Debug with GitHub Copilot – Visual Studio (Windows) | Microsoft Learn 

Submit Feedback for Auto Insights in Profiling Tools 

 

AI-Powered Rename Suggestions 

Have you ever grappled with naming a variable, method, or class? You’re not alone. This feature goes beyond mere name suggestions; it learns how your identifier is used and adapts to your code style, proposing identifiers that seamlessly integrate into your codebase. 

To access this feature in Visual Studio, simply select any identifier, right-click, and choose “Rename” (Ctrl+R, Ctrl+R). Click on the rename suggestions button or use the Ctrl+Space shortcut. You’ll be presented with a list of naming suggestions tailored to the context of your code. Pick the name that resonates with you the most, and press Enter!  

Image Screenshot 2024 03 14 055803

Learn more about AI-powered rename suggestions here: Naming Made Easy: AI-Powered Rename Suggestions – Visual Studio Blog (microsoft.com) 

Submit Feedback for AI-Powered Rename Suggestions 

 

AI-Generated Commit Messages 

After spending hours on a bug fix or a feature update, the last thing I would want to do is rack my brain to precisely explain the contents of my Git commit. Fortunately, Copilot offers a solution. Use the newly generated Git commit message feature to succinctly describe your set of changes and improve the quality and consistency of your commit messages, making your code easier to understand and maintain. You can then refine the message by adding the crucial ‘why’ behind the change before committing. 

Use the new “Add AI Generated Commit Message” sparkle pen icon in the Git Changes window to generate a suggestion. 

Image Screenshot 2024 03 14 055938

Find out more here: Write Your Git Commits with GitHub Copilot – Visual Studio Blog (microsoft.com) 

Submit Feedback for AI-Generated Commit Messages 

IntelliSense for Breakpoint Expressions 

Breakpoint expressions can help developers debug their code more efficiently and effectively. However, finding the optimal breakpoint expressions can be challenging and time-consuming. That is why we use GitHub Copilot Chat in Visual Studio, an AI companion that can help us with IntelliSense for breakpoint expressions. GitHub Copilot can analyze our code and suggest the best breakpoint expressions for our debugging scenarios. What a great way to save time and effort!  

This feature is aimed at users creating advanced breakpoints such as conditional breakpoints and trace points. Using the context of the code surrounding the breakpoint, GitHub Copilot suggests potential expressions to use for breakpoint conditions and logging statements. Note: IntelliSense breakpoint suggestions only support C#. 

Image breakpoint

Submit Feedback for IntelliSense for Breakpoint Expressions 

 

Deadlock Analysis with AI 

Deadlock can cause serious problems in your program and can be tedious to detect and resolve. With GitHub Copilot, deadlocks are demystified, and made much more obvious to the user by showing them in the Exception Helper. The exception helper will now include an “Ask Copilot” link, where Copilot takes the context of your code, along with the information that the Exception Helper has accrued and allows users to continue asking questions to Copilot about how they can resolve the deadlock. 

Image deadlock analysis

 

Submit Feedback for Deadlock Analysis in AI  

 

How can I get started? 

All of these features and more are now available on the recently released Visual Studio 17.9. So why wait? Install Copilot and Copilot Chat in Visual Studio today and experience the future of coding! 

 

Providing Feedback and Staying Connected 

We appreciate the time you’ve spent reporting issues/suggestions and hope you continue to give us feedback when using Visual Studio on what you like and what we can improve.  

Your feedback is critical to help us make Visual Studio the best tool it can be! You can share feedback with us via Developer Community: report any bugs or issues via report a problem and share your suggestions for new features or improvements to existing ones. 

Stay connected with the Visual Studio team by following us on YouTube, Twitter, LinkedIn, Twitch and on Microsoft Learn.  

Feedback usabilla icon