September 18th, 2024

Improving GitHub Copilot Completions in Visual Studio for C# Developers

Mika Dumont
Senior Product Manager

GitHub Copilot code completions provide autocomplete suggestions inline as you code. These suggestions are generated based on the content from your currently active file and any other open files in your editor. However, we have discovered that incorporating more relevant context significantly improves these suggestions.

We are excited to announce that in Visual Studio 2022 17.11, our team has made changes to ensure that additional relevant C# context, such as available types and methods, is now included in Copilot completions.

With the latest version of Visual Studio, Copilot now automatically considers semantically relevant files for additional context, even if these files are not open in your editor. This improvement helps reduce hallucinations while offering more relevant and accurate suggestions.

Before: Semantically relevant files are not considered as context for GitHub Copilot Completions

Consider a scenario where you’re trying to call a method defined in another file. Previously, GitHub Copilot might have suggested an incorrect method name like GetVsixPaths:

After: Semantically relevant files are considered as context for GitHub Copilot Completions

Now, with semantically relevant files included as context, GitHub Copilot suggests the correct method name, GetVsixPathFromVsmanFiles:

Let us know what you think!

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.

We would love to hear about your experiences with this enhancement. Your feedback is essential in helping us improve the Copilot experience for C# developers. You can provide feedback on GitHub Copilot by opening a GitHub discussion.

Author

Mika Dumont
Senior Product Manager

Mika is a Product Manager on the .NET and GitHub Copilot developer experience.

1 comment

Leave a comment

Newest
Newest
Popular
Oldest
  • James White 23 mins ago

    There is a huge gap between suggesting code and what's possible automating the edit/build/fix/commit loop. Having a tool integrated into your IDE that is entirely incapable of using the commands within that IDE just seems like a waste. Claude-Dev (a free VSCode plugin) can actually run commands, build & fix, install packages, commit changes - anything you can accomplish with file sys & command line access. It's made Copilot / Cursor entirely unnecessary for me.

    Read more
'; block.insertAdjacentElement('beforebegin', codeheader); let button = codeheader.querySelector('.copy-button'); button.addEventListener("click", async () => { let blockToCopy = block; await copyCode(blockToCopy, button); }); } }); async function copyCode(blockToCopy, button) { let code = blockToCopy.querySelector("code"); let text = ''; if (code) { text = code.innerText; } else { text = blockToCopy.innerText; } try { await navigator.clipboard.writeText(text); } catch (err) { console.error('Failed to copy:', err); } button.innerText = "Copied"; setTimeout(() => { button.innerHTML = '' + svgCodeIcon + ' Copy'; }, 1400); }

Feedback