For Serving Comments with 3 Lines

1

There are comments with 3 lines but I can not find its operation, I doubt it is a simple comment since when using three lines the comment darkens but when adding two, four lines or more it returns to its original color in which I called attention even when writing

///<  

I see other types of options in which more increases my curiosity so that it will serve

    
asked by Diego 09.04.2017 в 00:46
source

1 answer

5

First let's start with the types of comments that can be used in C #

We have 3 types:

A)) Comments on a line: //

Example:

//comentario
int a = 1; //otro comentario

B)) Comment of several lines: /* */

Example:

/* comentario
* de varias
* líneas */

C)) Documentation template comment: ///

Those three slashes /// are used to create a template for a documentation comment, which can then automatically generate documentation , it is useful for:

1) Show XML reports.

2) Give help to autocomplete the name or parameters of the class, object, variable, etc.

3) Generate the program's own documentation based exclusively on these comments.

///<summary>
///summary description
///</summary>
///<remarks>
///This is a test.
///</remarks>

That means that with that /// tag all the comments that you add and add the corresponding tags will generate a XML with a documented format.

In other words it's like making an HTML code but with the specifications of the code, such as variables, objects, classes, which will have a specific format within the XML

Examples:

Document classes

///<summary>
///Clase principal de la aplicación.
///</summary>
///<remarks>
///Lee archivos de configuración y crea los hilos que ejecutan el resto del programa.
///</remarks>
class CApp {
    static void Main(string[] args) {
        ...
    }
}

Between the tags <summary> and </summary> we put the description or summary of the class. The tags <remarks> and </remarks> are used for special comments, they will not be seen in the autocomplete but in the documentation.

Document members

class CApp2 {
    ///<summary>
    ///Variable que almacena el número de reintentos al acceder a un archivo.
    ///</summary>
    ///<remarks>
    ///Puede ser modificada en cualquier momento.
    ///</remarks>
    int var = 1;
    ...
}

Document methods / functions

///<summary>
///Lee la configuración de la aplicación desde el disco.
///</summary>
///<return>
///Devuelve true si la configuración fue leida. Si hubo algún error se devuelve false.
///</return>
///<param name="archivo">
///Ruta del archivo en disco a leer.
///</param>
public bool LeeConfig(string archivo) {
    bool c = false;
    ...
    return c;
}

Between the <return> and </return> tags, the value returned by the function is explained, and the <param></param> tags are used to describe each of the method / function parameters. Generate documentation

A parte de las ayudas al autocompletado que aparecen automaticamente en Visual Studio, SharpDevelop y MonoDevelop al documentar el código, también se pueden generar archivos de documentación.

On Windows, using the Microsoft .NET Framework implementation, the following command is used:

C:\>csc /doc:Documentacion.xml Programa.cs

With this you can generate your system documentation in XML format

Example:

CODE C #:

 // compile with: /doc:DocFileName.xml 

    /// text for class TestClass
    public class TestClass
    {
        /// <summary>DoWork is a method in the TestClass class.
        /// <para>Here's how you could make a second paragraph in a description. <see cref="System.Console.WriteLine(System.String)"/> for information about output statements.</para>
        /// <seealso cref="TestClass.Main"/>
        /// </summary>
        public static void DoWork(int Int1)
        {
        }

        /// text for Main
        static void Main()
        {
        }

Generate this XML:

   <?xml version="1.0"?>  
<doc>  
    <assembly>  
        <name>YourNamespace</name>  
    </assembly>  
    <members>  
        <member name="T:DotNetEvents.TestClass">  
            text for class TestClass  
        </member>  
        <member name="M:DotNetEvents.TestClass.DoWork(System.Int32)">  
            <summary>DoWork is a method in the TestClass class.  
            <para>Here's how you could make a second paragraph in a description. <see cref="M:System.Console.WriteLine(System.String)"/> for information about output statements.</para>  
            <seealso cref="M:DotNetEvents.TestClass.Main"/>  
            </summary>  
        </member>  
        <member name="M:DotNetEvents.TestClass.Main">  
            text for Main  
        </member>  
    </members>  
</doc>  

If you are more interested in CODE REPORTS:

Quoting link

Create code reports

Visual Studio .NET 2003

  

Once you have defined the objects and interfaces of a project, you can   see the structure of those objects and interfaces, as well as the   structure of the members, through web reports of comment of   code. These reports show information about the definitions of   code in a series of pages .htm. If you use C # or other languages   that support XML documentation comments, you can use these   comments to offer summary descriptions, comments from the   how a definition or summary of parameters behaves for   functions.

     

Note Visual C ++ provides limited support for comments   of XML documentation. Web reports of code comments   they recognize the following XML tags:

<summary></summary> Describe a member for a type.

<remarks></remarks> Specifies general information of a class or another type.

<param></param> Used in the comment of a method declaration to describe one of the parameters of the method.

<returns></returns> Used in the comment of a method declaration to describe the return value.

<newpara></newpara> Start a new paragraph in the comments.

For more information about the other tags and these, but in greater depth: link

    
answered by 09.04.2017 / 02:56
source