views:

50

answers:

2

Hi all..

Consider this scenario, 2 interfaces, 1 generic:

public IGenericAdder<T>
{
   T Add(T, T);
}

public IIntAdder : IGenericAdder<Int32>
{
}

Is there someway that I can do XML comments on the generic add method, so that intellisense will show "Adds the Int32" if I do a:

IIntAdder foo;
foo.Add(  //Show intellisense here
A: 

You don't need a doc comment - Visual Studio automatically fills in the generic type argument into the tooltip.

Andrew Hare
Ye, but say I want some custom comment in the Add method, but I also want my comment to write "Int" instead of "T" where the generic parameter has been specified
cwap
+1  A: 

I don't think there is a way. You could:

  • Make the comment generic enough to work (ie. "Adds two items together") and let the user infer the type from the Visual Studio generated docs/tooltip.
  • Hide the T Add(T, T) method of IGenericAdder with new int Add(int, int) in IIntAdder and put specific XML docs on it that refer to the correct types (ie. "Adds two ints together").
  • Use <see cref="T"/> in the XML docs, but Visual Studio just refers to it as T.

None of these really do what you originally asked though.

adrianbanks
Yes, that seems to be my conclusion as well :(
cwap