是否有C#的自动代码格式化? [英] Is there an automatic code formatter for C#?

查看:195
本文介绍了是否有C#的自动代码格式化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的工作,我用C#代码处理大部分时下,用java洒不时。我绝对喜欢关于Eclipse(我知道使用它每天爱它,甚至更多的人)是一个复杂的代码格式,能够塑造代码到任何编码标准可以想象。是否有C#这样的工具? Visual Studio代码格式(键Crtl + K,键Crtl + D)是欠佳和了StyleCop只检查源不固定的。

In my work I deal mostly with C# code nowadays, with a sprinkle of java from time to time. What I absolutely love about Eclipse (and I know people using it daily love it even more) is a sophisticated code formatter, able to mould code into any coding standard one might imagine. Is there such a tool for C#? Visual Studio code formatting (Crtl+K, Crtl+D) is subpar and StyleCop only checks the source without fixing it.

我的梦想工具将从控制台运行(易包括在自动构建或预提交挂钩,并执行在Linux +单声道),有基于文本的文件配置易于存放在项目资源库和预览图形规则编辑器 - 就像Eclipse代码格式化程序

My dream tool would run from console (for easy inclusion in automated builds or pre-commit hooks and for execution on Linux + Mono), have text-file based configuration easy to store in a project repository and a graphical rule editor with preview - just like the Eclipse Code Formatter does.

推荐答案

对于Visual Studio,看看 ReSharper的。这是一个真棒工具和一个明确的必须具备的。 4.0之后的版本有代码的格式,并且你正在寻找清理功能。还有用了StyleCop 插件整合,包括格式设置文件。你可能想代理史密斯插件还有,对于拼写检查标识符和评论。每个解决方案的格式设置文件,可以通过整个团队签入到版本控制系统和共享ReSharper的支持。代码清理键盘快捷键是<大骨节病>按Ctrl + E <大骨节病> C

For Visual Studio, take a look at ReSharper. It's an awesome tool and a definite must-have. Versions after 4.0 have the code formatting and clean-up feature that you are looking for. There's also plugin integration with StyleCop, including formatting settings file. You'll probably want Agent Smith plugin as well, for spell-checking the identifiers and comments. ReSharper supports per-solution formatting setting files, which can be checked into version control system and shared by the whole team. Keyboard shortcut for code cleanup is Ctrl+E C.

在香草​​的Visual Studio,当前文件即可自动格式化<大骨节病>键Crtl + K <大骨节病>键Crtl + D 和<大骨节病>按Ctrl + K <大骨节病>按Ctrl + F 格式所选文本

In 'vanilla' Visual Studio, current file can be automatically formatted with Crtl+K Crtl+D, and Ctrl+K Ctrl+F formats the selected text.

至于与使用的运行无处不在命令行工具提交挂钩,尝试 NArrange 的。它是免费的,可以同时处理整个目录和运行单以及对Microsoft.Net

As for a runs-everywhere command line tool to be used with commit hooks, try NArrange. It's free, can process whole directories at once and runs on Mono as well as on Microsoft.Net.

有些人也会用的艺术风格命令行工具,虽然它需要Perl和适用于C / C ++代码比用C#。

Some people also use Artistic Style command line tool, although it requires perl and works better with C/C++ code than with C#.

这篇关于是否有C#的自动代码格式化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆