Trim virtual method bodies if they are not called via `base` and the type itself is not constructed.
- Dominant language
- C#
- Stars
- 392
- Forks
- 128
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 2
Description
Let's say that we have the following code:
``` csharp
using System.Text.RegularExpressions;
Console.WriteLine(new Derived().Get().IsMatch("226"));
public class Base
{
public virtual Regex Get() => new Regex(@"\d+");
}
public partial class Derived : Base
{
[RegexGenerator(@"\d+")]
private static partial Regex GetRegex();
public override Regex Get() => GetRegex();
}
```
`Base.Get` is never called because first, we don't do `new Base()` anywhere and second, descendants of `Base` do not call `base.Get()`. Its method body is preserved however after trimming. The linker could recognize that and trim it away.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.