lundi 2 février 2015

Unsafe redundance refatoring in ReSharper 9.0?


Considering the following scenario:



public class A
{
...
public virtual void Foo() { ... }
...
}

public class B : A
{
public void DoSomething()
{
...
base.Foo();
...
}
}

public class C : B
{
...
public override void Foo()
{
...
}

public void MakeItSo()
{
DoSomething();
}
...
}


ReSharper 9.0 underlines the "base." in "base.Foo()" in class B, saying "Qualifier 'base.' is redundant". Before the refactoring, when I call C.MakeItSo(), the "DoSomething" method in B is calling A.Foo(). After the refactoring, because Foo() is overridden in C, the former call "base.Foo()" calls C.Foo() directly instead of A.Foo(). Should this be considered as a bug in the Resharper tool, because behavior is not preserved?





Aucun commentaire:

Enregistrer un commentaire