Fix invert if for cases where the if block is empty#54423
Fix invert if for cases where the if block is empty#54423ryzngard merged 7 commits intodotnet:mainfrom
Conversation
src/Features/CSharp/Portable/InvertIf/CSharpInvertIfCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
| { | ||
| await TestInRegularAndScriptAsync( | ||
| @"class C { void M(string s){ [||]if (s == ""a""){}else{ s = ""b""}}}", | ||
| @"class C { void M(string s){ if (s != ""a""){ s = ""b""}}}"); |
There was a problem hiding this comment.
tbh, this seems a bit strange. but i guess it's fine :)
There was a problem hiding this comment.
taht we are throwing away the empty block. it feels like if hte user asks to invert, we should just invert. another feature could potentially say: this block is useless
There was a problem hiding this comment.
oh...gotcha. I'm going to leave for now because it was my gut that it's how it should work. That said, I'm not really opposed to leaving the empty block if we find that people don't like it being removed
| end class", | ||
| "class C | ||
| sub M(x as String) | ||
| If x IsNot ""a"" Then |
There was a problem hiding this comment.
it's a bit strange that = got replaced withIsNot instead of <>.
There was a problem hiding this comment.
I didn't change the logic here... maybe worth a different bug?
src/Features/CSharp/Portable/InvertIf/CSharpInvertIfCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/InvertIf/CSharpInvertIfCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/InvertIf/CSharpInvertIfCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
Some small pieces of feedback.
Fixes #43224