Nullable merge sequential checks seems broken to me

Completed

I have some code:

 public void Something(decimal? thing)
{
if (thing != null && thing.HasValue)
{
// something
}

// something else
}

Resharper (v2018.1) offers to "Merge Sequential Checks". If I do it resharper changes this to

 public void Something(decimal? thing)
{
if (!thing.HasValue)
{
// something
}

// something else
}

I don't understand this refactor at all. In fact it seems like it's now doing the opposite of what I wanted. Can you guys make any sense of this?

2 comments
Comment actions Permalink

I'm seeing the same thing. In my case, I have a nullable DateTimeOffset property in a class:

if(something != null && something.nullableDateTimeOffset.HasValue)

Resharper wants this:

if(!(something?.nullableDateTimeOffset).HasValue)

0
Comment actions Permalink

Hello!

 

Unfortunately it's a known issues, please refer to the following request  - https://youtrack.jetbrains.com/issue/RSRP-469376.

Please feel free to comment or vote for it.

Thank you.

0

Please sign in to leave a comment.