Bug Report T643108
Visible to All Users

Static Code Analysis - The "Possible System.NullReferenceException" diagnostics should take "complex" expressions/conditions in "If()-Operator" into account

created 7 years ago

See following examples:

Visual Basic
Public Module Module1 ' CRR0027 Public Function Foo1(text1 As String, text2 As String) As Integer Return If((text1 Is Nothing) OrElse (text2 Is Nothing), -1, text1.Length + text2.Length) End Function ' CRR0027 Public Function Foo2(text1 As String, text2 As String) As Integer Return If((text1 IsNot Nothing) AndAlso (text2 IsNot Nothing), text1.Length + text2.Length, -1) End Function ' CRR0027 Public Function Foo3(text1 As String, text2 As String) As Integer Return If(Not ((text1 Is Nothing) OrElse (text2 Is Nothing)), text1.Length + text2.Length, -1) End Function 'No CRR0027 Public Function Bar1(text1 As String, text2 As String) As Integer If (text1 Is Nothing) OrElse (text2 Is Nothing) Then Return -1 Return text1.Length + text2.Length End Function 'No CRR0027 Public Function Bar2(text1 As String, text2 As String) As Integer Return If(text1 Is Nothing, -1, If(text2 Is Nothing, -1, text1.Length + text2.Length)) End Function End Module
Comments (1)
DevExpress Support Team 7 years ago

    Hello,

    Thank you for pointing out this issue and providing the code sample.
    We have reproduced it on our side.
    So, we will work on it and notify you when we make any progress.

    Answers approved by DevExpress Support

    created 7 years ago

    We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

    Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.