Reporter | 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:
R# suggests to simplify to:
but this will render the code non-compilable, because locationData will be used before it is declared.
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.