如何在 XML 文档中引用类型参数?
How to reference type parameter in XML documentation?
如何在 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>();
}
给出关于 typeparam name="TMethod"
的警告:
XML comment has cref attribute 'TInterface' that refers to a type paramter.
This question询问引用泛型类型,但我想引用类型参数。
而不是使用 see cref
,应该使用 typeparamref
:
/// <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>();
}
如何在 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>();
}
给出关于 typeparam name="TMethod"
的警告:
XML comment has cref attribute 'TInterface' that refers to a type paramter.
This question询问引用泛型类型,但我想引用类型参数。
而不是使用 see cref
,应该使用 typeparamref
:
/// <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>();
}