在我们公司,我们编写了过多的Xml注释。一个典型的方法必须像这样进行文档化:
/// <summary>
/// Determines whether this <see cref="IScheduler"/> contains a specific <see cref="ISchedule"/>.
/// </summary>
/// <param name="schedule">The <see cref="ISchedule"/> to locate in this <see cref="IScheduler"/>.</param>
/// <returns>
/// Returns <see langword="true"/> if <paramref name="schedule"/> is found in this <see cref="IScheduler"/>; otherwise, <see langword="false"/>.
/// </returns>
bool Contains(ISchedule schedule);
/// <summary>
/// Removes and <see cref="IDisposable.Dispose"/>s the first occurrence of a specific <see cref="ISchedule"/>
/// from this <see cref="IScheduler"/>.
/// </summary>
/// <param name="schedule">The <see cref="ISchedule"/> to remove from this <see cref="IScheduler"/>.</param>
/// <exception cref="System.ArgumentNullException">Is thrown when the parameter schedule is null.</exception>
/// <exception cref="System.ArgumentException">Is thrown when the <see cref="ISchedule"/> is not found in this <see cref="IScheduler"/> or was of the wrong type.</exception>
void Remove(ISchedule schedule);
可以看到几乎每个名词都可以用<see cref>
标签进行引用。
我认为这太多了。我们的大多数代码文件都被这样的注释搞得一团糟。让注释部分几乎无法阅读。
你怎么想?你喜欢在代码中使用这种文档吗?
像往常一样,我认为这种问题没有黑白之分,所以我把它设为维基。
编辑:
我的问题不是默认情况下是否有用的see-ref-tags本身。 很明显,在.chm文件(或任何其他类型的生成文档)中生成的链接非常有用。 我的问题是是否真的有必要在注释中标记每个“可链接”的名词的每个出现。
我们使用Sandcastle每晚生成文档。 不幸的是,其他开发人员极少使用它,但这是另一个问题。
<c>null</c>
来区分它作为编程语言语法中的关键字,而不是使用“see”引用。 - Ray