dotnet/roslyn

WrappingKeepStatementsOnSingleLine and WrappingPreserveSingleLine conflicts editor config settings

Open

#45,570 opened on Jun 30, 2020

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C# (20,414 stars) (4,257 forks)batch import
Area-IDEBugIDE-Formatterhelp wanted

Description

Version Used: Roslyn in Visual Studio Internal Preview 4

Steps to Reproduce:

Format an if statement with curly brace on the same line as the conditional like this:

if (true) {
    Console.WriteLine("Test");
}

With options configured like so:

var options = workspace.Options
    .WithChangedOption(CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false)
    .WithChangedOption(CSharpFormattingOptions.WrappingPreserveSingleLine, false);

And in a project with an editor config containing:

csharp_new_line_before_open_brace = none

Expected Behavior: Curly brace will be on the same line as the conditional after formatting.

Actual Behavior: Curly brace is placed on a new line ignoring the editor config file settings.

Contributor guide