问题描述
我们的团队与Visual Studio 2017 Professional合作.
Our team works with Visual Studio 2017 Professional.
我一直在试图在整个团队中统一代码风格,显然目前的行业标准是使用.editorconfig文件.甚至Visual Studio在其设置窗口中也建议使用该配置文件,并链接到有用的页面,介绍如何编写editorconfig文件.
I've been trying to unify the Code Style across the team and apparently the industry standard right now is to use .editorconfig files. Even Visual Studio in it's settings windows suggests to use that configuration file and links to a useful page on how to write an editorconfig file.
但是我不想手工编写我已经在VS中配置的所有设置.我想要一个将这些设置导出为.editorconfig文件以分发它们的工具.
but I don't want to write all the settings that I already have configured in VS by hand. I would like a tool that exports those settings as a .editorconfig file to distribute them.
我无法找到任何工具来做到这一点,所以我考虑自己进行修改并与其他人分享.但是显然,如果转到工具->导入和导出设置...",则无法下载当前的代码样式设置.
I haven't been able to find any tool to do just that so I thought on righting it myself and share it with other people like me. But apparently if go to "Tools -> Import and Export Settings..." you can't download your current Code Style settings.
有没有办法解决这个问题?
Is there a way around this?
您知道有什么工具可以将我的设置转换为editorconfig文件,还是可以导出当前代码样式设置的方法?
do you know any tool to convert my settings to an editorconfig file or a way to export my current Code Style settings?
我已经基于此处
您可以在我的 github存储库中找到它
推荐答案
我知道这个问题很古老,但是值得回答...
I know this question is ancient but worth an answer...
最新的 Visual Studio扩展允许您执行此操作(在此处指南):
The latest Visual Studio extension allows you to do this (Guide here):
基本安装扩展,然后右键单击解决方案或项目(您可以将规则限制为解决方案/项目或文件夹),然后单击add > new EditorConfig (IntelliCode)
Basically install the extension and right click on the solution or project (you can restrict the rules to solution/project or even folder) and click add > new EditorConfig (IntelliCode)
关于在最新版本的Visual Studio中可以执行的操作仍有一些限制,但是Visual Studio 2017 15.8 Preview 3或更高版本允许您使用新的扩展的格式文档"命令对当前版本执行其他代码清除文档.
There are still some restrictions about what you can do in the latest releases of Visual Studio, but Visual Studio 2017 15.8 Preview 3 or higher allow you to use a new extended "Format Document" command to perform additional code cleanup for the current document.
可耻的是,您无法使所有规则都导致构建错误,只有某些选项允许这样做-没有此选项,很多样式选项都可以忽略.
It's a shame you can't make all your rules cause build errors, only some of the options allow this - without this, a lot of the styling options can be ignored.
这篇关于将Visual Studio的“代码样式设置"导出为.editorconfig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!