0

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

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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

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

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.