简体   繁体   English

C#方法参数XML文档问题

[英]C# method parameter XML-documentation issue

Assume, i have a method which parameters are classes with already defined documentation: 假设我有一个方法,其中参数是具有已定义文档的类:

/// <summary>
///     Get criterion from table.
/// </summary>
/// <param name="plySide"></param>
/// <param name="criterionType"></param>
/// <returns></returns>
public Criterion GetCriterion(PlySide plySide, CriterionType criterionType)
{
   // some code
}

PlySide class has it's own xml-documentation: PlySide类具有自己的xml文档:

/// <summary>
///     Sides of monoply.
/// </summary>
public enum PlySide
{
   // some code
}

As you can see in GetCriterion method i didn't define any doc for the plySide param tag. 如您在GetCriterion方法中看到的,我没有为plySide param标签定义任何文档。 My question is should i duplicate description of a parameter or should i remove param tags? 我的问题是我应该重复参数的描述还是应该删除参数标签?

You shouldn't duplicate it but give a context aware description of the parameter. 您不应复制它,而应给出参数的上下文相关描述。 In your case it could be something like this (perhaps it's toally wrong, but I don't know the implementation and intention of your method): 在您的情况下,可能是这样的(也许是完全错误的,但是我不知道您方法的实现和意图):

/// <summary>
///     Get criterion from table.
/// </summary>
/// <param name="plySide">Monopoly side to get criterion for</param>
/// <param name="criterionType">Criterion to get for the given monopoly side</param>
/// <returns></returns>
public Criterion GetCriterion(PlySide plySide, CriterionType criterionType)
{
   // some code
}

The PlySide documentation will describe what the type is . PlySide文档将描述类型是什么

The plySide documentation should describe what role that parameter plays within the GetCriterion method. plySide文档应描述该参数GetCriterion方法中扮演GetCriterion

Those will usually be subtly (or not so subtly) different. 这些通常会微妙(或不太微妙)不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM