SA1513 triggered in switch statement used as part of an operation
See original GitHub issueHi,
I get SA1513 triggered in the case below. I’m asked by StyleCop to add a line after final bracket of the switch
statement, but I’m expecting the rest of the operation to be inline after the bracket. Here’s an example below reproduced in .NET Core 3.1 or .NET 5. Assuming Foo
is an enum
internal static int FooTest(Foo foo, int a)
=> foo switch
{
Foo.Bar => 1,
Foo.Buzz => 2,
_ => throw new InvalidOperationException(),
} << a;
forces me to write:
internal static int FooTest(Foo foo, int a)
=> foo switch
{
Foo.Bar => 1,
Foo.Buzz => 2,
_ => throw new InvalidOperationException(),
}
<< a;
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:8 (1 by maintainers)
Top Results From Across the Web
switch Statement (C)
A switch statement causes control to transfer to one labeled-statement in its statement body, depending on the value of expression .
Read more >Using Switch Expressions in Java
Introduced in Java 13, Switch Expressions offer developers a new way to use switch. See the benefits and potential pitfalls in our tutorial, ......
Read more >Every case in switch is triggered in JS
JavaScript supports C style switch case fall through, which means unless there is a break specified, it will continue to execute all the ......
Read more >if and switch statements - select a code path to execute
The `if` and `switch` statements provide branching logic in C#. You use `if, `else` and `switch` to choose the path your program follows....
Read more >Difference between SWITCH and IF/ELSE- ...
@DavidSchach I personally use a static method in the trigger; that static method is responsible for determining which handler class to execute ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Similar issue happens with semicolon. Having code like this:
StyleCop (1.2.0-beta.321) suggest following fix:
@DrummingBeb since it looks like a defect, I’d suggest putting it in separate issue