Skip to content
This repository was archived by the owner on Aug 24, 2022. It is now read-only.
This repository was archived by the owner on Aug 24, 2022. It is now read-only.

Delegate.Method fails when called in constructor. #1051

@baehny

Description

@baehny

Delegate.Method crashs when called in a constructor. The same code works when called inside a member method that is called in the ctor.

    class Class1
    {
        public Class1()
        {
            Delegate d = new Action<int>(
            (int someVar) =>
            {

            });
            var p = d.Method.GetParameters(); // TypeError: d.get_Method(...) is null
        }
    }
    class Class2
    {
        public Class2()
        {
            MemberMethod();
        }

        public void MemberMethod()
        {
            Delegate d = new Action<int>(
            (int someVar) =>
            {

            });
            var p = d.Method.GetParameters(); // TypeError: d.get_Method(...) is null
        }
    }

    public class JSILLimitations
    {
        public static void DelegateBug()
        {
            Delegate d = new Action<int>(
            (int console) =>
            {

            });
            var p = d.Method.GetParameters();
            Console.WriteLine("Static method version works.");

            Class2 clazz2 = new Class2();
            Console.WriteLine("Member method call version works.");

            Class1 clazz1 = new Class1();
            //Crash
            Console.WriteLine("Ctor method version works."); //
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions