locked
Help needed with comments in code on override methods RRS feed

  • Question

  • Hi! Is it possible to automatically render comments when a method is overriden ?

    For instance:

    I have this method:

    /// <summary>
    /// In this method, do something useful
    ///</summary>
    public abstract void DoSomething();

    Now when the user overrides this method say in an inherited class it looks like this:

    public override void DoSomething()

    {

    }

    But is it possible to get the comments as well? Like this:

    /// <summary>
    /// In this method, do something useful
    ///</summary>
    public override void DoSomething()

    {

    }

    Or is it possible to generate some kind of comments inside the method like this:

    public override void DoSomething()
    {

    /// Do something useful in here....

    }

    Thursday, April 12, 2012 6:38 AM

Answers

All replies

  • Sure, I'm using GhostDoc for that purpose. The free, basic version already handles this.
    • Proposed as answer by servy42 Wednesday, April 18, 2012 2:31 PM
    • Marked as answer by Leo Liu - MSFT Tuesday, April 24, 2012 7:12 AM
    Thursday, April 12, 2012 6:46 AM
  • Will this generate as well for users not having GhostDoc?

    I mean if the use my dll, will the comments render when they override my method?

    Thursday, April 12, 2012 6:52 AM
  • Imho yes, when you also deploy the generated XML document. But test it, the tool itself is free and I had no problem ever with it.
    Thursday, April 12, 2012 7:10 AM
  • Ok, ill try it ! 

    Thank you for your help!

    Thursday, April 12, 2012 7:11 AM
  • Hi Tobias,

    Have you tried the integrated feature "Insert Snippet" in Visual Studio?
    You can see it in the context menu if you right click in the C# editor, there are many that are already there.
    We can create a custom snippet with the mechanism I gave in the following thread:
    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/a1d95def-ebce-413c-9eb6-a2556a07b339.

    So by the way, what's going on with Stefan's suggestion? We are looking forward to hearing from you.

    Have a nice day,


    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, April 18, 2012 10:29 AM