开发者

Can I reference an overloaded method using C# documentation tags?

开发者 https://www.devze.com 2022-12-23 16:15 出处:网络
In this particular code sample I want to reference the second overloaded method (int n) from C# documentation tags:

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 DoSom开发者_JAVA百科ething(int n)  {
}
void DoSomething(string str) { 
}

But how?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消