About 10 years ago, when I worked at Microsoft, I wrote a specification for the original "Online-F1" function in Visual Studio 2005. Thus, my knowledge is somewhat authoritative, but probably outdated .; -)
You cannot change the URL that Visual Studio uses (at least I don’t know how to change it), but you can just write another add-in that steals the F1 key binding, uses the same help context as the F1 handler defaults to and directs the user to your own URL or application.
Firstly, information on how Online F1 works:
components of the Visual Studio IDE keyword identifiers in the "Help context F1", which is a bag of properties of information about what the user is doing: for example, the current selection in the code editor, the type of file being edited, the type of project being edited, etc.
when the user presses F1, IDE packages that help the context in the URL and open a browser pointing to the MSDN.
Here is an example URL, in this case, when you press F1 in the VS2012 HTML editor when the CSS width property was selected
msdn.microsoft.com/query/dev11.query? appId=Dev11IDEF1& l=EN-US& k=k(width); k(vs.csseditor); k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.0); k(DevLang-CSS)& rd=true
The "k" parameter above contains the help context inside the visual studio. The help context contains both “keywords” (text strings) and “attributes” (name / value pairs) that various windows inside Visual Studio use to tell the IDE what the user is doing right now.
The CSS editor clicked on two keywords: the "width" that I selected, and the "vs .csseditor", which MSDN can use as "backup" if, for example, my choice is not found in MSDN.
There are also some context filtering attributes:
TargetFrameworkMoniker = NETFramework,Version=v4.0 DevLang=CSS
This ensures that F1 loads the page for the correct language or technology, in this case CSS. (Another filter for .NET 4.0 exists because the project I downloaded is targeting .NET 4.0)
Note that the context is streamlined. The keyword "width" is more important than those below it.
The actual help content on MSDN contains metadata (manually set by the commands that create the documentation) that contain the keywords and name / value context properties associated with this page. For example, the css width documentation in MSDN, when it is stored on MSDN servers, has a list of keywords associated with it (in this case: "width") and a list of contextual properties (in this case: "DevLang = CSS"). Pages can have several keywords (for example, "System.String", "String") and several context properties (for example, "DevLang = C #", "DevLang = VB", etc.).
When a list of keywords falls into the MSDN Online F1 service, the algorithm is similar to this, with the caveat that it may change over the past few years:
- take the first keyword
- find all pages that match this keyword
- exclude all pages that match the name of the context attribute (for example, "DevLang") but do not have a match for the value. This, for example, would exclude the Control.Width page, because it would be marked as "DevLang = C #", "DevLang = VB". But that would not exclude pages without the DevLang attribute.
- If there are no results left, but more keywords are left, start C # 1 again with the next keyword (in order), if you have no keywords left. If there are no keywords, perform a “backup” operation, which may return a list of MSDN search results, may display “page cannot be found,” or some other solution.
- Separate the remaining results. I don’t remember the exact ranking algorithm, and it probably has changed since then, but I believe that the general idea was to show pages that first met higher specifications and showed more popular matches first.
- Show the highest score in the browser
Here is sample code for the Visual Studio Add-in:
- take the keyword F1
- when F1 is pressed, get the help context and turn it into a set of name = value pairs
- pass this set of name = value pairs to some external code to do something with the F1 request.
I leave all the code for the Visual Studio add-in template - if you need it too, there should be many examples in Google.
using System; using Extensibility; using EnvDTE; using EnvDTE80; using Microsoft.VisualStudio.CommandBars; using System.Resources; using System.Reflection; using System.Globalization; using System.Collections; using System.Collections.Generic; using System.Text; namespace ReplaceF1 {