简体   繁体   中英

Use base class Doxygen comment for overridden methods in derived classes

Using Visual Studio 2019 and C# (and new to Doxygen ). Is it possible for a Doxygen comment from the base class method to be "applied" in Intellisense for derived classes (without actually having to write a Doxygen comment block for the method in the derived class itself)?

An example:

public abstract class MyBaseClass
{
    /// <summary>
    /// Something about this cool function
    /// </summary>
    protected abstract void CoolFunction();
}

public class MyDerivedClass1 : MyBaseClass
{
    protected override void CoolFunction()
    {
        // Do something specific to derived class 1...
    }
}

public class MyDerivedClass2 : MyBaseClass
{
    protected override void CoolFunction()
    {
        // Do something specific to derived class 2...
    }
}

//...
MyDerivedClass1 d1;
MyDerivedClass2 d2;
d1.CoolFunction();
d2.CoolFunction();

In the above example, hover the mouse over (say) d1.CoolFunction . Can the base class comment "Something about this cool function" be displayed? Currently basic prototype information is displayed, but nothing else.

This related question on PHP seems to give an answer but:

    1. I was not able to get it to work in C# (perhaps the syntax is slightly different?)
    1. This still requires writing a Doxygen comment block for each method in all derived classes, something I'd like to avoid if possible

You can try

/// <inheritdoc />

I'm not sure if it works with doxygen but it's the way to do for XML-documentation. See here

public abstract class MyBaseClass
{
    /// <summary>
    /// Something about this cool function
    /// </summary>
    protected abstract void CoolFunction();
}

public class MyDerivedClass1 : MyBaseClass
{
    /// <inheritdoc />
    protected override void CoolFunction()
    {
        // Do something specific to derived class 1...
    }
}

public class MyDerivedClass2 : MyBaseClass
{
    /// <inheritdoc />
    protected override void CoolFunction()
    {
        // Do something specific to derived class 2...
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM