Results 1 to 2 of 2

Thread: Inheriting XML Comments

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Inheriting XML Comments

    Hey,

    Not sure if the title is describing my problem correctly, but I've no idea what else to call it


    I have a MustInherit class, let's call it BaseClass, with a bunch of MustOverride ReadOnly properties. The user is supposed to inherit this class and override the properties, returning appropriate values.
    To help the user decide which property does what, I have included XML comments for each property, so the BaseClass looks like this
    vb.net Code:
    1. Public MustInherit Class BaseClass
    2.  
    3.    ''' <summary>
    4.    ''' Gets the Name of something.
    5.    ''' </summary>
    6.    ''' <returns>The Name of something.</returns>
    7.    Public MustOverride ReadOnly Property Name As String
    8.  
    9.    ''' <summary>
    10.    ''' Gets the Age of something else.
    11.    ''' </summary>
    12.    ''' <returns>The Age of something else.</returns>
    13.    Public MustOverride ReadOnly Property Age As Integer
    14.  
    15.    ''' <summary>
    16.    ''' Gets something, I'm not quit sure what.
    17.    ''' </summary>
    18.    ''' <returns>I've no idea..</returns>
    19.    Public MustOverride ReadOnly Property Something as String
    20.  
    21. End Class

    The idea is now that, when a user inherits this class and tries to override a property, he'll get the XML comment in the Intellisense:


    This is where problem number 1 steps in... As soon as I type 'Inherits BaseClass', Visual Studio is so kind to add the 'skeleton' of each property, because they are declared MustOverride (I cannot declare them anything else, they must be overriden...), so the user will never see these XML comments!
    I thought that they would also pop up when hovering the mouse over their names, but apparently not:


    How can I make these comments show up when the user hovers his mouse over the property name? Or is this really impossible..?



    The second problem is kind of related, but not quite.
    In my project, there are a few 'default' derived classes that inherit BaseClass. For example, there's this class
    vb.net Code:
    1. Public Class DerivedClass1
    2.     Inherits BaseClass
    3.  
    4.     Public Overrides ReadOnly Property Age As Integer
    5.         Get
    6.             Return 15
    7.         End Get
    8.     End Property
    9.  
    10.     Public Overrides ReadOnly Property Name As String
    11.         Get
    12.             Return "Mark"
    13.         End Get
    14.     End Property
    15.  
    16.     Public Overrides ReadOnly Property Something As String
    17.         Get
    18.             Return "93usdivjiwu4"
    19.         End Get
    20.     End Property
    21.  
    22. End Class

    I now want to enable the user to inherit this class (DerivedClass1) instead, so that he can, for example, override only the Name property, and leave the other properties untouched. This way, he can create a slight modification to one of the default classes, instead of having to rewrite it completely (in reality, there are loads more properties).
    For example:
    vb.net Code:
    1. Public Class DerivedDerivedClass1
    2.     Inherits DerivedClass1
    3.  
    4.     Public Overrides ReadOnly Property Name As String
    5.         Get
    6.             Return "Nick"
    7.         End Get
    8.     End Property
    9. End Class

    Now, because the properties in DerivedClass1 are not declared MustOverride, I have to type the overrides myself, and I can see the XML comments.

    But wait! There are no XML comments, because they are in the BaseClass, and not in the DerivedClass1, which is the class I'm inheriting. In other words: the XML comments are not 'inherited'...


    Do I really have to copy/paste all the XML comments from the BaseClass and put them in the DerivedClass1 too? Or can I somehow tell the DerivedClass1 to use the XML comments from its base class?


    Thanks for any help...!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Inheriting XML Comments

    I don't know for sure but I doubt that you can get what you want from VS. You might be able to find a tool to do it for you. I'm not aware of one that does that specifically but maybe something like GhostDoc or Sandcastle (which I'm not sure a VS 2010 version is out yet but it's coming).
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width