编写开源库时应该遵循哪些 StyleCop 规则

发布于 2024-07-09 19:58:41 字数 1449 浏览 8 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

叶落知秋 2024-07-16 19:58:42

StyleCop 的总体思路是:全部 :)

关闭的选项越多,StyleCop 在强制执行 one-true 代码格式方面的价值就越小。 话虽这么说,如果您不喜欢某些选项,那么某些选项总比没有好,在您的代码中包含 StyleCop 设置文件,其他处理该文件的人可以使用相同的设置。

如果您不熟悉 StyleCop,有些设置一开始可能看起来很奇怪,但使用它两年了,现在我保留了所有选项,我们的团队对结果非常满意。

我还想说,如果您提供使用 FxCop 可能比使用 StyleCop 更重要。

The general idea with StyleCop is: All of them :)

The more options you turn off the less value StyleCop has in enforcing a one-true code format. That being said, if you don't like some of the options then some options is better than none, include the StyleCop settings file with your code and others working on it can then use the same settings.

Some of the settings may seem weird at first if you're not familiar with StyleCop, but having used it for two years now I leave all the options on and our team is quite happy with the results.

I'd also say that if you're providing a library or framework that using FxCop may be more important than using StyleCop.

看透却不说透 2024-07-16 19:58:42

大多数大型开源项目都有自己的风格指南。 例如,这里是Apache C 语言风格指南

首先,我建议搜索您感兴趣的操作系统项目的常见问题解答并从中获取。

不管怎样,我相信如果你严重违反了任何现有的风格规则,会有很多人很快让你知道! ;-)

请注意所有警告,通常它们试图告诉您一些有用的信息。 不要完成“巧合编程”(书籍摘录)正如务实的程序员所说!

编辑:我没有意识到这是您自己的新操作系统项目。 我的错。 不管怎样,我会仔细观察一些类似的现有操作系统项目,看看它们是否有任何风格指南。 当然,请查看 Steve McConnell 的书《Code Complete》(亚马逊链接 - 已针对脚本小子链接在这些大厅里游荡的纳粹分子)。

我所说的关于警告和“巧合编程”仍然适用! (-:

HTH。

干杯,

罗布

Most large open source projects have their own style guidelines. For example, here's the Apache C Language Style Guide.

As a start, I suggest trawling the FAQ for the OS project you're interested in and take it from there.

Anyway, I'm sure there'll be plenty of people who'll quickly let you know if you're breaking any existing style rules in a big way! ;-)

Take heed of all the warnings, usually they are trying to tell you something useful. Don't finish up "programming by coincidence" (book excerpt) as the Pragmatic Programmers say!

Edit: I didn't realise that this was your own, new, OS project. My bad. Anyway, I'd have a sniff around some similar already existing OS projects and see if they have any style guides. Definitely, check out Steve McConnell's book Code Complete (Amazon link - sanitised for the script kiddie link nazis that roam these halls).

What I said about warnings and "programming by coincidence" still applies! (-:

HTH.

cheers,

Rob

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文