Hi Sonarcommunity, I have what I think to be a false positive flag in the following code where the object operationState.Screens is queried with a condition.
Now I understand that FirstOrDefault query is not checked to be not null, however as this query is inside an if block with operationState.Screens.Exists(SameCondition) it is logically not possible that the query will return null, by going for the default value.
Our SymbolicExecution engine does not track the content of collections, which is why we are not aware that youâve already verified the existence of the object in question.
However, this does highlight a potential issue. In this instance, you are using a FirstOrDefault function where a default case will never be reached. I suggest using LINQ First or Single. This way S2259 should disappear and the code would be cleaner.