将 Visual Studio 的“代码样式设置"导出为 .editorconfig [英] Export Visual Studio's 'Code Style settings' as .editorconfig

查看:33
本文介绍了将 Visual Studio 的“代码样式设置"导出为 .editorconfig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的团队使用 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?

我根据 这里

I have created my own version of the .editorconfig file based on the information found in here

你可以在我的 github repo

推荐答案

我知道这个问题很古老但值得回答...

I know this question is ancient but worth an answer...

最新的 Visual Studio 扩展允许您执行此操作(此处指南):

The latest Visual Studio extension allows you to do this (Guide here):

基本上安装扩展并右键单击解决方案或项目(您可以将规则限制为解决方案/项目甚至文件夹)然后单击添加>新的 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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