Svish
Svish

Reputation: 158191

C#, XmlDoc: How to reference method overloads

If I have these two methods

public Foo Get(string bar) { ... }
public Foo Get(int bar) { ... }

And write this piece of xml documentation on a different method

/// <summary>
/// Has a close relation to the <see cref="Get"/> methods.
/// </summary>

I get a blue squiggly under Get, saying that it is an Ambiguous reference 'Get'. which is true, but I want it to reference both. What is the correct way of doing this? Or should am I only supposed to reference a single method overload?

Upvotes: 33

Views: 4651

Answers (2)

JNYRanger
JNYRanger

Reputation: 7097

Here's an updated answer to this old question. I'm not sure when this became valid because there isn't much documentation out there. If you prefix a cref attribute with "o:..." such as in "o:myMethod()" it will link to the overload section and cover all of the overloads of that method. Using Daniel Elliott's answer's example:

/// Has a close relation to the <see cref="o:Get()"/> methods.  

This will also remove warnings from Intellisense / Resharper about ambiguous references.

Upvotes: 4

Daniel Elliott
Daniel Elliott

Reputation: 22867

Try

/// Has a close relation to the <see cref="Get(string)"/>  
/// and <see cref="Get(int)" /> methods.

You may need full typenames but intellisense should help as soon as you put first bracket in.

Hope that helps,

Dan

Upvotes: 31

Related Questions