Maximizing the value of IntelliCode with API usage examples: Real-World Code Examples at Your Fingertips

Peter Groenewegen

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!

14 comments

Discussion is closed. Login to edit/delete existing comments.

  • Cyrille-Alexandre NDOUMBE 3

    Really nice !!!

    • A'maya SolomonMicrosoft employee 1

      Thanks!

  • James Johnson III 3

    Great feature. Thanks

    • A'maya SolomonMicrosoft employee 1

      Thank you! I hope you enjoy using it.

  • Anonymous 0

    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.

    • Aaron YimMicrosoft employee 0

      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 any code they add… whether it’s something they’ve found online or a suggestion that IntelliCode has helped them discover.

  • Tim Andersen 1

    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?

    • A'maya SolomonMicrosoft employee 1

      Thanks Tim! There currently isn’t a way for GitHub repo owners to request that their repos be included.

      • Tim Andersen 0

        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 product’s source code doesn’t live on GitHub, we do have samples in a GitHub repo which pulls in our NuGet project. I’m just wondering if there’s any chance that our samples on GitHub demoing our NuGet project might eventually get picked up with this IntelliCode tool? Or if it only works with code bases that are exclusively on GitHub from top to bottom?

        In any case, thanks for your work on this feature! I’ll be playing around with it in my various projects.

        • A'maya SolomonMicrosoft employee 0

          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

  • Stanislav Prusac 1

    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.

    • Aaron YimMicrosoft employee 1

      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

  • Mark Patterson 0

    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 out.

    Thanks, Mark

Feedback usabilla icon