tags:

views:

70

answers:

2

In this particular code sample I want to reference the second overloaded method (int n) from C# documentation tags:

/// <summary>
/// The method to pass an integer to is <see cref="DoSomething">
/// </summary>

void DoSomething() {
}
void DoSomething(int n)  {
}
void DoSomething(string str) { 
}

But how?

A: 

When ReSharper helps me complete cref attributes, it includes the argument types when there are overloads (i.e. DoSomething(int)). I'm assuming that this is the valid way to do that.

bdukes
+2  A: 

When Visual Studio generates the XML documentation file containing the comments for the associated assembly each documented member will be identified by a unique name. You can check the rules for this ID generation at:

Processing the XML File (C# Programming Guide)

Of special interest would be the rule for methods with base type arguments, that says:

For properties and methods, if there are arguments to the method, the argument list enclosed in parentheses follows. If there are no arguments, no parentheses are present. The arguments are separated by commas. The encoding of each argument follows directly how it is encoded in a .NET Framework signature:

  • Base types. Regular types (ELEMENT_TYPE_CLASS or ELEMENT_TYPE_VALUETYPE) are represented as the fully qualified name of the type.
  • ...

In your case would result in a ID of (M:YourNamespace.YourType.DoSomething(System.Int32)), which could then be used in the cref attributes.

João Angelo
Great detail. Thanks.
Jeff Yates