Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default error search in Visual Studio 2015

While I was writing my code in Visual Studio 2015CTP I got error as below in ErrorList window:

Error CS0117 'Console' does not contain a definition for 'ReadKey'

By clicking on CS0117 it redirects me to default browser and searches using Bing. As most of the time we use Google as a search engine, is there any way to make Google as a default search instead of Bing.

like image 441
Shrivallabh Avatar asked Jun 02 '15 11:06

Shrivallabh


People also ask

How do I change my search engine in Visual Studio?

Go to: Tools -> Option -> Text Editor -> C/C++ -> Advanced -> IntelliSense -> Search Provider -> then change "bing" to "google".

How do I get rid of errors in Visual Studio?

You can change this behavior by going to Tools -> Options -> Projects and Solutions -> General and deselecting the "Always show Error List if build finishes with errors".

How do I find the error list in Visual Studio?

To display the Error List, choose View > Error List, or press Ctrl+\+E.


2 Answers

Simply redirecting the search provider probably won’t work. We generate a search string that is tailored to work with a specialized search engine on the Bing side. Passing that same search string to another search engine probably will give poor results.

What you will need to do, instead, is define your own handler for the help event. This would extract relevant information from the error itself (such as error code, language, etc.) to create a generic search that would work with the provider of your choice. If this handler comes before the default handler, then you can handle the event and prevent the default (bing) search from executing.

The interfaces your need to implement are:

ITableControlEventProcessorProvider

This is a MEF export and should have the following attributes:

[Export(typeof(ITableControlEventProcessorProvider))]
[DataSourceType(StandardTableDataSources.ErrorTableDataSourceString)]
[DataSource(StandardTableDataSources.AnyDataSourceString)]
[ManagerIdentifier(StandardTables.ErrorsTableString)]
[Name("my custom event processor name")]
[Order(Before=Priority.Default)]  

ITableControlEventProcessor

It is probably best to define a class that is derived from TableControlEventProcessorBase (which provides default/no-op implementations for all of the events) and then explicitly handle the PreprocessNavigateToHelp(ITableEntryHandle entry, TableEntryEventArgs e) event by:

  1. extracting the useful data from entry
  2. creating a generic search to the search provider of your choice
  3. opening an instance of the browser
  4. setting e.Handled to true (to prevent the other help handlers from executing).
like image 170
David Pugh Avatar answered Oct 26 '22 01:10

David Pugh


There’s no built-in support for switching the search engine used. It is, however, possible to create an extension that lets Google (and other) search engines be linked to instead, just as the Bing Developer Assistant extension did in previous releases of Visual Studio.

I'd point you to the docs with info on how to create such an extension, but they're not published yet. They're on the list of docs to be published around the time Visual Studio 2015 is officially released.

like image 31
GusP Avatar answered Oct 26 '22 03:10

GusP