Author : MD TAREQ HASSAN | Updated : 2020/08/01

Doc comment structure


/// <summary>
/// Each class should have a summary tag describing its responsibility. 
/// The summary often starts with “Represents …“ or “Provides …“ but other forms also exist
/// </summary>


/// <summary>
/// Initializes a new instance of the <see cref="MyClass">MyClass</see> class.
/// </summary>


/// <summary>
/// Like the method name itself, the text in the summary tag should start with a verb.
/// </summary>
/// <param name="fooId">The Foo ID.</param>
/// <returns>Foo for the given ID.</returns>
public Foo FindFoo(int fooId)
  // ... ... ...

When retur type is bool

/// <returns><c>true</c> if the person could be found; otherwise, <c>false</c>.</returns>
/// <summary>
/// Go on, have a look at <see cref="MyClass"/>
/// Go on, have a look at <see cref="MyClass.MyMethod"/>
/// Go on, have a look at <see cref="MyClass.MyProperty">Custom text</see>
/// </summary>

Embedding code example

/// <example>
/// Below is an example of using MyMethod to do something.
/// <code>
/// <![CDATA[
/// MyClass a = new MyClass();
/// string result = a.MyMethod();
/// ]]>
/// </code>
/// </example>


/// <exception cref="InvalidOperationException">
/// Here you describe why the exception will be thrown.
/// </exception>

Generate html

Install docfx:

choco install docfx -y

Initialize docfx:

Generate html for a project located in a different folder: docfx.json

      "src": [
          "files": [
          "src": "../ProjectA"

Add doc comment, make sure that classes, methods are publc (by dafult, for private and internal access modifier, documentation will not be generated).

docfx docfx_project/docfx.json

# when we run the command from docfx_project folder (cd docfx_project)
# just docfx is enough

docfx serve docfx_project/_site