如何在XML文档中引用类型参数?

Bur*_*sBA 11 c# code-documentation visual-studio

如何在 XML 代码文档中引用类型参数?例如,这段代码

/// <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>();
} 
Run Code Online (Sandbox Code Playgroud)

给出警告typeparam name="TMethod"

XML 注释具有引用类型参数的 cref 属性“TInterface”。

这个问题询问有关引用泛型类型,但我想引用类型参数。

Bur*_*sBA 13

不应使用see creftypeparamref而应使用 :

/// <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>();
} 
Run Code Online (Sandbox Code Playgroud)