How to copy the summary of a method with Overload in C #

1

I'm creating an application where in classes I have a series of overload 's to optimize performance and flexibility. Ex:

public class Calc 
{
    // método original com sumário

    /// <summary>
    /// soma "a" com "b"
    /// </summary>
    /// <returns></returns>
    public int soma(int a, int b) => a + b;

    // métodos complementares de conversão (overload) sem comentários

    public int soma(string a, int b) => soma(int.Parse(a), b);
    public int soma(string a, string b) => soma(int.Parse(a), int.Parse(b));
}

Is there any way, when I call one of the complementary methods, it show me the doc of the original method?

    
asked by anonymous 21.06.2018 / 16:05

1 answer

3

It has to be at hand. If it were with override it would solve.

The most common case of overload is to avoid its use with default arguments, even is better, but in this case where the type changes does not give because of qaulquer way in most cases the semantics changes and the description should be different.

In general, copying and pasting into code in something of the same type is usually not difficult and as the contract should be very stable it should not have to change much. Anyway if you make a change without paying too much attention to the overloads you may make a mistake, so I do not think it is a serious fault of the tool. It's that thing, comments are complicated, somehow they even violate the DRY .

    
21.06.2018 / 16:21