Reporter | Dmitry Matveev (dmitry.matveev@jetbrains.com) |
---|---|
Created | Apr 26, 2018 4:00:32 PM |
Updated | Apr 26, 2018 4:00:32 PM |
Subsystem | Quick Fixes |
Assignee | Alexander Shvedov (shvedov) |
Priority | Normal |
State | Submitted |
Type | Bug |
Fix version | No Fix versions |
Affected versions | No Affected versions |
Fixed In Version ReSharper | Undefined |
VsVersion | All Versions |
A strange thing is happening in R# 2018.1. Using this refactoring it transforms
ViewBag.UserHasCompany = CurrentUser != null && CurrentUser.CompanyId.HasValue;
into
ViewBag.UserHasCompany = !(CurrentUser?.CompanyId).HasValue;
which is not right. e.g. when CurrentUser.CompanyId is not null, the first one evaluates to true, the second one to false.
ViewBag.UserHasCompany = CurrentUser != null && CurrentUser.CompanyId.HasValue;
into
ViewBag.UserHasCompany = !(CurrentUser?.CompanyId).HasValue;
which is not right. e.g. when CurrentUser.CompanyId is not null, the first one evaluates to true, the second one to false.
https://www.jetbrains.com/help/resharper/ConditionalTernaryEqualBranch.html#comment-3873569268