Documenting *not* overriden methods with different XML comments

57 views Asked by At

I have some base class and multiple classes inheriting from it. Those derived classes usually won't override the default constructor. Nevertheless, I'd like to change the documentation of that default constructor (usually inheriting the class doc).

Something like this:

class MyBase
{
    /// <summary>
    /// This is MyBase constructor
    /// </summary>
    public MyBase() { }
}

/// <summary>
/// This is MyClass1
/// </summary>
class MyClass1 : MyBase
{
}

/// <summary>
/// This is MyClass2
/// </summary>
class MyClass2 : MyBase
{
    /// <inheritdoc cref="MyClass2"/>
    public MyClass2() { } //this is what I don't want to do
}

Then somewhere I have things like this:

var myClasses = new MyBase[]
{
    new MyClass1(),
    new MyClass2(),
};

The tooltip over MyClass1 constructor doesn't have any comments: MouseHoverOverMyClass1

I'd like it to have some, like MyClass2 constructor does: MouseHoverOverMyClass2

But without adding empty default constructors everywhere.

Is this even possible?

1

There are 1 answers

0
YungDeiza On

You're mixing up the class and the constructor.

You will need to add a summary for the constructor if you want to see a summary when using instantiating a new instance of a given class.

The summary on the class is for references to the class not uses of its constructor.