简体   繁体   English

如何显示关于函数重载的一般注释

[英]How to show general comments on function overloads

I have created a function with some overloads.我创建了一个带有一些重载的函数。 Now I want to add comments for each overload but not repeating summary content again and again.现在我想为每个重载添加注释,但不要一次又一次地重复摘要内容。 I only want parameter description to be given.我只想给出参数描述。

ie IE

    /// <summary>
    /// Binds Control With DataTable/DataSet Passed as a Parameter. DataTable/Control Should not be NULL.
    /// </summary>
    /// <param name="lbx">DropDownList control</param>
    /// <param name="dt">Object of DataTable from where value need be fetched.</param>
    /// <param name="displayMember">Display Member for the list</param>
    public static void Source(this DropDownList ddl, DataTable dt, string displayMember)
    {
     // do something.
    }

    /// <summary>
    /// Binds Control With DataTable/DataSet Passed as a Parameter. DataTable/Control  
    /// </summary>
    /// <param name="lbx">DropDownList  control</param>
    /// <param name="dt">Object of DataTable from where value need be fetched.</param>
    /// <param name="displayMember">Display Member for the list</param>
    /// <param name="_setDefaultItem">If True Sets the default value as -1 and corresponding string</param>
    public static void Source(this DropDownList ddl, DataTable dt, string displayMember, bool _setDefaultItem)
    {
     //do something
    }

Here I dont want to write summary section again and again but want to write comments on parameter portion only.在这里我不想一次又一次地写摘要部分,而只想写对参数部分的评论。 Rest should be visible for every overload.对于每个超载,休息都应该是可见的。

Is there any way to do?有什么办法吗?

You can use include tag to achieve this.您可以使用include标签来实现这一点。

Create a xml file with common summary, parameter descriptions of your overloaded methods.创建一个 xml 文件,其中包含重载方法的通用摘要和参数描述。

And reference this in your every overloaded method, and add method specific param list comments alone in your overloaded method.并在您的每个重载方法中引用它,并在您的重载方法中单独添加特定于方法的参数列表注释。

/// <include file='common_tag.doc' path='MyDocs/MyMembers[@name="source"]/*' />
public static void Source(this DropDownList ddl, DataTable dt, string displayMember) 
{ 
 // do something. 
} 

/// <include file='common_tag.doc' path='MyDocs/MyMembers[@name="source"]/*' />
/// <param name="_setDefaultItem">If True Sets the default value as -1 and corresponding string</param> 
public static void Source(this DropDownList ddl, DataTable dt, string displayMember, bool _setDefaultItem) 
{ 
 //do something 
} 

And ur xml file is something like你的xml文件就像

<MyDocs>

<MyMembers name="source">
<summary>
Binds Control With DataTable/DataSet Passed as a Parameter. DataTable/Control Should not be NULL
</summary>
<param>....</param>
</MyMembers>


</MyDocs>

i haven't tested this... you may try this我还没有测试过这个……你可以试试这个

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

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