.editorconfig在VS2017中没有做任何事情?

Ser*_*ern 10 editorconfig visual-studio-2017

我有以下版本的visual studio:

Microsoft Visual Studio社区2017版15.1(26403.7)发布VisualStudio.15.Release/15.1.0 + 26403.7

我创建了一个新项目并.editorconfig在我的解决方案基础文件夹中添加了一个文件 它的内容如下:

root = true

[*.cs]
indent_style = space:warning
indent_size = 12:warning

# CSharp and VisualBasic code style settings:
[{*.cs,*.vb}]
dotnet_style_qualification_for_field = false:warning
Run Code Online (Sandbox Code Playgroud)

文件位置应该是正确的:

.editorconfig <-- Here it is
ApplicationInsights.config
App_Data
App_Start
bin
Content
Controllers
favicon.ico
fonts
Global.asax
Global.asax.cs
Models
obj
packages.config
Properties
Scripts
Startup.cs
Views
Web.config
Web.config.backup.1
Web.Debug.config
Web.Release.config
WebApplication8.csproj
WebApplication8.csproj.user
Run Code Online (Sandbox Code Playgroud)

但每当我编辑一个.cs文件时,没有什么特别的事情发生(尽管缩进没有遵循规则),我怀疑警告(例如在构建之后)出现,但没有.

我的配置有问题,还是有什么东西会阻碍配置的应用?

小智 6

我也有同样的问题。在我的例子中,解决方案是将.editorconfig文件添加到解决方案中。您可以选择将其添加到解决方案项目中,具体取决于您希望将其应用到所有地方还是仅应用到单个项目

\n

Solution\xc2\xa0Explorer \xe2\x86\x92 右键单击​​您的解决方案或项目 \xe2\x86\x92 Add \xe2\x86\x92 Existing Item...(如果您的.editorconfig文件位于解决方案或项目)或新项目...(然后在 (然后在“添加新项”并为您的工作选择适当的类型)。

\n


小智 0

我有一个类似的问题,这就是我解决它的方法:

我的解决方案文件夹有一个在方括号之间命名的父文件夹[],例如[ParentFolderName],所以我删除了方括号,一切都按预期工作。

由于某种原因,当解决方案文件夹具有在方括号之间命名的父文件夹时,editorconfig 文件不会执行任何操作。IDE(在我的例子中为 Visual Studio 2017)使用其设置。