Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference a parameter of a different method?

Tags:

c#

sandcastle

Is it possible to reference a parameter from a different method than the one you are writing a summary for, and if so what is the syntax.

I know about <paramref name="..."/> but I don't know how to reference from a different method.

Simple humorous example in case I'm not making myself clear:

/// <summary>
/// Does magical Foo things!
/// </summary>
/// <param name="magic">Magic Toggle!</param>
public void Foo(bool magic)
{
    //...
}

/// <summary>
/// Does Bar things. More down to earth, no <paramref name="Foo(bool).magic"/> involved!
/// </summary>
public void Bar()
{
    //...
}

(Obviously the above is not a great use case, it's just for illustratory purposes.)

like image 773
AnorZaken Avatar asked May 16 '17 11:05

AnorZaken


1 Answers

There is no recommended tag for this.

I suspect the reason why there is no recommended tag is because the primary use-case of this documentation is generated documentation in the style of the MSDN pages which doesn't make use of links to specific parameters of other methods. That said, its not a spec, just a recommendation. any valid XML you write will end up in the output XML file, so if you have a custom documentation generator which would make use of this there is nothing stopping you from adding "custom" tags that do whatever it is you need.

Personally I'd just do something like this:

interface IFoo
{
    void Foo(object otherParam);

    /// <summary>Documentation for this method.</summary>
    /// <returns>The object passed as the otherParam argument of
    /// the <see cref="Foo" /> method.</returns>
    object Bar();
}
like image 176
Justin Avatar answered Oct 12 '22 23:10

Justin