38

评论这个的正确方法是什么?

/// <summary>
/// Initializes a new instance of the <see cref="Repository"/> class.
/// </summary>
/// <param name="unitOfWork">The unit of work.</param>
public Repository(IUnitOfWork unitOfWork)
{
    this.UnitOfWork = unitOfWork;
}

VS抱怨它:

警告 11 关于“Data.Repository.Repository(Data.IUnitOfWork)”的 XML 注释具有无法解析的 cref 属性“Repository” C:\Projects\xx\yy\DataAccess\Repository.cs 35 58 数据

4

2 回答 2

49

您需要使用花括号:

/// <summary>
/// Initializes a new instance of the <see cref="Repository{T}"/> class.
/// </summary>

对于每个typeparam,只需在大括号中添加一个附加值,用逗号分隔。

于 2011-07-29T03:00:31.417 回答
4

StyleCop 已经定义了它的外观

如果类包含泛型参数,则可以使用以下两种格式之一在 cref 链接中对其进行注释:

/// <summary>
/// Initializes a new instance of the <see cref="Customer`1"/> class.
/// </summary>
public Customer()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="Customer{T}"/> class.
/// </summary>
public Customer()
{
}
于 2018-03-13T11:11:47.687 回答