Please see following example:
Visual BasicPublic Class Class1
Public Function Foo1(items As Object()) As Object
If items Is Nothing Then
Return "Something"
ElseIf items.Count = 0 Then
Return "Something else"
End If
'CRR0027 (false positive)
For Each item As Object In items
'Do something
Next
'No CRR0027
Return items.Count
End Function
Public Function Bar1(items As Object()) As Object
If items Is Nothing Then
Return "Something"
End If
If items.Count = 0 Then
Return "Something else"
End If
'No CRR0027
For Each item As Object In items
'Do something
Next
'No CRR0027
Return items.Count
End Function
Public Function Foo2(value As Object) As String
If value Is Nothing Then
Return "Something"
ElseIf TypeOf value Is Integer Then
Return "Something else"
End If
'CRR0027 (false positive)
Return $"{value.GetType.Name}"
End Function
Public Function Bar2(value As Object) As String
If value Is Nothing Then
Return "Something"
End If
If TypeOf value Is Integer Then
Return "Something else"
End If
'No CRR0027
Return $"{value.GetType.Name}"
End Function
End Class
Hi Robert,
Thank you for providing the code sample. I have reproduced this issue with "Possible System.NullReferenceException" false positives. We are working on it and will inform you of our progress.