我有一个类(用C#编写),带有一些文档注释:
/// <summary>
/// Abstract class defining a tolerance-based method for Equals.
/// Tolerance must be defined in a derived class like this:
/// <code>class MyPrec : Precision { private MyPrec() : base(42) {} }</code>
/// (This subclass will have a tolerance of 42.)
/// </summary>
public abstract class Precision
{
protected readonly double TOL;
protected Precision(double tol)
{
TOL = tol;
}
/// <summary>
/// Checks if two doubles are equal up to numerical tolerance given by TOL.
/// </summary>
/// <param name="left">First double.</param>
/// <param name="right">Second double.</param>
/// <returns>True if the absolute value of the difference is at most TOL,
/// false otherwise.</returns>
public bool Equals(double left, double right)
{
return Math.Abs(left - right) <= TOL;
}
/// <summary>
/// Not Equals.
/// </summary>
public bool NotEquals(double left, double right)
{
return !Equals(left, right);
}
}
如果我通过Visual Studio的重命名功能在left
方法中重命名参数Equals
,它也会自动在文档注释中重命名。但似乎这只适用于即时参数。
如何编写文档注释,以便在重命名相应的类/字段/方法时Visual Studio还会更新以下单词?
Precision
的摘要注释的代码示例中的 Precision
/// <code>class MyPrec : Precision { private MyPrec() : base(42) {} }</code>
TOL
的返回注释中的 Equals
/// <returns>True if the absolute value of the difference is at most TOL,
Equals
的摘要评论中的 NotEquals
/// Not Equals.
我正在使用Visual Studio 2015。
我已经尝试了
/// <returns>True if the absolute value of the difference is at most <paramref name="TOL"/>,
但它不起作用。毕竟它不是输入参数。
答案 0 :(得分:1)
对于TOL和Equals,这很简单。在评论中引用其他代码成员时,请使用<see>标记。重命名将应用于此类元素。在您的情况下,评论将是:
/// <returns>True if the absolute value of the difference is at most <see cref="TOL"/>,
和
/// Not <see cref="Equals"/>.