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.
After browsing source code on GitHub, a pattern began to emerge and the following informal order of tags seems to be pretty common:
summary
typeparam
param
returns
exception
remarks
example
Other observations:
true
, false
and null
tend to be wrapped within the <c>
tag.<c>
tag.<see cref="Foo"/>
tag.<see cref="Bar{T}"/>
tag.<paramref name="name"/>
tag.<typeparamref name="T"/>
tag.<code>
within an <example>
, are sometimes indented.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With