In xml doc, can I insert a reference to a method group? How?
-
05-07-2019 - |
Question
In C#, I can attach documentation for properties, methods, events, and so on, directly in the code using XML Documentation Comments.
I know how to insert a reference to a particular method:
<see cref="MethodName(TypeForArg1, TypeForArg2..)"/>
Is there a way to insert a reference to a method group? Where I've got multiple overloads of the same method name...
I tried
<see cref="M:MethodName"/>
..but that did not work.
EDIT: BUMP
Solution
Apparently there is no way to do this.
OTHER TIPS
It appears that this was be fixed at least in Visual Studio 2012:
<see cref="MethodName"/>
Will generate a warning:
Ambiguous reference in cref attribute: 'MethodName'. Assuming '…', but could have also matched other overloads including '…'.
But adding an M:
in front get's rid of the warning:
<see cref="M:MethodName"/>
This is now supported in Sandcastle.
To reference a method group, the following syntax is required:
/// <summary>
/// Reference to a method group with two items:
/// <see cref="O:Full.Declaring.Namespace.TypeName.Foo"/>
/// </summary>
void Foo() { }
void Foo(int x) { }
Note that this syntax does still have some limitations, as described this C# language feature request.
- The syntax is not validated during build. Errors made while typing are not reported until if/when Sandcastle Help File Builder processes the comments.
- The syntax only works if there are more than one method with the same name.
- There is no syntax highlighting or editor support for this syntax.