Open
Description
Issue
- Build does not fail when
when_on_single_line
is violated andEnforceCodeStyleInBuild=true
dotnet format style src
does not auto format code to align withwhen_on_single_line
## Use expression body for methods
## https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0022
dotnet_diagnostic.IDE0022.severity = error
csharp_style_expression_bodied_methods = when_on_single_line:error
csharp_style_expression_bodied_methods = true:error
is supported and enforced
True for all of; IDE0022,IDE0023,IDE0023,IDE0024,IDE0025,IDE0026,IDE0027
SDK
dotnet --version
7.0.400
dotnet format --version
7.4.431902+3c30490bb2ecae8967a3b5e79c97ab98de334676
Expect
when_on_single_line
fails the build when an expression is used for a multi-line statement.
// Given
public void Example() =>
builder.
.Foo(...)
.Bar(...)
.Build();
// Expect output of `dotnet format style src`
public void Example()
{
return builder.
.Foo(...)
.Bar(...)
.Build();
}
Currently when_on_single_line
does not format the above example nor does it fail the build.
If this behavior is expected, perhaps it should be called when_single_statement
. Regardless it should auto format to align with its intent.
//Given
public void Example()
{
return builder.
.Foo(...)
.Bar(...)
.Build();
}
// Expect output of `dotnet format style src`
public void Example() =>
builder.
.Foo(...)
.Bar(...)
.Build();
Activity