编译器警告CS1723“关于XML注释的cref属性'T'引用类型参数”是什么?

ror*_*.ap 5 c# code-documentation compiler-warnings visual-studio visual-studio-2017

给出以下代码:

/// <summary>
/// Implementations represent a configuration with a specific data 
/// type <see cref="T"/> that can be used by this application.
/// </summary>
internal interface IConfiguration<T>
{
}
Run Code Online (Sandbox Code Playgroud)

我得到一个编译器警告CS1723T内部see crefXML元素:

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

在这种情况下,MS Docs完全没有用。我为什么要关心这个警告?是什么原因呢?

Mat*_*int 10

您应该在<typeparamref name="T" />这种情况下使用。

https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/xmldoc/typeparamref


Adr*_*ian 8

see cref(交叉引用)旨在指向实际类型(例如作为生成文档中的超链接)。类型参数在这个地方没有任何意义,因为事先不知道将使用什么类型。

要记录类型参数,请使用

<typeparamref name="name"/>