| Priority |
Normal |
| Type | Bug |
| State | Fixed |
| Assignee | Sergey Shkredov |
| Subsystem | No subsystem |
| Affected versions |
No affected versions
|
| Fixed in |
4.1
|
| Fixed in build | |
| Build |
819
|
| Fixed in build |
910
|
RSRP-75137 |
'Convert To Auto Property' incorrectly re-initializes fields that are already initialized in constructor |
|
|
class ConvertToAutomaticPropertyTest
{
public ConvertToAutomaticPropertyTest(bool testInitialValue)
{
mTest = testInitialValue; // <- note the explicit initialization of the backing field
}
public ConvertToAutomaticPropertyTest()
{
}
private bool mTest = true;
public bool TestProperty
{
get { return mTest; }
set { mTest = value; }
}
}
class ConvertToAutomaticPropertyTest
{
public ConvertToAutomaticPropertyTest(bool testInitialValue)
{
TestProperty = testInitialValue; // Resharper correctly changed mTest to TestProperty here
TestProperty = true; // <- BUT: the initialization is overwritten!
}
public ConvertToAutomaticPropertyTest()
{
TestProperty = true; //<- correct!
}
public bool TestProperty { get; set; }
}