Bug Report T651495
Visible to All Users

Static Code Analysis - The "Possible System.NullReferenceException" diagnostics should take Lambda-Expressions/Closures into account

created 7 years ago

See following example:

Visual Basic
Module Module1 Function Foo(text As String) As Integer 'CRR0027 Return text.Length End Function Function Bar(text As String) As Integer 'No CRR0027 Return (Function() text.Length)() End Function End Module
Comments (2)
DevExpress Support Team 7 years ago

    Hi Robert,
    I have managed to reproduce the issue. Please give us some time to research the issue in detail.

    DevExpress Support Team 7 years ago

      Hi Robert,

      Currently, the Possible NullReference.Exception analyzer skips a check for lambda parameters. It was done after we received users' comments that reports for lambda parameters sometimes create a lot of noise. We are working on providing settings for this analyzer (including an option for lambda parameters). It is a complex task and its implementation requires some time. We will inform you of our progress.

      Answers approved by DevExpress Support

      created 6 years ago (modified 6 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.

      Additional information:

      Hi Robert,

      In the CodeRush 18.1.11, we have implemented settings for the Possible System.NullReferenceException analyzer. By default, check of lambda parameters is disabled. To enable it, perform the following steps:

      1. From the Visual Studio menu, select "CodeRush\Options…" .
      2. In the tree view on the left, navigate to the "Editor\Visual Basic\Code Analysis" folder.
      3. Select the "Possible NullReferenceException" options page.
      4. Select the "Thorough" mode for the "Parameters" item.
      5. Check the "Check anonymous methods' parameters" item.

        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.