How to generate summary comments of methods, properties and etc in C#

Asked

Viewed 42 times

0

Here’s the thing, guys. I know that to create a summary in a given Method just put "//" in Visual Studio that Intellisense, automatically puts the following:

Example:

    /// <summary>
    /// 
    /// </summary>
    /// <param name="ligacao"> "Server = localhost; Integrated security = SSPI; database = Nome do Banco de dados"; </param>
    /// <param name="nomeTabela"> Nome da tabela em questão </param>
    /// <param name="nomeCampo"> Nome do campo pertencente a tabela em questão </param>
    /// <returns> Retorna o id atualmente disponível </returns>
    public static int IdDisponivel(SqlConnection ligacao, string nomeTabela, string nomeCampo)
    {
        int id = -1;

        string query = string.Format("SELECT MAX({0}) AS IdMax FROM {1}", nomeCampo, nomeTabela);
        DataTable dados = new DataTable();
        SqlDataAdapter adaptador = new SqlDataAdapter(query, ligacao);

        try
        {
            adaptador.Fill(dados);

            //Verifica se a tabela está vazia ou não
            if (DBNull.Value.Equals(dados.Rows[0][0]))
                id = 1;
            else
                id = Convert.ToInt16(dados.Rows[0][0]) + 1;
        }
        catch (Exception ex)
        {
            MsgBox.Show("Erro:\n" + ex.Message, "Banco de Dados", TipoIcone.Erro);
        }
        finally
        {
            dados.Dispose();
            adaptador.Dispose();
        }

        return id;
    }

If I use some internal Method of C# itself and leave the mouse on top of this Method it informs the Parameters, type of return, in order, everything.

inserir a descrição da imagem aqui

The problem is that if I write some code (with my entire summary) in a DLL (as can be seen just above one of my methods) and use this DLL in another project of mine, I don’t see my notes that I left in the summary.

inserir a descrição da imagem aqui

As you can see in the image above, my summary did not appear.

I learned that it was necessary to create and configure a location for the XML summary file, so that all my applications that used my DLL’s could "see" my summaries, just as I can when I use the internal methods of C#. But, I don’t know how to do it, someone could help me?

From now on I thank you all.

1 answer

1


In order for comments to be exported along with the DLL a file . xml with this metadata must be generated, and must also be bundled with the DLL.

To do this, in the Visual Studio go to the properties of the project (right click on the project), in Build, on the opium "XML Documentantion file".

Note that the file must have the same DLL name, for example:

Project.Bananas.XXX.dll
Project.Bananas.XXX.xml

  • Ok. Thank you so much for the answer. I will test.

  • It worked perfectly, thank you very much.

  • don’t forget to accept the answer then :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.