.NET的XML文档 - 继承文件文档、文件、NET、XML

2023-09-02 10:43:10 作者:这般废物

NDoc的具有XML元素 inheritdoc ,它允许你继承父类成员(或已实现的接口)的文件。但是,Visual Studio中(即C#编译器)不明白这个标记和抱怨的文件不被present或完整。这样做了StyleCop和一些其他工具。是否有其他方法吗?你怎么去保持文档完整,但没有重复的XML描述?

NDoc has an XML element inheritdoc which allows you to inherit documentation of a member from the parent class (or an implemented interface). However, Visual Studio (i.e. the C# compiler) does not understand this tag and complains about the documentation not being present or complete. So does StyleCop and some other tools. Is there an alternative approach? How do you go about keeping the docs complete, yet without duplicating the XML descriptions?

推荐答案

一种替代方法是使用 GhostDoc - 一个加载项的Visual Studio自动生成的评论你。这种复制过程中的XML描述,这是你想要什么,以避免部分 - 但至少它会自动为你

One alternative is to use GhostDoc - an add-in for Visual Studio that automatically generates comments for you. This duplicates the XML description of course, which is part of what you're trying to avoid - but at least it does it automatically for you.

如果你只是离开关闭文档完全是为这些被继承的方法,或压倒一切的接口方法会发生什么?我怀疑这取决于你如何配置了NDoc的,但肯定是在MSDN文档似乎天生就继承文档 - 和一个快速检查的提示的是VS不会whinge当你不prodive文档来继承的方法。值得一试,当然。

What happens if you just leave off the docs entirely for methods which are being inherited, or overriding interface methods? I suspect it depends on how you've got NDoc configured, but certainly in MSDN documentation seems to just naturally inherit the docs - and a quick check suggests that VS won't whinge when you don't prodive docs for an inherited method. Worth a try, certainly.