C# XML Documentation Website Link

C#XmlHyperlink

C# Problem Overview


Is it possible to include a link to a website in the XML documentation? For example, my method's summarized as

///<Summary>
/// This is a math function I found HERE.
///</Summary>
public void SomeMathThing(Double[] doubleArray)
{
   ...
}

and when I type

SomeMathThing(

I want IntelliSense to show the summary with the option to click on "HERE" to link to an outside website. Is this possible? How would it be done?

C# Solutions


Solution 1 - C#

Try:

///<Summary>
/// This is a math function I found <see href="http://stackoverflow.com">HERE</see>
///</Summary>

Solution 2 - C#

A bit late on the hype-train, but here is what I found out for Visual Studio 2015.

My sample looks like this:

    /// <summary>
    ///     Retrieves information about the specified window. 
    ///     The function also retrieves the value at a specified offset into the extra window memory.
    ///     From <see cref="!:https://msdn.microsoft.com/en-us/library/windows/desktop/ms633585(v=vs.85).aspx">this</see> MSDN-Link.
    ///     AHref <a href="http://stackoverflow.com">here</a>.
    ///     see-href <see href="http://stackoverflow.com">here</see>.
    /// </summary>
    /// <param name="hwnd"></param>
    /// <param name="index"></param>
    /// <returns>
    ///     Testlink in return: <a href="http://stackoverflow.com">here</a>
    /// </returns>
    public static IntPtr GetWindowLongPtr(IntPtr hwnd, int index)
    {
        return IntPtr.Size == 4 ? GetWindowLongPtr32(hwnd, index) : GetWindowLongPtr64(hwnd, index);
    }

The results are:

  1. Tooltip:
    • Shows cref-url with !:, but hides "this"
    • Hides ahref-url but shows text
    • Hides seehref url and text Screenshot of intellisense tooltip

  1. Object Browser:
    • Shows cref-url with !:, but hides "this" (not clickable)
    • Hides ahref-url but shows text (not clickable)
    • Hides seehref url and text (not clickable) Screenshot of ObjectBrowser

  1. ReSharper (CTRL+SHIFT+F1, Command ReSharper.ReSharper_QuickDoc)
    • Hides cref-url with !:, but shows "this" (not clickable)
    • Does now interpret ahref-url (Version from 2016 and newer)
    • Hides seehref url and text (not clickable) Screenshot of Resharper QuickHelp

Conclusion: Best one, as Heiner pointed out, would be

See <a href="link">this link</a> for more information.

Update As Thomas Hagström pointed out, Resharper now Supports clickable a-href URLs. Updated screenshot accordingly.

Solution 3 - C#

You can use the standard HTML syntax:

<a href="http://stackoverflow.com">here</a>

The text will be displayed in Visual Studio.

Solution 4 - C#

You can include a !: prefix in a cref to have it passed through untouched in the generated Xml documentation so that tools such as Innovasys Document! X and Sandcastle will use it. e.g.

/// <summary>
/// This is a math function I found <see cref="!:http://stackoverflow.com">HERE</see>
/// </summary>

Visual Studio intellisense won't display that as a link for intellisense though - wouldn't be much point as it's a tooltip so you can't click it anyway.

Solution 5 - C#

Use the <a> tag. For example, I used this solution in my project:

Result:

My XML code:

/// <summary>
/// This is C# XML Documentation Website Link
/// <a href="https://stackoverflow.com/questions/6960426/c-sharp-xml-documentation-website-link">See more</a>
/// </summary>

Or use the <see> tag. Result is the same to the <a> tag.

/// <summary>
/// This is C# XML Documentation Website Link
/// <see href="https://stackoverflow.com/questions/6960426/c-sharp-xml-documentation-website-link">See more</see>
/// </summary>

Solution 6 - C#

I also tried <see href="https://some.com/> first and it did not work; however, I then tried <seealso href="https://some.url/"> and it did work.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjohnView Question on Stackoverflow
Solution 1 - C#dizzwaveView Answer on Stackoverflow
Solution 2 - C#MHolzmayrView Answer on Stackoverflow
Solution 3 - C#HeinerView Answer on Stackoverflow
Solution 4 - C#fubaarView Answer on Stackoverflow
Solution 5 - C#Ramil AliyevView Answer on Stackoverflow
Solution 6 - C#gregsonianView Answer on Stackoverflow