I understand how to use XML tags in order to populate Intellisense descriptions when calling methods. I would like to centralize the definitions of various parameters (6 of them) however so that I don't need to copy/paste the same XML tags across dozens of formulas with similar parameters.
It would also be helpful to define them as a single list, so that each method only has a single decorator, such as [MyCommonParameters], instead of 6 lines of definitions on each method.
For example, in this simplified code below, I have two functions which take the same inputs. It would be nice to only have to define the parameter descriptions once, for better maintainability once brought up to scale for the full project.
public static class MyClass
{
/// <param name="x">x description</param>
/// <param name="y">y description</param>
public static int Add_XY(int x, int y)
{
return x + y;
}
/// <param name="x">x description</param>
/// <param name="y">y description</param>
public static int Subtract_XY(int x, int y)
{
return x - y;
}
}
I have tried using decorators/attributes, but got stuck as the inputs seem to require static text, and can't be passed a variable containing the definition. I don't have a strong grasp on using attributes yet, so I may just be missing how it could be implemented using custom attributes.
Yes, there is a way, as described here.
For example, you could add a file to your project called "CodeDoc.xml" with the following contents:
And then change your XML comments to reference it like so:
You can change the
M:MyXYParamsto suit, but it must begin withM:as far as I know.