Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-462247: "Merge conditional expression" breaks code

$
0
0
Reporter Andrew (impworks) Andrew (impworks)
Created Dec 15, 2016 2:21:33 PM
Updated Apr 11, 2018 8:04:27 PM
Resolved Apr 11, 2018 8:04:27 PM
Subsystem Quick Fixes
Assignee Alexander Shvedov (shvedov)
Priority Critical
State Fixed
Type Bug
Fix version 2018.1
Affected versions 2016.2.2
Fixed In Version ReSharper 2018.1 EAP 7
VsVersion All Versions
Consider the following code:

class TestClass
{
public ImageTypeEnum? Kind { get; set; }

public string Description => Kind == null ? "(none)" : ((ImageTypeEnum)Kind.Value).ToString();
}

When I apply the suggested "Merge conditional exprerssion" quickfix, the code becomes broken:

class TestClass
{
public ImageTypeEnum? Kind { get; set; }

public string Description => ((ImageTypeEnum?) Kind?.Value)?.ToString() ?? "(none)";
}

The Kind?.Value makes no sense in the new context, because the value is already unwrapped by a safe navigation operator.

Viewing all articles
Browse latest Browse all 106942

Trending Articles