0

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?

Tymur Gubayev
  • 468
  • 4
  • 14
  • Nope, also it is not related to inheritance. You can not document the default constructor without declaring it. – Eldar Aug 23 '23 at 10:17
  • While `/// ` appears to work, it doesn't make sense. You should not apply the description of a class to a constructor. (99% of the cases, `inheritdoc` should be used without arguments) – PMF Aug 23 '23 at 10:27

1 Answers1

2

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.

YungDeiza
  • 3,128
  • 1
  • 7
  • 32