Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is compiler warning CS1723 "XML comment has cref attribute 'T' that refers to a type parameter" all about?

Given this code:

/// <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>
{
}

I'm getting a compiler warning CS1723 on T inside the see cref XML element:

XML comment has cref attribute 'T' that refers to a type parameter

MS Docs is completely useless in this case. Why should I care about this warning? What is the reason for it?

like image 916
rory.ap Avatar asked Nov 05 '18 15:11

rory.ap


2 Answers

To reference a type parameter, use <typeparamref name="T" />.

/// <summary>
/// Implementations represent a configuration with a specific data 
/// type <typeparamref name="T" /> that can be used by this application.
/// </summary>
internal interface IConfiguration<T>
{
}
like image 54
Matt Johnson-Pint Avatar answered Nov 15 '22 12:11

Matt Johnson-Pint


see cref (cross reference) is meant to point to an actual type (eg as a hyperlink in the generated docs). A type parameter doesn't make any sense in this place since it is not known beforehand what type is going to be used.

To document type parameters use

<typeparamref name="name"/>

like image 5
adjan Avatar answered Nov 15 '22 12:11

adjan