C# XML Documentation Website Link
Is it possible to include a link to a 开发者_Python百科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?
Try:
///<Summary>
/// This is a math function I found <see href="http://stackoverflow.com">HERE</see>
///</Summary>
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:
- Tooltip:
- Shows cref-url with !:, but hides "this"
- Hides ahref-url but shows text
- Hides seehref url and text
- 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)
- 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)
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.
You can use the standard HTML syntax:
<a href="http://stackoverflow.com">here</a>
The text will be displayed in Visual Studio.
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.
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>
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.
精彩评论