Skip to content

Remove DAM warning for base types/interfaces #118713

@sbomer

Description

@sbomer

Similar to #107660, it should be possible to call static methods on a derived type even if the type declaration has mismatching DAM annotations. The problem should surface when the base type is actually instantiated:

using System.Diagnostics.CodeAnalysis;

Derived<int>.DoSomethingSafe();
new Derived<int>();

class Derived<T> : Base<T> // warns here but should not
{
    public Derived() // warns here
    {
    }

    public static void DoSomethingSafe() { }
}

class Base<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>
{
    static void Require() => typeof(T).GetMethods();
}

Similar for interfaces.

@MichalStrehovsky @agocke do you agree or can you see any problems with this?

Metadata

Metadata

Assignees

Labels

area-Tools-ILLink.NET linker development as well as trimming analyzers

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions