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.11k stars 4.04k forks source link

csharp_style_allow_embedded_statements_on_same_line_experimental and csharp_new_line_before_open_brace colide #69490

Open LokiMidgard opened 1 year ago

LokiMidgard commented 1 year ago

Version Used:

8.0.100-preview.7.23376.3

Steps to Reproduce:

  1. Set .editorconfig:
    csharp_style_allow_embedded_statements_on_same_line_experimental = false:warning
    csharp_new_line_before_open_brace = false
  2. Write an if with braces
  3. Format

A minimal repro, with source-code provided, is ideal. https://github.com/LokiMidgard/bugRepoIDE2001

Diagnostic Id: IDE2001

Expected Behavior: No Warning if only an open brace is in the same line

Actual Behavior: Warns when an opening brace is there

image

CyrusNajmabadi commented 1 year ago

csharp_style_allow_embedded_statements_on_same_line_experimental = false:warning

You'll need to set this one to true.

LokiMidgard commented 1 year ago

@CyrusNajmabadi I actually want to forbid embadded statments on the same line

// Here I want a warning
if ('a' == 'a') Console.WriteLine("Hello, World!");

just not for the braces…

(I updated the repo including the above code)

CyrusNajmabadi commented 1 year ago

This is not a supported config for those options.