我应该为代理方法使用什么文档标签
What documentation tag should I use for proxy method
假设我有这样的代码:
class A
{
/// <summary>
/// Some important text here
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="c"></param>
public void Method1(int a, int b, int c)
{
}
}
class B
{
private A a = new A();
// I'd like to show A.Method1 documentation here
public void Method1(int a, int b, int c)
{
this.a.Method1(a, b, c);
}
}
是否有任何标准文档标签(例如,足以在 Visual Studio 中显示正确文档的标准)可以实现这一点?
我想做这样的事情:
/// <SomeMagicTag ref="A.Method1" />
public void Method1(int a, int b, int c)
并让 visual studio 在我使用 B.Method1
.
时向我展示 A.Method1
的文档
您可以使用 cref 属性来引用 Class A.
的方法
The cref attribute in an XML documentation tag means "code reference." It specifies that the inner text of the tag is a code element, such as a type, method, or property
看看微软文档:
cRef Attribute
我有点明白了。遗憾的是,此方法不适用于 visual studio intellisense(至少在 VS2013 中无效),但它确实适用于 sandcastle 帮助文件生成器。
这是我的问题中经过编辑的示例,用于说明如何操作:
/// <inheritdoc cref="A.Method1" />
public void Method1(int a, int b, int c)
它可以通过使用 select
属性进一步自定义,该属性可以包含 xpath 查询以仅从引用的评论中继承选定的标签。
假设我有这样的代码:
class A
{
/// <summary>
/// Some important text here
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="c"></param>
public void Method1(int a, int b, int c)
{
}
}
class B
{
private A a = new A();
// I'd like to show A.Method1 documentation here
public void Method1(int a, int b, int c)
{
this.a.Method1(a, b, c);
}
}
是否有任何标准文档标签(例如,足以在 Visual Studio 中显示正确文档的标准)可以实现这一点?
我想做这样的事情:
/// <SomeMagicTag ref="A.Method1" />
public void Method1(int a, int b, int c)
并让 visual studio 在我使用 B.Method1
.
A.Method1
的文档
您可以使用 cref 属性来引用 Class A.
的方法The cref attribute in an XML documentation tag means "code reference." It specifies that the inner text of the tag is a code element, such as a type, method, or property
看看微软文档: cRef Attribute
我有点明白了。遗憾的是,此方法不适用于 visual studio intellisense(至少在 VS2013 中无效),但它确实适用于 sandcastle 帮助文件生成器。
这是我的问题中经过编辑的示例,用于说明如何操作:
/// <inheritdoc cref="A.Method1" />
public void Method1(int a, int b, int c)
它可以通过使用 select
属性进一步自定义,该属性可以包含 xpath 查询以仅从引用的评论中继承选定的标签。