Skip to content

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

Closed

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]()

Activity

  1. added this to the 9.0.0 milestone on Apr 14, 2024
  2. dotnet-policy-service commented on Apr 14, 2024

    @dotnet-policy-service
    Contributor

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

  3. locked and limited conversation to collaborators on May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

  • Status
    No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions