Sweep base methods if not required
- Dominant language
- C#
- Stars
- 392
- Forks
- 128
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 2
Description
The linker marks all base methods of any marked method, even if it's not strictly required.
For example, in Inheritance.VirtualMethods.VirtualMethodGetsStrippedIfImplementingMethodGetsInvokedDirectly.cs:
```C#
class VirtualMethodGetsStrippedIfImplementingMethodGetsInvokedDirectly
{
public static void Main ()
{
new A ().Foo ();
}
[KeptMember (".ctor()")]
class B
{
// TODO: Would be nice to be removed
[KeptBy (typeof (A), nameof (A.Foo), "BaseMethod")]
public virtual void Foo ()
{
}
}
[KeptMember (".ctor()")]
[KeptBaseType (typeof (B))]
class A : B
{
[KeptBy (typeof(A), nameof(Foo), DependencyKind.DirectCall)]
public override void Foo ()
{
}
}
}
}
```
We know that Foo is only called on A, so we could be able to remove B.Foo() and make A.Foo not virtual.
Similarly, we could remove all of B if we sweep unused base types.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.