Open
Description
In the following scenario base.
is incorrectly removed:
class A: B
{
public override void DoSomething()
{
OtherMethod();
}
}
class B: C
{
public void OtherMethod()
{
base.DoSomething();
}
}
class C
{
public virtual void DoSomething()
{
// Do some logic
}
}
If base.
is removed in this scenario, the derived method is called (A.DoSomething() -> B.OtherMethod() -> A.DoSomething() -> B.OtherMethod()
... instead of A.DoSomething() -> B.OtherMethod() -> C.DoSomething()
), causing a StackOverflowException
. This isn't great design, but the fix is dangerous because of this scenario.