In a VB.Net Structure, how do I add the XML description tag for the New()
constructor with no parameters? This is so the description is displayed by Intellisense.
I created the structure shown below. It's a stripped-down version of System.Drawing.Size(). Then based on this post, I used the '''
trick (three single quotes) to automatically insert the <summary></summary>
tags.
This worked great for everything but the empty New()
constructor. Where do I put the summary tags for this? Perhaps I'm not doing the empty New()
correctly? I did have to experiment to make it work, and ended up with Shared
but no access modifier.
I've pasted together the large screenshot below to show the issue visually. Intellisense shows the descriptions for sections 1, 2, and 4. But in the 3rd section, when the empty New()
signature is displayed, Intellisense does not show the description.
What have I missed?
Perhaps there is no solution in this situation?
The screenshot...
And the code...
'A simple structure to store a pair of integers which specify the width and height of an arbitrary
'area. This could be used for various types of tables, grids, control layouts, etc. This structure
'is based on System.Drawing.Size(), but stripped down & slightly modified.
''' <summary>
''' A simple structure to define the width and height of an arbitrary area.
''' </summary>
Public Structure Area
'Auto-implemented properties of the Area structure.
Public Property Width As Integer
Public Property Height As Integer
''' <summary>
''' A simple structure to define the width and height of an arbitrary area.
''' </summary>
Shared Sub New()
End Sub
'Initialize a new instance of the Area structure with the specified dimensions.
''' <summary>
''' A simple structure to define the width and height of an arbitrary area.
''' </summary>
''' <param name="Width">The width of the area.</param>
''' <param name="Height">The height of the area.</param>
Public Sub New(Width As Integer, Height As Integer)
Me.Width = Width
Me.Height = Height
End Sub
'Return a structure with .Width=0 and .Height=0.
''' <summary>
''' A simple structure to define the width and height of an arbitrary area.
''' </summary>
Public Shared ReadOnly Empty As Area
'Tests whether this Area structure has .Width=0 and .Height=0.
Public ReadOnly Property IsEmpty As Boolean
Get
Return (Me.Width = 0 AndAlso Me.Height = 0)
End Get
End Property
'Tests to see whether the specified object is an Area structure with the same dimensions as this instance.
Public Overrides Function Equals(obj As Object) As Boolean
Dim fTest As Boolean = False
If Me.GetType = obj.GetType Then
Dim objArea As Area = DirectCast(obj, Area)
If Me = objArea Then
fTest = True
End If
End If
Return fTest
End Function
'Returns a hash code for this Area structure.
Public Overrides Function GetHashCode() As Integer
Return Me.ToString().GetHashCode()
'https://stackoverflow.com/a/11142338/2705042
End Function
'Return a human-readable string that represents this Area structure in the format "Width, Height"
'(width-comma-space-height).
Public Overrides Function ToString() As String
Return Width.ToString() & ", " & Height.ToString
End Function
'Return a human-readable string that represents this Area structure in the specified format.
'(not yet implemented)
'TODO: Add code here to process replaceable parameters to define the format, similar to "m/d/yyyy"
'in Strings.Format().
'Public Overloads Function ToString(ByVal format As String) As String
' Return Width.ToString() & ", " & Height.ToString
'End Function
'Tests whether two Area structures have equal dimensions.
Public Shared Operator =(Area1 As Area, Area2 As Area) As Boolean
If Area1.Width = Area2.Width AndAlso Area1.Height = Area2.Height Then
Return True
Else
Return False
End If
End Operator
'Tests whether two Area structures have different dimensions.
Public Shared Operator <>(Area1 As Area, Area2 As Area) As Boolean
If Area1.Width <> Area2.Width OrElse Area1.Height <> Area2.Height Then
Return True
Else
Return False
End If
End Operator
End Structure