The official source of product insight from the Visual Studio Engineering Team
Download the extension now from the Visual Studio Gallery
Update: For the folks who have extensions that replace the Visual Studio IntelliSense experience, you can still access the feature using 'ALT-A' as a shortcut or assign the 'Tools.LaunchSnippetSearch' command to a shortcut of your choosing (under Tools->Options->Environment->Keyboard)
Imagine wanting to read a file line by line, and process those lines. Today, we’d most likely load up a web browser, visit our favorite search engine, and start crafting a well-designed set of keywords that helps the search engine understand the problem we’re trying to solve.
In the ideal case, we’d find high quality official documentation with examples, or a highly voted-on topic from one of the major forums or crowd sourced Q&A web sites. We would then scan through the options, try to figure out what’s relevant to us and do some copy/paste magic.
We wanted this to be become more accessible and make finding relevant code samples for the given tasks you’re trying to complete far easier.
Making it better
We wanted to make that experience better for you. To that end, Visual Studio, Bing and Microsoft Research have teamed up to deliver a DevLabs experience that takes code search to the next level.
When you find yourself looking for a code-sample that you could leverage for a task, you can trigger the new Bing Code Search experience directly from IntelliSense.
That triggers a spacious inline experience similar to Peek-Definition, focused on code-search. You type in the task you’re trying to complete, for instance ‘read a file line by line’, press Enter, and get results that are tailored for your code.
Behind the scenes, that query is securely beamed up to Bing along with contextual pieces that help us hone in on the fuller meaning of that query. We use meta-data like the project type, semantic context (using the new C#/VB compiler services aka ‘Roslyn’!), and a few other sprinkles of Microsoft Research magic.
Those pieces along with the query then leverage Bing’s enormous search index and keyword analysis to track down potential pages that might contain high quality examples you can learn from.
From those pages, we isolate and rank the relevant code samples, using a large number of syntactic and semantic code metrics.
That’s when you conveniently see the ordered results in Visual Studio, right around your code, along with our projected quality estimation of the sample and its source (so you can go dig in).
Check out this video demoing the experience
This new technology implementation can use virtually the entire web as its source. However, we found that partnering with a few of the top web sites where some of the richest code examples live was more than sufficient in uncovering answers for many of the top user tasks, and it allows us to focus our efforts.
We partnered with MSDN, StackOverflow, Dotnetperls and CSharp411 to deliver some of the best code samples straight to Visual Studio.
To bring the technology public early on, we selected a sub-set of the problem to tackle first. Specifically, Bing Code Search works solely for C# solutions, and we’ll look for ways to generalize the approach to more languages.
Make sure you grab the extension from the Visual Studio Gallery page, use it and let us know what you think! Happy Coding!
Visual Studio, Bing and Microsoft Research teams
But do I get bing points for my searches? :)
The video chrashes in my browsers. Stop using Q-time.
Are there plans to make this work with VS2012?
This is actually a good concept. Will have to try and see how well it works in practice. The worst part about trying to find documentation the "traditional" way with Google is that there are now so many versions and variations of .Net that it is hard to narrow to the one you want. Especially when MS have used such generic names for their various products: Windows Phone, Windows Store, Windows 8 etc are not particularly useful for a search engine to filter by. That's where Silverlight was a good name, you could search by it.
It looks like you're writing a program! Would you like help? :-)
The key for this to succeed will be to have a large library of code best practices that is constantly maintained to keep it up to date. That'll have to be crowd-sourced, I believe. I'd rather have a code repository behind it than a web scraper.
This is really great!
Why doesn't the suggested code use the 'using' keyword - since StreamReader implements the IDisposable interface?!
Cool! - Would love to know some more details / how this works.
Ok, so copy pasted code got to a new level ;)
I hope Bing can diferentiate good from bad code, otherwise it will take the blame for crapy code, you know ....
P.S. Also I hope that it does not suggest unsafe code (the one that blog authors mark with 'do not use in production')
No professional programmer will use this. If you need a code example for reading a file line-by-line, you're either learning a new language, or you just suck at programming.
Is it possible to set a new repository website to the search? For example, let's say that I want a centralized codebase for all my teams in the company and I would like them to point to one of our server that cointains all the snippets already implemented, following quality policies and naming conventions.
I am getting an error executing intellisense.
<description>System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.VisualStudio.Editor.InvokePeek.IntellisensePresenterProvider.GetUIElement(CompletionSet itemToRender, ICompletionSession context, UIElementType elementType)
at Microsoft.VisualStudio.Language.Intellisense.Implementation.Helpers.<>c__DisplayClass2`2.<FindUIElement>b__0(IUIElementProvider`2 provider)
at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata,TExtensionInstance](Object errorSource, Lazy`2 provider, Func`2 getter)</description>