DotNetAnalyzers / StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform
MIT License
2.61k stars 506 forks source link

SA1009 - Behavior in Switch expression #3835

Open modestotech opened 1 month ago

modestotech commented 1 month ago

Version: 1.2.0-beta.556 .NET version: 8

I'm working with a switch expression like below: image

This gives the SA1009 error.

StyleCop wants me to put it like this: image

Doesn't look nice, and when reading the in the docs about SA1009 it seems there are some exceptions to this rule (cast), so maybe some logic needed here to handle switch expressions.