Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference type parameter in XML documentation?

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.

like image 861
BurnsBA Avatar asked Feb 24 '26 15:02

BurnsBA


1 Answers

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>();
} 
like image 97
BurnsBA Avatar answered Feb 27 '26 04:02

BurnsBA