Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ordering of tags in XML documentation

Tags:

c#

.net

Microsoft have the triple-slash XML documentation with their recommended set of tags.

It would be weird if the ordering of the tags were different in different places where they were used.

So I am wondering if there is any recommended ordering for the XML tags?

Example:

/// <summary>Performs a foo calculation.</summary>
/// <param name="baseValue">The base value.</param>
/// <param name="af">The amplification factor.</param>
/// <returns>The supposed calculation.</returns>
/// <exception cref="ArgumentException"><paramref name="af"/> is negative.</exception>
/// <remarks>According to the theory laid forward by Dr. Hans Foo in 1732.</remarks>
/// <example>
/// Performs a foo calculation using a amplification factor of 10.
/// <code>var value = Foo(512, 10);</code>
/// </example>
public decimal Foo(int baseValue, decimal af) { /* ... */ }

Right now, I only assume that the <summary> tag always ought to be the first tag.

like image 655
Fred Avatar asked Sep 09 '25 11:09

Fred


1 Answers

After browsing source code on GitHub, a pattern began to emerge and the following informal order of tags seems to be pretty common:

  1. summary
  2. typeparam
  3. param
  4. returns
  5. exception
  6. remarks
  7. example

Other observations:

  • The words true, false and null tend to be wrapped within the <c> tag.
  • Sometimes but not always URLs are within the <c> tag.
  • References to types are marked up with the <see cref="Foo"/> tag.
  • References to generic types are marked up with <see cref="Bar{T}"/> tag.
  • References to parameters are marked up with the <paramref name="name"/> tag.
  • References to generic type parameters are marked up with the <typeparamref name="T"/> tag.
  • Sentences end with punctuation.
  • Nested tags, such as <code> within an <example>, are sometimes indented.
like image 109
Fred Avatar answered Sep 11 '25 03:09

Fred