Simple project to test the .editorconfig capabilities.
It seems as if some attributes in the .editorconfig does not work as intended but is reset when opening the Visual Studio Viewer.
The following attributes is affected:
- Place open brace on new line for types
- Place open brace on new line for methods and local functions
- Place open brace on new line for properties, indexers, and events
- Place open brace on new line for property, indexer, and event accessors
- Place open brace on new line for anonymous methods
- Place open brace on new line for control blocks
- Place open brace on new line for anonymous types
- Place open brace on new line for object, collection, array, and with initializers
- Place open brace on new line for lambda expression
- Clone and open this project.
- Open the .editorconfig separately in a stand alone editor, preferably VS Code (since it updates the files dynamically).
- In the file, find
csharp_new_line_before_open_brace
and not its value. It's probablyall
ornone
. Idnone
, set it toall
. - In Visual Studio, open the .editorconfig file in the viewer.
- Find the list of attributes mentioned above under the Whitespeace tab. It is under the New line preferences section. If you have set
csharp_new_line_before_open_brace
toall
, they should all be ticked. - Untick one of them. Save the file.
- In the text editor, notice how the
csharp_new_line_before_open_brace
have changed fromall
tonone
. - In Visual Studio, close, then reopen the .editorconfig. All the attributes have been unticked.
The csharp_new_line_before_open_brace
should be able to handle the following values:
all
none
Or, in a comma-separated list:
accessors
anonymous_methods
anonymous_types
control_blocks
events
indexers
lambdas
local_functions
methods
object_collection_array_initializers
properties
types
The latter don't seem to be supported by Visual Studio. At least not for me. If I create a comma-separated list as per the definition, Visual Studio can read it. But if I remove one of the tick boxes, it doesn't simply remove the specific item from the list, but set the whole attribute to none
.
For more info on how it is supposed to work: C# formatting options