So, if you are like me, it’s easy to make mistakes on whether to use && or || when combining variables on if statements. I hate to just start nesting if statements because the code gets bulky, but if not, I have to think three times about whether I got it right.
So, Here comes Resharper for c# from Jetbrains. Simply write the if statement nested as follows:
if (_instance._meta == null) { if (DataContextLazyLoad) { AssignAllDataContexts.Run(); } }
Then, resharper will give you the following suggestion about merging if’s:
Chose “Merge two if’s”
And, this is what you get:
if (_instance._meta == null && DataContextLazyLoad) { AssignAllDataContexts.Run(); }
OK, granted, this one was pretty simple, but think about when it gets more complicated. Hard not to love this product.