10

How do you reference a type parameter in XML code documentation? For instance, this code

/// <summary>
/// An interface.
/// </summary>
/// <typeparam name="TInterface">Type paramter.</typeparam>
public interface IFace<TInterface>
{
    /// <summary>
    /// Does the thing.
    /// </summary>
    /// <typeparam name="TMethod">Different from <see cref="TInterface"/>.</typeparam>
    /// <returns>An integer.</returns>
    int SomeMethod<TMethod>();
} 

Gives a warning about typeparam name="TMethod":

XML comment has cref attribute 'TInterface' that refers to a type paramter.

This question asks about referencing a generic type, but I want to reference the type parameter.

BurnsBA
  • 4,347
  • 27
  • 39

1 Answers1

11

Instead of using see cref, the typeparamref should be used instead:

/// <summary>
/// An interface.
/// </summary>
/// <typeparam name="TInterface">Type paramter.</typeparam>
public interface IFace<TInterface>
{
    /// <summary>
    /// Does the thing.
    /// </summary>
    /// <typeparam name="TMethod">Different from <typeparamref name="TInterface"/>.</typeparam>
    /// <returns>An integer.</returns>
    int SomeMethod<TMethod>();
} 
BurnsBA
  • 4,347
  • 27
  • 39