static void Main(string[] args)
{
object o = null;
var test = o.ToString(); // Noncompliant, always null
var list = new List<int>();
//var listCount = list?.Count;
Console.ReadLine();
}
Reports s2259. If commented line is uncommented (it uses null conditional operator), then the s2259 is no longer reported.
Great! Will it also fix the local results from SonarLint? As far as I understand it’s a different analyzer. Also it’s not a false positive but more a false negative, the rule does not report error if null conditional operator is used in the file.