if (o is string text &&
int.TryParse(text, out var n) &&
n < 5 && n > -5)
{
}
else
{
}
Is refactored to:
switch (o)
{
case string text when int.TryParse(text, out var n) &&
n < 5:
break;
default:
break;
}
Not ideal that it trims off && n > -5
I expected:
switch (o)
{
case string text when int.TryParse(text, out var n) &&
n < 5 && n > -5:
break;
default:
break;
}

I think the purpose is to speedily get you into switch form. You may have to do some fixups as necessary if your existing constructs use features (like larger scoping) that aren't well supported by a switch expression.
I agree, getting 90% of the way there is better than being forced to do all the typing myself.
Looks like best effort could be significantly improved though. There's no logical reason IMO that && should be disappearing. It might even be possible to make the refactoring understand the variable scoping change.
I missed that a whole operand was gone after the &&, not just the operator. That's a more serious bug because it could be missed if you were moving fast and didn't have a test covering it.
Note: the bit about the clause being stripped off should def just be fixed. I wasn't referring to that bit :)
this should be fixed by #38238
Yup. Have validated this is fixed. LMK if there are other issues we need to closeout. Thanks!