How to reference a parameter of a different method?

别来无恙 提交于 2019-12-08 18:00:20

问题


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.)


回答1:


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();
}


来源:https://stackoverflow.com/questions/44000345/how-to-reference-a-parameter-of-a-different-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!