开发者

What's the proper way to comment a constructor in a generic class?

开发者 https://www.devze.com 2023-03-24 05:10 出处:网络
What\'s the proper way to comment this? /// <summary> /// Initializes a new instance of the <see cref="Repository"/> class.

What's the proper way to comment this?

/// <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 complains about it:

Warning 11 XML comment on 'Data.Repository.Repository(Data.IUnitOfWork)' has cref attribute 'Repository' that coul开发者_如何转开发d not be resolved C:\Projects\xx\yy\DataAccess\Repository.cs 35 58 Data


You need to use curly braces:

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

For each typeparam, just add an additional value in the braces, delimited with a comma.


StyleCop has defined how it should look like.

If the class contains generic parameters, these can be annotated within the cref link using either of the following two formats:

/// <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()
{
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号