5

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?

Community
  • 1
  • 1
Ignacio Calvo
  • 754
  • 9
  • 22

2 Answers2

3

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)" />.

Ignacio Calvo
  • 754
  • 9
  • 22
0

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.

  • I wanted to write something like `` (this is the C# way) in an xml-doc comment. It seems that this issue has been fixed in VS2013. – Ignacio Calvo Jan 23 '14 at 19:43
  • And by the way, `FancyClass(Of String` is certainly a class (you can create instances of that class); `FancyClass(Of T)` is just a class template; you cannot create object instances of that thing. – Ignacio Calvo Jan 23 '14 at 19:45
  • Yep, when i said it's not a class, i thought in xml-doc way : you can't write `` – Frédéric THEVENON Jan 24 '14 at 08:41