dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.13k stars 4.04k forks source link

Creating new file does not respect .editorconfig tab setting #22171

Open dpoeschl opened 7 years ago

dpoeschl commented 7 years ago

Ported from https://developercommunity.visualstudio.com/content/problem/114359/creating-new-file-does-not-respect-editorconfig-ta.html

Also :link: Formatting Code when adding Item

Also :link: Formatting of init class after adding new class library into project

I have an .editorconfig file that specifies:

[*] indent_style = tab indent_size = 4

However, when creating a new C# class, the newly created file still uses spaces. Any code added into the class will use tabs due to C# auto-formatting, so the resulting code file will usually be a mixture of tabs and spaces :(

I think the templates shipping with VS should respect the indentation setting.

jasonmalinowski commented 5 years ago

And FWIW: this is just a bug because we try to do all the magic to fetch the correct .editorconfig settings:

https://github.com/dotnet/roslyn/blob/2d355454fe78c80e6a68a41b5fb33b037a7fc3fe/src/VisualStudio/Core/Def/Implementation/AbstractEditorFactory.cs#L272-L298

So this is supposed to work, and at one point it did...