Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4273448
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:42:52+00:00 2026-05-21T07:42:52+00:00

I believe I have found a bug in ReSharper. Suppose I have code as

  • 0

I believe I have found a bug in ReSharper. Suppose I have code as follows:

int[] someArray = new int[10];
while (someArray  != null)
{
     //perhaps some other usage of someArray here, but not assigning it.
     SomeMethod(ref someArray );
}

If the local variable someArray is not assigned to null in its scope, then the statement someArray != null would always be true. But that isn’t the case when that variable is given as ref-parameter to another method, since it could get assigned to null in that method. Then ReSharper incorrectly assumes that someArray != null is still always true.

I thought I’d share this information, because I’m unsure what I should do with this. Firstly I’d like someone to verify this bug, and afterwards send it to JetBrains?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:42:53+00:00Added an answer on May 21, 2026 at 7:42 am

    Hm, apparently the static analysis of ReSharper is smarter than me….
    The code in which I correctly get the "expression is always true" warning is:

    int[] someArray = new int[10];
    while (someArray != null)
    {
        Foo(ref someArray);
        someArray.Bar();
    }
    

    I get the warning that someArray != null is redundant, so I thought ReSharper misinterpreted the ref parameter, since someArray can in fact be assigned to null. But that is not the reason why the warning is correct. Then a subtle fact plays a role: that someArray is null would mean that the method invocation of Bar would throw a NullReferenceException, and with that alter the control flow such that the start of the while loop isn’t reached. So even when someArray is assigned to null in Foo, the warning is correct.

    My mistake, and thank you all for your effort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe I have found a weird bug as follow: I want to delete
I believe I have found a bug in WebKit. It involves outerWidth(true) (and I
I believe that I have successfully impersonated my own user account while running an
I've found very strange C# compiler behavior for following code: var p1 = new
Edit: This code is fine. I found a logic bug somewhere that doesn't exist
I have found the below Javascript recently, and (believe) I understand its operation, but
EDIT: I believe i may have found the problem. I need to work on
I have recently upgraded to Play 1.2.4 and I believe the bug fix for
I was recently trying to solve some task in Python and I have found
I believe I have disabled the view state on all controls as well as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.