如何在实现满足 StyleCop 的接口时自动化 property/method headers

How to automate property/method headers when implementing an interface to satisfy StyleCop

我们使用 StyleCop 强制对我们的代码进行文档记录。

StyleCop(开箱即用)需要记录属性和方法。理论上,接口及其具体化可以有不同的 header,但实际上它们通常是相同的。

但是,当在具体实现接口时,header 不会被复制过来,这意味着它必须手动完成。有没有更好的方法来自动执行此操作而不是必须复制每个?

显然我们可以简单地复制接口代码,但是你会丢失很多存根代码,所以这并不是一个完美的解决方案。

我发现 Atomineer Pro Documentation 做得很好。我相信概述中的陈述总结了您的要求。

Intelligent automatic duplication of existing documentation for overrides of interface and base class methods, throughout groups of overloaded methods, and across related parameters within a class to maximise documentation consistency with minimal effort.

有免费试用,如果你想测试一下运行,看看它是否满足你的需求。

Comparison

您可以使用 Ghostdoc,Visual Studio 的插件。安装后,只需右键单击属性,类 或方法,然后单击 "Document This"。

如果您有很长的属性或方法,您可以使用Resharper自动实现和复制接口文档。