Ignacio Calvo
Ignacio Calvo

Reputation: 834

VB.NET: How to reference generic classes and methods in xml documentation

Note: This is a copy of this question but for Visual Basic instead C#.

When writing XML documentation you can use <see cref="something">something</see>, which works of course. But how do you reference a class or a method with generic types?

Public Class FancyClass(Of T)

  Public Function  FancyMethod(value As T) As String
    Return "something fancy"
  End Function

End Class

If I was going to write xml documentation somewhere, how would I reference the fancy class? how can I reference a FancyClass(Of String)? What about the method?

For example in a different class I wanted to let the user know that I will return an instance of FancyClass(Of Integer). How could I make a see cref thing for that?

Upvotes: 5

Views: 1102

Answers (2)

Ignacio Calvo
Ignacio Calvo

Reputation: 834

Seems that you cannot do this thing in VS2012, but it has been fixed in VS2013; you can simply write <see cref="FancyClass(Of T)" />.

Upvotes: 3

I'm used to write something like that :

''' <summary>
''' A great fancy class.
''' </summary>
''' <typeparam name="T">Generic stuff ....</typeparam>
Public Class FancyClass(Of T)

    ''' <summary>
    ''' A fancy method that do fancy operation.
    ''' </summary>
    ''' <param name="value">The value.</param>
    ''' <returns></returns>
    Public Function FancyMethod(value As T) As String
        Return "something fancy"
    End Function

End Class

The xml documentation must talk about your generic class. You will never reference FancyClass(Of String) : this is not a class.

Upvotes: 0

Related Questions