从 C# 中的接口继承 XML 注释 [英] Inheriting XML comments from interfaces in C#
问题描述
我想知道是否有人知道如何将接口 xml 注释链接到实现.问题是我希望基本评论首先来自我的界面.示例:
I was wondering if anyone knows how to link an interface xml comment to an implementation. The problem is that I want the base comments to come from my interface first. Example:
interface myinterface {
/// <summary>
/// Does something.
/// </summary>
void method1(string foo);
}
然后实现是:
public class myclass : myinterface {
public void method1(string foo) {
//do something...
}
}
所以现在如果我在实例化对象后用鼠标悬停在方法上:
So now if I hover over the method with my mouse after instantiating the object:
myclass foo = new myclass();
foo.method1("do something");
如何让评论出现在悬停弹出窗口中?有什么方法可以将接口注释链接到实现吗?我知道 Java 中有一种方法,但找不到 C# 的解决方案.
how can I make the comments appear in the hover popup? Is there some way I can link the interface comments to the implementation? I know there's a way in Java, but can't find the solution for C#.
谢谢
推荐答案
更新答案:
使用<inheritdoc/>
-标签.
旧答案:
恕我直言,链接 XML 评论是不可能的,但您可以使用像 GhostDoc 将 XML 注释从接口/基类复制到实现/派生类.
Old Answer:
Linking XML Comments is IMHO not possible, but you could use a tool like GhostDoc to copy the XML Comment from your Interface/Baseclass to the implementation/derived class.
这篇关于从 C# 中的接口继承 XML 注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!