XML Documentation with ParamArray
-
Wednesday, March 07, 2012 1:15 PM
Hello...
I am trying to use xml documentation tool in my application. one of my methods receives 'ParamArray' as an argument. i want to document this argument elements.
here is my code
Public Sub LoadSearch_ByEmployee(ByVal EmployeeID As Integer _ , ByVal FromDate As Date _ , ByVal ToDate As Date _ , ByVal ParamArray Parameters() As String _ ) Implements ITransactionViewCollection.LoadSearch_ByEmployeethe 'parameters' argument first element would be the company ID, secondly would be department ID. what i want is to add xml documentation for this method and specify the expected values of each index in the ParamArray, something like this
''' <param name="Parameters"> ''' <params> ''' <param name="Parameters[0]">company ID</param> ''' <param name="Parameters[1]">Department ID</param> ''' </params>any idea to do this
thanks
All Replies
-
Wednesday, March 07, 2012 2:01 PM
What if no or more than two arguments are passed? As the number of parameters is undefined by the signature, it's impossible to refer to specific items in the array.
If you have no, one ore two arguments, I suggest you add overloaded versions of the function or use optional parameters instead of using a ParamArray.
Armin
- Edited by Armin Zingler Wednesday, March 07, 2012 2:14 PM
- Proposed As Answer by Mark Liu-lxfModerator Friday, March 09, 2012 2:18 AM
- Marked As Answer by Mark Liu-lxfModerator Thursday, March 15, 2012 8:11 AM
-
Thursday, March 15, 2012 9:38 AM
Thanks for your reply Armin, and regarding to method overloading, i cannot overload the method because it is an implementation of base interface method.
this method should exactly has two paramaters when its implemented in this class, while in another class it may has three or more parameters
-
Thursday, March 15, 2012 9:58 AM
Ok, I see. However, documentation is based on the method signature no matter how the method will be called.
If possible, you can add another method with exactly the parameters you need and write the matching documentation. The function would call the one posted above. You can even declare the above one private so that it's at least not visible to the outside (as long as the referencing expression is of type YourClass and not of type ITransactionViewCollection). It would still implement ITransactionViewCollection.LoadSearch_ByEmployee.
In other words:
Interface I Sub method(ByVal param1 As Integer, ByVal ParamArray params As String()) End Interface Class Base Implements I Private Sub Method(ByVal param1 As Integer, ByVal ParamArray params() As String) Implements I.method End Sub Public Sub Method(ByVal param1 As Integer, ByVal param2 As String) Method(param1, New String() {param2}) End Sub End ClassYou need "New String() {param2}" to call the ParamArray version and to avoid recursion.
Now you can add a comment to the second method as you like.
Armin
- Edited by Armin Zingler Thursday, March 15, 2012 9:58 AM
-
Thursday, March 15, 2012 10:38 AM
thanks for your reply, i will try it and tell you the results...

