Refactor logical statements with VA Modify Expression to simplify tasks such as resorting if else statements and simplifying complex chains of logical expressions.
Access
To see the modifications suggestions, right-click or press Shift+F10 on a logical statement in a source file and select Modify Expression... from the Quick Actions and Refactorings (VA) menu. Find the option also in the VAssistX entry in the menu bar (Alt+X, R), hover over the Code Generation and Refactoring and find the Modify Expression option.
The Modify Expression dialog contains the current expression and the expression after all of the modifications, press OK if you agree with all changes.
The following are options you have in the VA Modify Expression dialog:
Highlight differences
Check if you want to see the differences between the before and after modifications.
Invert Expression Logic
VA Modify Expression will invert the logical expression.
Apply this modification to swap the contents of an if and else statement.
Transform Expression (De Morgan)
VA Modify Expression will transform the logic using De Morgan’s law.
Apply this modification to reduce the complexity of some logical statements containing ! (not) operators.
Modify logical operators
Uncheck this option to preserve logical operators such as && and ||. This is helpful if the types do not support all logical operations.
Modify relational operators
Uncheck this option to preserve relational operators such as > and <. This is helpful if the types do not support all relational operations.
Remove ! (not) operators
Apply De Morgan’s laws to factor in any ! (not) operators, simplifying the logical expression.
Older IDEs
This feature is only available for Visual Studio 2010 or newer.