Skip to content

[NativeAOT] Trivial use of Delegate.Method is not enabling delegate targets for reflection #101026

@jkotas

Description

@jkotas

Repro

class Program
{
    static void Main() => Console.WriteLine(new Action(Test<string>).Method);

    static void Test<T>() { }
}

Actual behavior (current main)

Unhandled exception. System.NotSupportedException: Cannot retrieve a MethodInfo for this delegate because the method it targeted (Program.Test[T]()) was not enabled for metadata.
   at Internal.Reflection.Extensions.NonPortable.DelegateMethodInfoRetriever.GetDelegateMethodInfo(Delegate) + 0x276
   at Program.Main() + 0x26

Expected behavior (.NET 8)

Void Test[String]()

Metadata

Metadata

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions