Improving GitHub Copilot code suggestions in Visual Studio for C# developers

In the latest versions of Visual Studio 2022, GitHub Copilot Completions now automatically considers semantically relevant C# files as additional context, even if those files are not open in your editor. This enhancement helps reduce hallucinations and provides more accurate, relevant suggestions.

GitHub Copilot provides autocomplete suggestions inline as you code. These suggestions are generated based on the content in your currently active file and any other open files in your editor. However, we’ve found that incorporating more relevant context leads to better suggestions.

To get started in Visual Studio 2022, ensure you’re using version 17.11 or later and have an active GitHub Copilot subscription. We hope this enhancement improves your experience with GitHub Copilot in Visual Studio. Our team is committed to improving Copilot support for C# developers in both Visual Studio and VS Code, with similar updates coming to VS Code soon.

For more details, visit the .NET team blog here.

Join our dedicated Community Discussions to discuss this update, share tips, and connect with other coders.

Announcing the general availability of GitHub Enterprise Cloud with data residency in the EU

Today, GitHub Enterprise Cloud with data residency in the EU is generally available. GitHub Enterprise Cloud offers customers a robust, enterprise-grade development platform designed to enhance productivity, collaboration, and agility in software development, while providing the flexibility and control to choose where your code is stored, starting with the European Union (EU) and expanding to more regions in the future. Customers will also be able to monitor the status and availability of our services by region via the GitHub status webpage.

What is GitHub Enterprise Cloud with data residency?

GitHub Enterprise Cloud is a multi-tenant, enterprise SaaS deployment option of GitHub Enterprise with enhanced enterprise-grade capabilities and powered by Microsoft Azure. Customers experience a cloud-based unified platform that includes a suite of tools and capabilities to enhance the developer experience, so you can focus on building innovative software at scale without the complexities of having to manage updates and infrastructure.

GitHub Enterprise Cloud empowers you with the flexibility to choose where your code is stored, starting with the EU and expanding to more regions in the future. This enhanced control allows you to manage your data residency preferences to meet the unique needs of your business, whether for compliance, performance, availability, or other reasons. Powered by Microsoft Azure’s enterprise-grade infrastructure and security, GitHub Enterprise Cloud with data residency protects your code both in transit and at rest.

Who is this available for?

GitHub Enterprise Cloud is available to customers who need their code and repository data to reside in the EU. Support for data residency in additional regions will be released as they become available.

How can I access GitHub Enterprise Cloud with data residency?

Get started today by contacting our sales team. You can also learn more by visiting our docs.

Join our Community

Discuss this and other updates and swap tips with other Github Enterprise customers in our dedicated Community Discussions.

See more

A list of the GitHub Copilot Chat updates in the October VS Code release.

In the latest Visual Studio Code release, you will find a suite of enhancements to GitHub Copilot Chat, designed to streamline your coding, debugging, and testing processes. These features are now available for you to try out in the latest version of Visual Studio Code.

Start a code editing session with multi-file editing (Preview)

Setting: github.copilot.chat.edits.enabled

With multi-file editing, currently in preview, you can start an AI-powered code editing session where you can quickly iterate on code changes. Use multi-file editing to prompt GitHub Copilot to propose code changes across multiple files in your workspace. These edits are applied directly in the editor, so you can quickly review them in place, with the full context of the surrounding code.

Multi-file editing is great for iterating on large changes across multiple files. It brings the conversational flow of Copilot Chat and fast feedback from inline chat together in one experience. You can have an ongoing, multi-turn chat conversation on the side, while benefiting from inline code suggestions.

Get started with multi-file editing with these steps:

  1. Start an edit session by selecting Open Copilot Edits from the Chat menu.

Screenshot showing the Copilot menu in the Command Center, highlighting the Open Edit Session item

  1. Add relevant files to the working set to indicate to GitHub Copilot which files you want to work on.
  2. Enter a prompt to tell GitHub Copilot about the edit you want to make! For example, Add a simple navigation bar to all pages or Use vitest instead of jest.

Get more details about multi-file editing in the VS Code documentation. Try it out now and provide your feedback through our issues!

A new place to chat: Secondary Side Bar

The new default location for GitHub Copilot Chat view is the Secondary Side Bar. By using the Secondary Side Bar, you can have chat open at any time, while you still have other views available to you like the File Explorer or Source Control. This provides a more integrated AI experience in VS Code. You can quickly get to chat by using the Chat menu in the Command Center.

Chat view in its new location after having moved

With the introduction of the new Chat menu next to the Command Center, bringing up the Secondary Side Bar with chat is just a click away:

The Chat menu gives you access to the most common tasks for Copilot Chat. We provided a new setting, chat.commandCenter.enabled, that you can use to hide this menu if you wish.

Chat Menu

Note: If you had previously installed GitHub Copilot, a view will show up at the location you had Copilot Chat before that enables you to restore the Chat view to the old location.

Chat view in its old location after having moved

Code review (Preview)

With Copilot-powered code review in Visual Studio Code, you can now get fast, AI-powered feedback on your code as you write it, or request a review of all your changes before you push. Code review in Visual Studio Code is currently in preview. Try it out and provide feedback through our issues.

There are two ways to use code review in VS Code:

  • Review selection: For a quick review pass, select code in the editor and either select Copilot > Review and Comment from the editor context menu, or use the GitHub Copilot: Review and Comment command from the Command Palette. (This feature is in preview.)
  • Review changes: For a deeper review of all uncommitted changes, select the Copilot Code Review button in the Source Control view, which you can also do in your pull request on GitHub. (Join the waitlist, open to all Copilot subscribers)

Request review of uncommitted changes

Copilot’s feedback shows up as comments in the editor, attached to lines of your code. Where possible, the comments include actionable code suggestions, which you can apply.

Screenshot showing a comment reviewing a code selection

Head to the code review documentation to learn more.

GitHub Copilot’s quick review on code selection can provide feedback that matches the specific practices of your team or project, provided you give it the right context. When reviewing selections with custom review instructions, you can define those specific requirements via the github.copilot.chat.reviewSelection.instructions setting. Similar to code-generation and test-generation instructions, you can either define the instructions directly in the setting, or you can store them in a separate file and reference it in the setting.

The following code snippet shows an example of review instructions:

"github.copilot.chat.reviewSelection.instructions": [
{
"text": "Logging should be done with the Log4j ."
},
{
"text": "Always use the Polly library for fault-handling."
},
{
"file": "code-style.md" // import instructions from file `code-style.md`
}
],

Here is an example of the contents of the code-style.md file:

Private fields should start with an underscore.

A file can only contain one class declaration.

Sort by relevance in semantic search (Experimental)

Setting: github.copilot.chat.search.semanticTextResults

Last milestone, we introduced the ability to perform a semantic search using GitHub Copilot to get search results that are semantically relevant to your query. We have now improved the search results by sorting them by their relevance. Keyword matches from more relevant snippets are deemed more relevant overall.

File-based custom instructions enabled by default (Preview)

Setting: github.copilot.chat.codeGeneration.useInstructionFiles

The newly introduced .github/copilot-instructions.md file lets you document code-specific conventions for GitHub Copilot in your workspace or repository. With this release, the setting is enabled by default in VS Code, so chat conversations automatically include this file if it is present in the workspace. You can verify which instructions are added to a chat request in the Used references list. Learn more about customizing Copilot with instructions.

Intent detection in Copilot Chat

Setting: chat.experimental.detectParticipant.enabled

GitHub Copilot has several built-in chat participants, such as @workspace, which also contribute commands to the Chat view. Previously, you had to explicitly specify the chat participant and command in a chat prompt. To make it easier to use chat participants with natural language, we’ve enabled Copilot Chat to automatically route your question to a suitable participant or chat command.

Screenshot of Chat view that shows how the '@workspace' participant is automatically detected.

If the automatically selected participant is not appropriate for your question, you can select the rerun without link at the top of the chat response to resend your question to GitHub Copilot.

Control current editor context

Copilot Chat has always automatically included your current selection or the currently visible code as context with your chat request. Large Language Models (LLMs) are generally good at understanding whether a piece of context is relevant. But sometimes, when you ask a question that is not about your current editor, including this context might affect how the model interprets your question.

We now show a special attachment control in the chat input that gives a hint about the editor context. It also enables you to toggle whether or not to include the editor context.

The current editor context control in the chat input, which shows that the context is not included.

There are no changes to the behavior of the editor context. When the active editor has a selection, then just the selection is included. Otherwise, just the code that is scrolled into view is included. You can still attach other files or the full file by using the paperclip button or by typing # in the chat prompt.

A common use case of Copilot Chat is asking questions about the code in your workspace, such as using /tests to generate new unit tests for the selected code or asking @workspace to find some specific class or function in your project. This milestone, we added enhanced links for any workspace symbols that GitHub Copilot mentions in chat responses. These symbol links can help you better understand Copilot responses and learn more about the symbols used in them.

Symbol links are rendered as little pills in the response, just like the file links we added last milestone. To learn more about a symbol, select the symbol link to jump to that symbol’s definition:

You can also hover over the symbol link to see which file the symbol is defined in:

Hovering over a symbol link to see the file it's defined in

To start exploring a symbol in more detail, right-click on the symbol link to bring up a context menu with options, such as Go to Implementations or Go to References:

Using the context menu on a symbol link to learn more about a symbol

Basic symbol links should work for any language that supports Go to Definition. More advanced IntelliSense options, such as Go to Implementations, also require support for that language. Make sure to install language extensions to get the best symbol support for any programming languages used in GitHub Copilot responses.

Workspace indexing

@workspace lets you ask questions about code in your current project. This is implemented using either GitHub’s code search or a smart local index that VS Code constructs. This milestone, we added a few more UI elements that let you understand how this workspace index is being used.

First up, the new GitHub Copilot: Build Local Workspace index command lets you explicitly start indexing the current workspace. Normally, this indexing is automatically kicked off the first time you ask a @workspace question. With the new command, you can start indexing at any time. The command also enables indexing larger workspaces, currently up to 2000 files (not including ignored files, such as the node_modules or out directories).

While the index is being built, we now show a progress item in the status bar:

A status bar item showing the progress of indexing the current workspace

Indexing workspaces with many hundreds of files can take a little time. If you try to ask an @workspace question while indexing is being constructed, instead of waiting, GitHub Copilot will try to respond quickly by using a simpler local index that doesn’t take as long to build. We now show a warning in the response when this happens:

A warning showing on a response telling the user the Copilot user

Notice that Copilot was still able to answer the question in this case, even though it used the simpler local index. That’s often the case, although more ambiguous or complex questions might only be answerable once the more complex index has been constructed. Also keep in mind that if your workspace is backed by a GitHub repository, we can instead use GitHub’s code search to answer questions. In this case, GitHub Copilot uses code search instead of the simpler local index.

Fix using Copilot action in the Problem hover

The Problem hover now includes the action to fix the problem using GitHub Copilot. You can use this action with problems that have a fix available, and the fix is generated by Copilot.

The Problem hover showing a fix using Copilot action

Chat settings updates

As we continue to add new features to GitHub Copilot, we want to make it easier to check out what’s new and ready to try out. We’ve restructured our settings and added support for tagging preview and experimental settings.

New features may go through the following early access stages, which are described in the settings editor as follows:

Experimental: This setting controls a new feature that is actively being developed and may be unstable. It is subject to change or removal.

Preview: This setting controls a new feature that is still under refinement but is ready to use. Feedback is welcome.

You can check out all of GitHub Copilot’s preview features using @tag:preview in the Settings editor and all of the experimental features using @tag:experimental.

Discuss this and more in our dedicated community discussion.

See more