您的团队如何为 .Net 定制 Stylecop(或许还有其他工具)以获得良好的结果?

发布于 2024-09-02 08:00:09 字数 423 浏览 6 评论 0原文

我们的团队仍然对它又爱又恨。我希望通过内部投票来结束辩论,决定哪些规则应该被排除以及哪些规则应该被添加。

在此之前,我想询问其他SO用户。为了标准化(但不限制)响应:

  1. 您当前的 StyleCop 版本是什么?
  2. 您当前的目标是哪个 .Net 版本?
  3. 您关闭了哪些默认规则?
  4. 您启用了哪些非默认规则?
  5. 您编写了自己的规则吗?请描述一下。
  6. 你还有其他值得分享的 StyleCop 技巧吗?
  7. 你用Resharper吗?什么版本?这是物有所值的吗?
  8. 您是否使用任何其他与 Visual Studio 集成并辅助开发的 .Net / C++ 工具?你的钱花得值吗?
  9. 您还有什么想补充的吗?
  10. ...

谢谢你!

Our team is still in a love / hate relationship with it. I am hoping to put an end to the debate by having an internal vote on what rules should be excluded and which rules should be added.

Before doing so, I wanted to ask others SO users. To standardize (but not limit) the responses:

  1. What is your current StyleCop version?
  2. What .Net version do you currently target?
  3. Which default rules did you turn off?
  4. Which non-default rules have you turned on?
  5. Have you coded your own rules? Please describe.
  6. Do you have any other StyleCop tricks worth sharing?
  7. Do you use Resharper? What version? Is it a good bang for the buck?
  8. Do you use any other tools for .Net / C++ which integrate with Visual Studio and aid development? Did you get your money's worth?
  9. Anything else you like to add?
  10. ...

Thank you!

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

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

发布评论

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

评论(3

不一样的天空 2024-09-09 08:00:09
  1. 您当前的 StyleCop 版本是什么? 本地为 4.3.3,构建服务器上为 4.3.0
  2. 您当前的目标是哪个 .Net 版本? 2.0 或 3.5
  3. 您关闭了哪些默认规则?
  4. 您启用了哪些非默认规则? 刚刚在匈牙利规则中添加了一些排除
  5. 您编写了自己的规则吗?请描述一下。
  6. 您还有其他值得分享的 StyleCop 技巧吗? 使用<项目文件中的 code>元素
  7. 您使用 Resharper 吗?什么版本?这是物有所值的吗? 的,R# 5,非常有价值(特别是使用StyleCop for ReSharper
  8. 是 您使用任何其他与 Visual Studio 集成并辅助开发的 .Net / C++ 工具吗?你的钱花得值吗? GhostDoc 是我们使用的唯一其他工具
  1. What is your current StyleCop version? 4.3.3 locally, 4.3.0 on build server
  2. What .Net version do you currently target? 2.0 or 3.5
  3. Which default rules did you turn off? none
  4. Which non-default rules have you turned on? just added a couple of exclusions to the Hungarian rule
  5. Have you coded your own rules? Please describe. nope
  6. Do you have any other StyleCop tricks worth sharing? use the <ExcludeFromStyleCop> element in your project files
  7. Do you use Resharper? What version? Is it a good bang for the buck? yes, R# 5, great value (especially with StyleCop for ReSharper)
  8. Do you use any other tools for .Net / C++ which integrate with Visual Studio and aid development? Did you get your money's worth? GhostDoc is the only other tool we use
三生路 2024-09-09 08:00:09
  1. 我使用的是 4.3.3.0
  2. .net 3.5
  3. 很多,所有文档和其他文档的集合。
  4. 没有,IIRC。
  5. 过去我也是这么做的。我目前没有编码风格要求,但以前我有。当我有它们时,我会为它们创建自定义规则。
  6. “右键单击警告,显示错误帮助”是一个很好的选择。我最喜欢的是“将 Settings.StyleCop 文件添加到解决方案项目文件夹”。
  7. 不,但如果可以的话我会的。
  8. FxCop。是的,物超所值。
  9. 是的。您启用/禁用的规则应完全由您尝试验证的编码指南驱动。您不知道要使用哪些的原因可能是因为您没有。因此,这是您应该做的第一件事,创建一套编码指南。您可以使用 StyleCop 来确定要强制执行哪些规则(从所有规则开始,当每个人都同意该规则对于修复它所付出的努力没有任何价值时删除一条规则)。这似乎有点落后,并且会跳过 StyleCop 尚未强制执行的编码标准的可能性,但绝对比没有好。这将是制定一些地方标准的快速方法。另一种方法是四处寻找一些现有的已发布您的团队或多或少可以达成一致的编码指南(1),然后配置 StyleCop 来强制执行这些指南。无论哪种方式,在整个团队中保持一致的编码风格都会带来很多好处,而 StyleCop 就是强制执行它的方法。
  10. 自定义规则很棒。不要低估关闭 StyleCop 规则并实施同一规则的“更好”版本的可能性。

(1) 就像披萨配料一样,小组内不可能达成完全一致,但可以达成普遍共识

  1. I'm on 4.3.3.0
  2. .net 3.5
  3. Lots, all the Documentation and a collection of others.
  4. None, IIRC.
  5. In the past I did. I currently have no coding style requirements, but previously I did. I create custom rules for them when I have them.
  6. "Right-click the warning, Show Error Help" is a good one. My favourite is "add the Settings.StyleCop file to the Solution Items folder".
  7. No, but I would if I could.
  8. FxCop. Yup, infinite value for the money.
  9. Yes. What rules you enable/disable should be driven entirely by the coding guidelines that you're trying to validate against. The reason you don't know which ones to use is likely because you don't have any. So that's the first thing you should be doing, creating a set of coding guidelines. You could use StyleCop to determine which rules you want to enforce (start with all of them on and remove one when everyone agrees that that rule provides no value for the effort it would take to fix it). That seems a little backward and would skip the possibility of having a coding standard that wasn't already enforced by StyleCop, but is definitely better than nothing. And it would be a quick way to generate some local standards. Another way to do it would be to look around for some existing published coding guidelines that your team can more-or-less agree on(1) and then configuring StyleCop to enforce those. Either way, there's a lot to be gained from having a consistent coding style across the group, and StyleCop's the way to go to enforce it.
  10. Custom rules are awesome. Don't discount the possibility of turning off a StyleCop rule and implementing a 'better' version of the same rule.

(1) It's like pizza toppings, there's no way you'll get complete agreement in the group but a general consensus can arise

沧笙踏歌 2024-09-09 08:00:09
  1. 4.3.3
  2. .NET 3.5
  3. 关闭 SA1309 - FieldNames 不得以下划线开头(对于属性
  4. 自定义规则后面的私有变量,没有变量以“m_”开头
  5. 是的,#4 中的自定义规则基于此 博客
  6. 不是真的
  7. 我们使用 VisualSVN 插件,它是免费的,而且我们发现它很有用,因为我们使用 Subversion 进行源代码控制
  1. 4.3.3
  2. .NET 3.5
  3. Turned off SA1309 - FieldNames must not start with underscore (for private variables behind a Property
  4. custom rule that no variables start with "m_"
  5. Yes, custom rule in #4 based off of code in this blog
  6. not really
  7. no
  8. we use the VisualSVN plugin, it's free and we find it useful since we use Subversion for source control
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文