ReSharper suggests using null propagation for the "damageable" if block, but for the "forceVelocityCalculator" one there is no suggestion.
GetComponent()
If you really really look at what GetComponent does, it actually never returns null
, you always get an object wrapper that handles the communication between your C# code and Unity's underlying C++ code.
So when you get "null" from GetComponent()
what you actually get (Unity has overridden the == operator!) is not actually null, but an object wrapper around a null
. So ReSharper doesn't know that null propagation would be helpful here (assuming, of course, that it works: because the object isn't actually null, just pretending to be null, the syntactic sugar might not work properly!).