I've noticed Ghostdoc never seems to attempt to produce returns documentation. Given a method like this:
/// <summary>
/// Gets the departure date.
/// </summary>
/// <returns></returns>
private DateTime GetDepartureDate()
{
// TODO:
}
I'd expect it to populate the returns information like so:
/// <summary>
/// Gets the departure date.
/// </summary>
/// <returns>The departure date.</returns>
private DateTime GetDepartureDate()
{
// TODO:
}
I've seen this but this is quite old and to be honest, I don't really understand it. Any ideas?
Clearly it will never be perfect but anything is better than nothing.
By default, Ghostdoc does not attempt to provide any text for return types. However, you can set up a rule to do it, as suggested in the link in the question.
For example, to set a rule that adds a return description to any method with a name starting 'Get...' and using the rest of the method name for the text (as suggested in the question):
RulesunderGhostDocin the treeMethods'folder' in the right-hand Rules list (you may need to scroll the list)Add a new rule to match methods starting with 'Get...':
Add...andOKto add a new 'Custom match' rule<any>link aftermethod nameto set the conditionSelect
starts with, typefollowed by a space, in the text box and click
OKNow, to set the 'returns' template text:
...next to<returns>Type
followed by a space, in the 'Template text' box
MethodName>Words, selectExceptFirst, clickInsertandOKThe default summary text is overridden by the new rule, so to add something sensible for our new rule:
...button next to<summary>Type
followed by a space, in the Template text box
MethodName>Words, selectExceptFirst, clickInsertandOKOKto complete the setting up of the ruleEnsure the rule is positioned below the existing
int GetHashCode()rule so that the latter one will take precedence in that special case. Click OK to close the Options dialog and you're ready to try out the new rule.