Visual Studio:重命名时更新的文档注释 classes/fields/methods
Visual Studio: Doc Comments that get updated when renaming classes/fields/methods
我有一个 class(用 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 的重命名功能重命名 Equals
方法中的参数 left
,它也会在文档注释中自动重命名。但似乎这只适用于直接参数。
如何编写文档注释,以便在重命名相应的 class/field/method 时,以下单词也被 Visual Studio 更新?
Precision
中classPrecision
的总结注释的代码示例
/// <code>class MyPrec : Precision { private MyPrec() : base(42) {} }</code>
TOL
在方法 return 注释中 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"/>,
但它不起作用。毕竟不是入参
- 精度,这个我觉得不行。
标签内的注释为自由文本。</li>
<li><p>对于 TOL 和 Equals,这很简单。当您在评论中引用另一个代码成员时,请使用 <a href="http://www.helixoft.com/files/vsdocman/help/aseelinkxml.htm" rel="nofollow"><see></a> 标签。重命名将应用于此类元素。在您的情况下,评论将是:</p>
<pre><code>/// <returns>True if the absolute value of the difference is at most <see cref="TOL"/>,
和
/// Not <see cref="Equals"/>.
我有一个 class(用 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 的重命名功能重命名 Equals
方法中的参数 left
,它也会在文档注释中自动重命名。但似乎这只适用于直接参数。
如何编写文档注释,以便在重命名相应的 class/field/method 时,以下单词也被 Visual Studio 更新?
的总结注释的代码示例Precision
中classPrecision
/// <code>class MyPrec : Precision { private MyPrec() : base(42) {} }</code>
TOL
在方法 return 注释中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"/>,
但它不起作用。毕竟不是入参
- 精度,这个我觉得不行。
标签内的注释为自由文本。</li> <li><p>对于 TOL 和 Equals,这很简单。当您在评论中引用另一个代码成员时,请使用 <a href="http://www.helixoft.com/files/vsdocman/help/aseelinkxml.htm" rel="nofollow"><see></a> 标签。重命名将应用于此类元素。在您的情况下,评论将是:</p> <pre><code>/// <returns>True if the absolute value of the difference is at most <see cref="TOL"/>,
和
/// Not <see cref="Equals"/>.