Please see following examples:
Visual BasicPublic Class Class1
Public Function Foo1() As Integer
Dim value As String = "Value"
Dim other As Object = DirectCast(value, Object)
'CRR0027 (false positive)
Return other.GetHashCode
End Function
<NotNull>
Public Function Value() As String
Return "Value"
End Function
Public Function Foo2() As Integer
Dim other As Object = DirectCast(Value(), Object)
'CRR0027 (false positive)
Return other.GetHashCode
End Function
Public Function Bar() As Integer
Dim value As String = Nothing
Dim other As Object = DirectCast(value, Object)
'CRR0027 (correct!)
Return other.GetHashCode
End Function
End Class
<AttributeUsage(AttributeTargets.All)>
Public NotInheritable Class NotNullAttribute
Inherits Attribute
End Class
Hi Robert,
Thanks for the code snippet.
I have reproduced this issue locally. Please give us some time to research the issue in detail.