C# FP S2259 - implied not null unrecognized

Please provide

  • Operating system: Windows 10 Enterprise 21H2
  • Visual Studio version: 2019 v16.11.31
  • SonarLint plugin version: 7.4.0.80741
  • Programming language you’re coding in: C#
  • Is connected mode used: NO

And a thorough description of the problem / question:
This kind of code implicitly checks if left and right are null together so in the 3rd condition none could be null:

            if (left == right) 
                return true;
            else if (left == null && right != null || left != null && right == null) 
                return false;
            else if (left.Length != right.Length) 
                return false;
            else
                return true;

This problem was reported in 2019 but it still exists. See:
C#: False positive variable is null on at least one execution path - SonarCloud - Sonar Community (sonarsource.com)

Hello @DomiKJ,

I confirm this is a false positive.

The issue here is that our symbolic execution engine does not track object relations for now and as a result, it cannot learn from that first if condition that if it’s true it also means that both objects can also be null.

This FP will be solved once we add support for object relations.