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

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

当我输入

SomeMathThing(

我想智能感知显示的摘要选项点击“这里”链接到一个外部网站。这可能吗?怎么做呢?


当前回答

你可以在cref中包含一个!:前缀,让它在生成的Xml文档中不受影响地传递,这样像Innovasys Document!X和Sandcastle将使用它。如。

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

Visual Studio智能感知不会将其显示为智能感知的链接——这没什么意义,因为它是一个工具提示,所以你不能点击它。

其他回答

你可以使用标准的HTML语法:

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

文本将在Visual Studio中显示。

你可以在cref中包含一个!:前缀,让它在生成的Xml文档中不受影响地传递,这样像Innovasys Document!X和Sandcastle将使用它。如。

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

Visual Studio智能感知不会将其显示为智能感知的链接——这没什么意义,因为它是一个工具提示,所以你不能点击它。

使用<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>

虽然有点晚了,但以下是我对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);
    }

结果如下:

提示: 使用!:显示cref-url,但隐藏“this” 隐藏ahref-url,但显示文本 隐藏seehref url和文本


对象浏览器: 使用!:显示cref-url,但隐藏“this”(不可点击) 隐藏ahref-url,但显示文本(不可点击) 隐藏seehref url和文本(不可点击)


ReSharper (CTRL+SHIFT+F1, Command ReSharper. resharper_quickdoc) 隐藏cref-url与!:,但显示“this”(不可点击) 现在可以解释ahref-url(2016年及更新版本) 隐藏seehref url和文本(不可点击)

结论:正如海纳指出的,最好的答案是

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

更新 正如托马斯Hagström指出,Resharper现在支持可点击的a-href url。更新了截图。

Try:

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