C#XML文档网站链接

时间:2011-08-05 17:42:24

标签: c# xml hyperlink

是否可以在XML文档中包含指向网站的链接?例如,我的方法总结为

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

当我输入

SomeMathThing(

我希望IntelliSense显示摘要,并选择单击“此处”链接到外部网站。这可能吗?怎么做?

6 个答案:

答案 0 :(得分:106)

尝试:

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

答案 1 :(得分:59)

炒作有点晚了,但这是我在Visual Studio 2015中发现的。

我的示例如下:

    /// <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);
    }

结果是:

  1. 工具提示:
    • 使用!:显示cref-url,但隐藏“this”
    • 隐藏ahref-url但显示文字
    • 隐藏seehref网址和文字 Screenshot of intellisense tooltip
    1. 对象浏览器:
      • 使用!:显示cref-url,但隐藏“this”(不可点击)
      • 隐藏ahref-url但显示文字(不可点击)
      • 隐藏seehref网址和文字(不可点击) Screenshot of ObjectBrowser
      1. ReSharper (CTRL + SHIFT + F1,Command ReSharper.ReSharper_QuickDoc)
        • 用!:隐藏cref-url,但显示“this”(不可点击)
        • 现在解释ahref-url(2016年及更新的版本)
        • 隐藏seehref网址和文字(不可点击) Screenshot of Resharper QuickHelp
      2. 结论:正如海纳指出的那样,最好的一个是

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

        <强>更新 正如ThomasHagström指出的那样,Resharper现在支持可点击的a-href网址。相应更新了截图。

答案 2 :(得分:18)

您可以在cref中包含!:前缀,使其在生成的Xml文档中不受影响,以便Innovasys Document! X和Sandcastle等工具可以使用它。 e.g。

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

Visual Studio intellisense不会将其显示为intellisense的链接 - 因为它是工具提示所以不会有太多意义,因此无论如何都无法点击它。

答案 3 :(得分:14)

您可以使用标准HTML语法:

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

文本将显示在Visual Studio中。

答案 4 :(得分:9)

使用<a>标签。例如,我在项目中使用了以下解决方案:

结果:

我的XML代码:

/// <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>

或使用<see>标签。结果与<a>标签相同。

/// <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>

答案 5 :(得分:1)

我还首先尝试了<see href="https://some.com/>,但没有成功;但是,我随后尝试了<seealso href="https://some.url/">,它没有起作用。