Visual Studio 2022 17.11 now allows you to pass your entire workspace or specific classes and functions as context for GitHub Copilot Chat. By referencing your entire codebase, down to specific classes and functions, Copilot Chat can deliver refined and accurate results tailored to your code.
@workspace for project references
You can now use GitHub Copilot Chat to refer to your entire C++ project using the @workspace command. This feature allows you to ask questions about your project, and GitHub Copilot will provide you with detailed responses.
An example use case for the @workspace command in GitHub Copilot is identifying where the ship’s turning logic is handled in the OSS (Open-Source Software) Pioneer project. Without using @workspace, GitHub Copilot would provide general steps on how to identify the ship’s turning logic, such as searching for relevant functions and reviewing code sections related to movement.
When you ask, “@workspace, identify where the ship’s turning logic is handled in this project,” it will give specific and actionable insights, directly pointing to the relevant sections of code where the ship’s turning logic is implemented, as showcased in the GIF below.
GitHub Copilot Chat lists the sources it uses to generate responses, providing transparency and helping users verify the information. Additionally, the Content Exclusion feature allows you to customize which files Copilot can access, ensuring sensitive information is never sent to Copilot. This helps enforce company-wide security policies while still benefiting from Copilot’s capabilities across your development workflow.
@workspace is also supported in VS Code. For more information, you can visit the Making Copilot Chat an expert in your workspace page.
Reference Classes and Functions with Copilot Chat
While @workspace is used to dynamically gather workspace context to navigate and understand an entire codebase, references allow you to be super specific about particular classes and functions when you have targeted questions.
You can now use GitHub Copilot Chat to reference your classes and functions. This feature allows Copilot to access relevant code segments directly, enabling it to provide answers that directly apply to the code in your project.
For example, in the OSS Pioneer project, you can ask GitHub Copilot, “What are common issues when working with the #StarSystem?” Copilot will then provide pertinent answers based on that specific class. Make sure to add a ‘#’ symbol at the beginning of the name, as demonstrated in this example.
Let us know what you think
To access these features, you need the latest version of Visual Studio and an active GitHub Copilot subscription.
We hope you enjoy these new updates to GitHub Copilot. Your valuable input continuously helps us improve our product. Share your thoughts in the comment section below, through the, Developer Community, via email at [email protected] or via X at @VisualC.
0 comments