如何在中为方法重载创建 cref C# 中的标签?
我在 MSDN 中看到诸如“CompareOrdinal Overloads”之类的链接。我怎样才能用C#编写这样的链接?
我尝试过:
<seealso cref="MyMethod">MyMethod Overloads</seealso>
但是编译器向我发出警告,警告我对具有其他重载的方法的引用不明确。
(初学者问题:我实际上需要编写此标签来链接到重载,还是由文档处理器自动生成?)
I see in MSDN links such as "CompareOrdinal Overloads". How can I write such a link in C#?
I tried:
<seealso cref="MyMethod">MyMethod Overloads</seealso>
But the compiler gives me a warning about being an ambiguous reference for the method which has other overloads.
(Beginner question: do I actually need to write this tag to link to the overloads, or is it automatically generated by documentation processors?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要针对特定成员,我相信您只需匹配签名即可:
说实话,我不确定如何生成“所有重载”链接;我假设任何明智的生成器都会自动执行此操作。
To target specific members, I believe you just match the signature:
To be honest, I'm not sure how to generate an "all overloads" link; I'd assume that any sensible generator did this automatically.
使用Sandcastle很简单:
FullyQualifiedMyMethod是达到重载所需的完整路径,包括命名空间和类,即:System.Linq.Enumerable.Sum
但是VB编译器会发出警告,指出该属性无法解析,可以忽略。
Using Sandcastle it is simple:
FullyQualifiedMyMethod is the complete route you need to reach the overload, including namespaces and classes, i.e.: System.Linq.Enumerable.Sum
However VB compiler issues a warning saying the attribute can not be resolved, which can be ignored.
Xml 文档没有办法引用方法的所有重载。
最流行的 C# 项目文档生成器是 Sandcastle。如有必要,它将自动创建指向重载列表页面的链接。因此,在成员列表页面中,重载方法的名称只会出现一次,单击它将导航到该方法的重载页面列表,并从那里导航到特定的重载。
在 Xml 文档中放置指向重载列表页面的链接需要对所使用的外部工具有深入的了解,这可能不是一个好主意。
如果您确实必须拥有这个,那么也许一种方法是使用具有特定形成的 ID 的锚点。大多数文档生成器提供了一些对生成的文件进行预处理或后处理的神秘方法,并且应该让您有机会挑选出这些锚点并为它们提供适当的 href。
哦,这可能比它的价值更麻烦;)
Xml documentation doesn't have a means to reference all overloads of a method.
The most popular documentation generator for C# projects is Sandcastle. It will automatically create a link to an overloads list page if necessary. Hence in a members list page the name of an overloaded method will appear only once, clicking it will navigate you to the list of overloads page for that method and from there to a specific overload.
Placing a link to the overloads list page in Xml documentation would require intimate knowledge of the external tool being used and probably not a good idea.
If you really must have this then perhaps one way is to use an anchor with a specificaly formed ID. Most document generators provide some arcane means of pre or post processing generated files and should give you the opportunity to pick these anchors out and provide an appropriate href for them.
OTH, it may be more trouble than its worth ;)