实现类是否可以从其实现的接口“继承”XML注释?

时间:2022-09-24 23:34:09

Curious question. I'm using Microsoft's Sandcastle to generate documentation from the XML comments in my C# code. Several of my classes are implementing interfaces which already have commented methods. I'd rather not duplicate the documentation in both the interface method and the public implemented method. Is there some kind of tag I can use to "inherit" this documentation from the interface?

好奇的问题。我正在使用Microsoft的Sandcastle从我的C#代码中的XML注释中生成文档。我的几个类正在实现已经有注释方法的接口。我宁愿不在接口方法和公共实现方法中复制文档。是否有某种标签我可以用来从界面“继承”这个文档?

3 个解决方案

#1


This feature does not exist currently in Visual Studio.

此功能目前在Visual Studio中不存在。

You can get third party tools, such as GhostDoc that will help with creating XML documentation. GhostDoc also has the option to generate documentation that was "inherited" like you are attempting to do.

您可以获得第三方工具,例如GhostDoc,它将有助于创建XML文档。 GhostDoc还可以选择生成像您尝试的那样“继承”的文档。

Link: GhostDoc

#2


You can add <inheritdoc/> in the implementation.

您可以在实现中添加

You should have a look on the following thread: Ways to synchronize interface and implementation comments in C#

您应该看看以下线程:在C#中同步接口和实现注释的方法

#3


In case anyone else is looking for a solution, I built a library to post-process the XML documentation files to add support for an <inheritdoc/> tag.

如果其他人正在寻找解决方案,我构建了一个库来对XML文档文件进行后处理,以添加对 标记的支持。

More info at www.inheritdoc.io (free version available).

更多信息请访问www.inheritdoc.io(免费版)。

#1


This feature does not exist currently in Visual Studio.

此功能目前在Visual Studio中不存在。

You can get third party tools, such as GhostDoc that will help with creating XML documentation. GhostDoc also has the option to generate documentation that was "inherited" like you are attempting to do.

您可以获得第三方工具,例如GhostDoc,它将有助于创建XML文档。 GhostDoc还可以选择生成像您尝试的那样“继承”的文档。

Link: GhostDoc

#2


You can add <inheritdoc/> in the implementation.

您可以在实现中添加

You should have a look on the following thread: Ways to synchronize interface and implementation comments in C#

您应该看看以下线程:在C#中同步接口和实现注释的方法

#3


In case anyone else is looking for a solution, I built a library to post-process the XML documentation files to add support for an <inheritdoc/> tag.

如果其他人正在寻找解决方案,我构建了一个库来对XML文档文件进行后处理,以添加对 标记的支持。

More info at www.inheritdoc.io (free version available).

更多信息请访问www.inheritdoc.io(免费版)。