Skip to main content

Invert if

PropertyValue
IdRR0189
Applicable Syntaxif statement
Syntax Spanif 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