cwap
cwap

Reputation: 11287

How to reference specific implementations of generic interfaces in XML comments?

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

Upvotes: 0

Views: 171

Answers (2)

adrianbanks
adrianbanks

Reputation: 82944

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.

Upvotes: 1

Andrew Hare
Andrew Hare

Reputation: 351536

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

Upvotes: 0

Related Questions