As a software developer, we’ve all faced the frustration of having to leave our IDE to search for documentation, code examples, Stack Overflow, blog posts or simply trying to remember how to use a certain API. What if we told you that we have a solution for you? Now with Visual Studio 17.6 Preview, IntelliCode makes finding real-world code examples for common APIs easier than ever. With this feature, you’ll have real examples at your fingertips. See how an API has been used in real-world projects. Saving you time and making your coding even more efficient.
Under your fingertips
IntelliCode API usage examples enables you to browse open-source code examples of 100k common APIs. These code snippets represent real-world usage examples that are sourced in public GitHub repositories. Now you have these examples under your fingertips. When you hover over a known API, the documentation shows a link to start browsing examples.
How it works
When you hover over a method, IntelliCode checks for matching examples in its database. A link is displayed which opens a tab with examples. In this tab you can browse snippets and access documentation. On the snippet you can click through to the source-code on GitHub.
The IntelliCode API usage examples helps you to understand how a function works in real code. This enables you to use them in your project more effectively, by providing examples of how a function can be used from within the editor. No more searching for examples on the internet. However, it’s important to note that the code snippets provided by the IntelliCode are only examples and may not be the best or most up-to-date way to use a function in all cases.
Feedback
Overall, the this is a useful addition to the IntelliCode features to help you write better code more efficiently. It’s currently in public preview in Visual Studio. Install Visual Studio 17.6 Preview today and try it out! We’d love your feedback! If you run into an issue, in Visual Studio, use Help | Send Feedback to report a problem. Let us know what you think!
The examples feature is great Peter. Also, IntelliSense and CoPilot are working better together.
However, CoPilot isn't working within C# code files of a WinUI 3 project.
I don't know if you saw my comment in Linked-In but CoPilot suggests entire methods in response to comments in a Console project.
However, when I try the same comment in the C# file in a WinUI 3 project, CoPilot doesn't suggest anything, so you might check that...
Mark,
Thanks for taking the time to leave feedback.
I’ve filed a bug on our end, but if you come across this again, please use the “Report A Problem” feature so we can take a look at your specific logs as well.
Link to docs for “Report a Problem”: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2022
Cheers,
Aaron
An issue:
after I click on the “GitHub Examples and Documentation” link, a new tab opens that says “Loading…” and nothing else.
On the laptop, the same version of VS works correctly, while on the desktop computer this problem occurs.
I tried to compare various settings in VS, windows 10, firewall,… but I didn’t discover anything.
If anyone has a hint as to what the problem is, I’d love to hear it.
Oh no! We’d love to investigate further for you. Please use the “Report A Problem” feature so we can take a look at your specific logs.
Cheers,
Aaron
Very nice feature! Is there a process for how GitHub repo owners can get their own samples included in this database? Or do we not really have a way to suggest / register our own repos to this database?
Thanks Tim! There currently isn’t a way for GitHub repo owners to request that their repos be included.
Thanks for the quick reply! I do have one other question, if I may. Suppose you have "MyLibrary" product, and there are GitHub repos with samples that demo usage of MyLibrary. Does MyLibrary's source code also need to be located in a GitHub repo for this IntelliCode samples feature to work?
To put it more concretely, we have a closed source commercial product that is distributed on NuGet. While our...
You’re welcome, Tim!
The feature’s database currently only uses GitHub open-source repositories. Since there’s a filtering mechanism for these repositories, your samples may or may not get pulled in by the feature.
Best,
A’maya
Please don’t infringe on my rights by stealing my copyright works. My code on GitHub is under the GPL License and if you use take my code, then you must license your code under the same license.
Also please beware that much of the code on GitHub is written by hobbyists and insecure. Do not suggest poor quality code with bugs and vulnerabilities.
Thanks for taking the time to leave a comment.
We're trying to save our customers the work of having to search for specific code examples across various online repositories / Q&A forums.
I've shared this feedback with the team - we will review & see if there's anything we can do differently from a security/licensing perpsective.
As always, the responsibility for the code a user writes ultimately rests with them, and they should carefully test and review...
Great feature. Thanks
Thank you! I hope you enjoy using it.
Really nice !!!
Thanks!