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

RSRP-468743: Convert to ?: suggestion incorrect

$
0
0
Reporter Olga Rodygina (olgarodygina) Olga Rodygina (olgarodygina)
Created Mar 19, 2018 4:10:46 PM
Updated Apr 23, 2018 1:52:01 PM
Resolved Apr 23, 2018 1:52:01 PM
Subsystem Quick Fixes
Assignee Andrey Dyatlov (Andrey.Dyatlov)
Priority Normal
State Fixed
Type Bug
Fix version 2018.1
Affected versions 2017.3.2
Fixed In Version ReSharper Undefined
VsVersion All Versions
When I have a code like this:

if (locationsMap.TryGetValue(reader.GetInt(0), out LocationImportData locationData))
{
locationData.EndpointId = reader.GetInt( 1 );
}
else
{
locationData.EndpointId = locationData.CurrentEndpoint.Id;
}

R# suggests to simplify to:

locationData.EndpointId = locationsMap.TryGetValue(reader.GetInt(0), out LocationImportData locationData) ? reader.GetInt( 1 ) : locationData.CurrentEndpoint.Id;


but this will render the code non-compilable, because locationData will be used before it is declared.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>