Following example code is correct and does not produce any NullReferenceException although it's mentioned for line 16 "Return text.Bar":
Visual BasicPublic Module Module1
<System.Runtime.CompilerServices.Extension>
Function Bar(text As String) As String
Dim result As String = text
If text IsNot Nothing Then
result = text.Substring(0, 3)
End If
Return result
End Function
Function Foo(text As String) As String
'do something else
Return text.Bar
End Function
'Examples:
'Foo("Hello") => "Hel"
'Foo(Nothing) => Nothing
End Module
Hi Robert,
Thank you for catching this false positive report of the Possible NullReference diagnostics. I managed to reproduce it on my side. Give us some time to prepare a fix.