dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.97k stars 4.66k forks source link

ILLink doesn't warn for annotation mismatch for derived method implementing a recursive interface #106552

Open jtschuster opened 1 month ago

jtschuster commented 1 month ago

In IL it is valid for an abstract Base to implement I but provide no methods. This is not possible in C#, as Base would not be allowed to be missing M. If Base does provide M, the trimmer does warn there (see RequiresCapability/BaseProvidesInterfaceMethodRequiresMismatch.cs). This is a very niche corner case and not the highest priority.

abstract class Base : I
{
}

class Derived : Base
{
    public virtual void M() {} // warning IL2046
}

interface I
{
    [RequiresUnreferencedCode("RUC")]
    void M();
}

See https://github.com/dotnet/runtime/pull/103317#discussion_r1718737150_ for context

dotnet-policy-service[bot] commented 1 month ago

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas See info in area-owners.md if you want to be subscribed.