๐Ÿ”— API reference link helper

August 21, 2025 ยท View on GitHub

This handy-dandy extension helps content developers quickly insert and edit cross-reference ("xref") links to the official Microsoft API reference documentation for .NET types and members. It uses the Microsoft Learn API Browser to search for a requested type or member. The extension:

  • Exposes the ability to insert a Markdown link in the Markdown or XML file that's open in the active editor.
  • Supports different link text variations: display only the type or member name, the member name with its type, the fully qualified name, or custom text.

Requirements

  • Visual Studio Code

Example usage

  1. With your cursor positioned where you want the link to be inserted in your document, open the command palette F1 and search for Insert XREF Link.

  2. Select the command, and when prompted, enter the type or member name you want to link to.

    Insert XREF link

  3. After a valid search term is entered, the extension searches for the configured API and displays the most relevant results.

    Results

  4. Once you select a result, you're prompted to choose the format of the link you want to insert.

    URL formats

    The extension inserts the selected link format into the active editor.

Tip

You can also preselect text that you want converted to an xref hyperlink before you select the command. In this case, whatever text you selected is used as the link text. Nifty!

Get started

To install the extension, download the latest xref-helper.vsix file from the .dist/ folder, and from Visual Studio Code, right-click the file and select Install Extension VSIX.

Alternatively, to install the VSIX extension, open the command palette F1 and select Extensions: Install from VSIX.... Then, browse to the downloaded xref-helper.vsix file and select it.

Tip

Since this extension isn't published to the Visual Studio Code Marketplace, you'll need to download the VSIX file from the GitHub repository every time an update is made available and manually reinstall it.

Features

The following URL formats are supported, given the example System.String.Format method when selecting the overloads option and Method overloads search result:

FormatResulting MarkdownExample HTML
Default<xref:System.String.Format*><a href="https://learn.microsoft.com/dotnet/api/system.string.format">Format</a>
Name with type<xref:System.String.Format*?displayProperty=nameWithType><a href="https://learn.microsoft.com/dotnet/api/system.string.format">String.Format</a>
Full name<xref:System.String.Format*?displayProperty=fullName><a href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</a>
Custom link text[The string.Format method](xref:System.String.Format*)<a href="https://learn.microsoft.com/dotnet/api/system.string.format">The string.Format method</a>

Command pallette commands:

  • Insert XREF Link: Inserts a markdown (<xref:uid>) link to the official Microsoft API reference documentation for the selected type or member.
  • Insert API Reference Link: Inserts a markdown ([Name](URL link)) link to the official Microsoft API reference documentation for the selected type or member.
  • Transform XREF to Other: Convert XREF link between [](xref:) and <xref:>.

Auto-completions:

  • XREF Link Completion: When typing <xref:, the extension will suggest the Insert XREF Link as a completion.
  • XREF Display Property Completion: When typing <xref:uid?, the extension will suggest the possible display properties as completions.

Code actions:

  • XREF Display Property Switch: The quick-edit code action (๐Ÿ’ก) is displayed when your cursor is on a line that contains an xref link with an existing display property, allowing you to quickly change the display property.

Context menu commands:

  • Convert XREF Link: When a full xref link is selected, a context menu command is available to convert the link between [](xref:) and <xref:>.

Search validations

After you start typing, if you delete the text, there's a validation error that will appear. The extension doesn't allow you to insert an empty search term:

Empty

The search term cannot contain spaces:

Spaces

If an opening bracket is specified (i.e. if you're looking for a generic API), the search term must also include the closing bracket:

Brackets

Extension settings

In Visual Studio Code settings, search for "XREF Helper" (or paste this filter into the search bar @ext:ievangelist.xref-helper). You can configure the following settings:

SettingDescriptionDefault
Xref Helper: Allow Git Hub Session
xref-helper.allowGitHubSession
Whether to prompt the user for GitHub auth to allow the GitHub session to be used for API requests. Enables scenarios where XREF metadata is in a private GitHub repo.false
Xref Helper: Apis
xref-helper.apis
The APIs to search for xref links.See defaults below.
Xref Helper: Append Overloads
xref-helper.appendOverloads
Whether to append overloads to the search results. Applies to methods and constructors.true

Settings Screenshot

API defaults

By default, only .NET is enabled. To enable other APIs, update the xref-helper.apis setting JSON:

[
   {
      "name": ".NET",
      "enabled": true,
      "url": "https://learn.microsoft.com/api/apibrowser/dotnet/search",
      "queryStringParameters": [
         {
         "name": "api-version",
         "value": "0.2"
         },
         {
         "name": "locale",
         "value": "en-us"
         }
      ]
   },
   {
      "name": "Java",
      "enabled": false,
      "url": "https://learn.microsoft.com/api/apibrowser/java/search",
      "queryStringParameters": [
         {
         "name": "api-version",
         "value": "0.2"
         },
         {
         "name": "locale",
         "value": "en-us"
         }
      ]
   },
   {
      "name": "JavaScript",
      "enabled": false,
      "url": "https://learn.microsoft.com/api/apibrowser/javascript/search",
      "queryStringParameters": [
         {
         "name": "api-version",
         "value": "0.2"
         },
         {
         "name": "locale",
         "value": "en-us"
         }
      ]
   },
   {
      "name": "Python",
      "enabled": false,
      "url": "https://learn.microsoft.com/api/apibrowser/python/search",
      "queryStringParameters": [
         {
         "name": "api-version",
         "value": "0.2"
         },
         {
         "name": "locale",
         "value": "en-us"
         }
      ]
   },
   {
      "name": "PowerShell",
      "enabled": false,
      "url": "https://learn.microsoft.com/api/apibrowser/powershell/search",
      "queryStringParameters": [
         {
         "name": "api-version",
         "value": "0.2"
         },
         {
         "name": "locale",
         "value": "en-us"
         }
      ]
   }
]

Settings JSON Screenshot