As the name states, I have no idea how to reference a dictionary indexer. Any help here? :)
FYI, I've tried:
<see cref="Item"/>
<see cref="Item(Int32)"/> //Highly doubted this would work.
<see cref="Item(TKey)"/>
<see cref="Item[TKey]"/>
C# documentation comments use XML elements to define the structure of the output documentation. One consequence of this feature is that you can add any valid XML in your documentation comments. The C# compiler copies these elements into the output XML file.
The use of XML doc comments requires delimiters that indicate where a documentation comment begins and ends. You use the following delimiters with the XML documentation tags: /// Single-line delimiter: The documentation examples and C# project templates use this form.
The first rule for commenting is it should have /// three slash for comments as C# supports C++ style commenting so commenting can be done by // -- two slashes -- but for Documentation /// is necessary. We will go through each one by one. You can add a paragraph to the description by using <para> tag.
You can use the full property syntax to reference indexers:
namespace ConsoleApplication1
{
/// <summary>
/// See indexer <see cref="P:ConsoleApplication1.MyDictionary`2.Item(`0)"/>
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
public class MyDictionary<TKey, TValue>
{
/// <summary>
/// Indexer
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public TValue this[TKey key]
{
get { return default(TValue); }
set { }
}
}
}
You can check that the property was resolved properly by inspecting the generated XML file:
<doc>
<assembly>
<name>ConsoleApplication1</name>
</assembly>
<members>
<member name="T:ConsoleApplication1.MyDictionary`2">
<summary>
See <see cref="P:ConsoleApplication1.MyDictionary`2.Item(`0)"/>
</summary>
<typeparam name="TKey"></typeparam>
<typeparam name="TValue"></typeparam>
</member>
<member name="P:ConsoleApplication1.MyDictionary`2.Item(`0)">
<summary>
Indexer
</summary>
<param name="key"></param>
<returns></returns>
</member>
</members>
</doc>
Notice how the first P:
matches the second one.
Finally, make sure it's working with Intellisense:
Update by Original Poster (myermian):
I did a little bit of digging and have discovered that the shortform of an indexer property is just "this". Ex: <see cref="this"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With