简体   繁体   English

如何在 C# 中强制执行编码风格约定?

[英]How to enforce coding style conventions in C#?

I'm currently using Visual Studio Community for Mac 7.7.3 (build 43).我目前正在使用 Visual Studio Community for Mac 7.7.3(内部版本 43)。

I'd like to enforce coding style conventions.我想强制执行编码风格约定。 I can't understand which is the most widely adopted tool to do it.我不明白哪个是最广泛采用的工具。 StyleCop?风格警察? FXCop?外汇警察? Microsoft Code Analysis?微软代码分析? Any of them is the one that performs live code analysis in Visual Studio Community?他们中的任何一个是在 Visual Studio 社区中执行实时代码分析的人吗? Do I have to prefer an extension or a NuGet package?我必须更喜欢扩展程序还是 NuGet 包?

I've read some books on C# but none of them covered tooling.我读过一些关于 C# 的书,但没有一本涉及工具。 Any advice?有什么建议吗?

Thanks, Adriano谢谢,阿德里亚诺

At my current place we use FxCop and StyleCop, enforced in the solution and build servers.在我目前的地方,我们使用 FxCop 和 StyleCop,在解决方案中强制执行并构建服务器。 Both are free and are well integrated into the IDE.两者都是免费的,并且很好地集成到 IDE 中。

We do have Resharper, but performance is so poor on large projects, that most devs have turned it off.我们确实有 Resharper,但在大型项目中性能很差,以至于大多数开发人员都将其关闭。 Also, it's a paid-for product, so not all developers have licences.此外,它是一种付费产品,因此并非所有开发人员都拥有许可证。

I would recommend not modifying the auto-format style, as most places I've worked at, use the defaults, so you might get into 'bad' habits that don't translate anywhere else.我建议不要修改自动格式样式,因为我工作过的大多数地方都使用默认值,因此您可能会养成不会在其他任何地方翻译的“坏”习惯。

Most developers i know use Resharper.我认识的大多数开发人员都使用 Resharper。 Stylecop is good, but it's too hard to make same rules in Stylecop and Resharper Stylecop 很好,但在 Stylecop 和 Resharper 中制定相同的规则太难了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM