Invert if
Property | Value |
---|---|
Id | RR0189 |
Applicable Syntax | if statement |
Syntax Span | if keyword |
Enabled by Default | ✓ |
Usage
Example #1
before.cs
if (condition1)
{
if (condition2)
{
Foo();
}
}
after.cs
if (!condition1)
{
return;
}
if (!condition2)
{
return;
}
Foo();
Example #2
before.cs
if (!condition1)
{
return;
}
if (!condition2)
{
return;
}
Foo();
after.cs
if (condition1)
{
if (condition2)
{
Foo();
}
}
Configuration
roslynator_refactoring.invert_if.enabled = true|false