13

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.

0

1 Answer 1

15

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>();
} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.