Skip to content

SA1100 incorrectly removes base. if a class doesn't have a local implementation but a subclass does #2938

Open
@ali-hk

Description

@ali-hk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions