dotnet/roslyn

WrappingKeepStatementsOnSingleLine and WrappingPreserveSingleLine conflicts editor config settings

Aperta

#45.570 aperta il 30 giu 2020

 (0 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-IDEBugIDE-Formatterhelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

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.

Guida contributor