<example></example> XML comment tag: how to see it?

7.4k Views Asked by At

I use Microsoft Visual Studio 2012. When I put code examples into XML comments of C# classes/methods, I wonder: how will user that references my assemblies see that code example?

I tried to reference my own assembly, and the only way I found was: to look at assembly.xml file. Can I settle Visual Studio or anything else to see those code examples?

Here is what I put into comments:

/// <summary>
/// This is my method example
/// </summary>
/// <example>
/// <code>
/// // Here is my code example. Call my method like this:
/// const int a = 10;
/// MethodExample(a);
/// </code>
/// </example>
public static void MethodExample(int parameter)
{
}

Here is what I get in IntelliSense:

enter image description here

Here is what I get in Object Browser:

enter image description here

Here is what I get in assembly.xml file:

enter image description here

What I'd like to get: see code examples in Object Browser and IntelliSense.

2

There are 2 best solutions below

6
Past Tense On

A number of XML comment tags appear in IntelliSense only as child elements of other tags. These tags, known as ChildCompletionList tags, are: c, code, example, list, listheader, para, paramref, see and see also.

/// <summary>
/// MethodExample the function that does it all...
/// <example>
/// <code>
/// <para/>// Here is my code example. Call my method like this:
/// <para/>const int a = 10;
/// <para/>MethodExample(a);
/// </code>
/// </example>
/// </summary>
1
Ken747 On

If your not seeing XML commments in IntelliSense or they're not updating after you edit them try:

  1. Not seeing: be sure everything is enclosed in the <summary> element. ref: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/recommended-tags

  2. Not updating: close & reopen solution (this seems to work pretty consistently)

VS Ent 2019 (16.10.4)