Visual Studio 类似 Eclipse 的格式设置
Visual Studio 是否有一个工具可以在保存源代码(C#)时自动格式化它?这对于我的多开发人员团队保持代码外观统一非常有用,特别是在将代码签入源代码控制存储库之前。
Is there a tool for Visual Studio that will automatically format source code (C#) on saving it? This would be useful for my multi-developer team to keep the code looking uniform, especially before the code is checked into the source control repository.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想到的是 CodeRush 或 ReSharper。
CodeRush or ReSharper come to mind.
Visual Studio 的 PowerCommands:http://code.msdn.microsoft.com/PowerCommands
如果您安装插件并在“工具”->“选项”菜单下查找“PowerCommands”,有两个复选框“保存时格式化文档”和“保存时删除和排序用途”。它是我最喜欢的具有该功能的插件之一。
PowerCommands for Visual Studio: http://code.msdn.microsoft.com/PowerCommands
If you install the addin and look for PowerCommands under the Tools->Options menu, there's two tick boxes for "Format document on save" and "Remove and Sort Usings on save". It's one of my favourite addins for that exact functionality.
许多(和我)使用 StyleCop 并将其设置为分析构建上的文件,我将其设置为标记警告作为错误,因此必须在成功构建之前解决问题。
我更喜欢这种方法,因为它混淆了第三方的责任,第三方在没有开发人员干预的情况下自动设置代码样式,我觉得失去了一些东西,过度依赖这种方法可能会导致开发人员的代码变得越来越糟糕,而他们甚至不知道这一点。
似乎更可取的是,将问题通知开发人员并强制修复它们,以便整体提高他们的编码技能。
编辑:我知道这是一篇旧帖子,我只是认为我的想法可能对发生在这个页面上的人有帮助。
Many (and me) use StyleCop and set it to analyse files on a build and I set it to flag warnings as errors so issues must be resolved prior to a successful build.
I prefer this method as obfuscating the responsibility to a third party which automatically styles the code without developer intervention I feel loses something, over reliance on this method could lead to a developers code becoming worse and worse without them even knowing it.
It seems more preferable that the developer be notified of issues and forced to fix them, so as to hopefully overall improve their coding skills.
EDIT: I know this is an old post I just thought my thoughts could be helpful to somebody happenning accross this page.