In the c# block comments, I want to say that the default value for a particular parameter is a class const property. Is there a way to reference that parameter directly?
I'd like to either display the value in the generated documentation, or link to the property in some structured way.
This is an example of what I'm trying to do:
public class Foo
{
private const int DefaultBar = 20;
///<summary>
///Does the thing.
///</summary>
///<param name="bar">Description of bar. Defaults to [[DefaultBar]]</param>
public int DoTheThing(int bar = DefaultBar)
{
return bar;
}
}
Where [[DefaultBar]]
above is whatever syntax is necessary to reference the DefaultBar property.
Because it's a constant, I feel like there should be a way to reference it in the generated documentation without manually keeping them in sync. (I don't want to just replace [[DefaultBar]]
with 20
in case I want to change 20
later to some other int)
I looked at C# "Constant Objects" to use as default parameters but that question (and associated answers) don't bring up documentation.
Passing by by reference refers to a method of passing the address of an argument in the calling function to a corresponding parameter in the called function. In C, the corresponding parameter in the called function must be declared as a pointer type.
A constant reference is an expression that evaluates to the value of the named constant. The simplest constant references are primary expressions—they consist simply of the name of the constant: CM_PER_INCH = 2.54 # Define a constant. CM_PER_INCH # Refer to the constant.
The grammar doesn't allow you to declare a “const reference” because a reference is inherently const . Once you bind a reference to refer to an object, you cannot bind it to refer to a different object.
You can reference a constant like any other code member with the <see> comment tag. In your case it will be:
public class Foo
{
private const int DefaultBar = 20;
///<summary>
///Does the thing.
///</summary>
///<param name="bar">Description of bar. Defaults to <see cref="DefaultBar"/>.</param>
public int DoTheThing(int bar = DefaultBar)
{
return bar;
}
}
When you generate documentation from these comments, you'll get a link to the constant's page. For example, the output generated with VSdocman (our product) will look like:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With