Skip to content

Postpone marking DAM members until type allocated #110563

@MichalStrehovsky

Description

@MichalStrehovsky

We currently keep the M method for this even though it's provably unreachable - we intend to keep it because of a object.GetType call but the instance was never allocated so object.GetType would never return C.

using System.Diagnostics.CodeAnalysis;

class Program
{
    private static C _inst;

    public static void Main()
    {
        if (_inst != null)
            RequirePublicMethods(_inst.GetType());
    }

    public static void RequirePublicMethods([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type t) { }
}


[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)]
class C
{
    public void M() { }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions