Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Provide examples of Info.OfMethod for generic method and methods with arguments. #582

@virzak

Description

@virzak

Describe the issue

Info.MethodOf documentation is somewhat unclear regarding generic methods and parameters.

Below are some of my attempts that came up short.

Minimal Repro

namespace MyNs
{
    public class MyClass
    {
        // OK
        public static readonly MethodInfo ProduceMethod = Info.OfMethod<MyClass>(nameof(Produce)); // OK
        public static readonly MethodInfo ProduceMethod2 = Info.OfMethod("InfoOfMethodOverload", "MyNs.MyClass", "Produce"); // OK
        public int Produce() => throw new NotImplementedException();
        
        // What do I do?
        //public static readonly MethodInfo ProduceGeneric = Info.OfMethod<MyClass>(nameof(Produce)+"``1<T>");
        //public static readonly MethodInfo ProduceGeneric = Info.OfMethod("InfoOfMethodOverload", "MyNs.MyClass", nameof(Produce)+"``1<T>");
        //public static readonly MethodInfo ProduceGeneric = Info.OfMethod("InfoOfMethodOverload", "MyNs.MyClass", nameof(Produce)+"``1<mscorlib|System.Int32>");
        public int Produce<T>() => throw new NotImplementedException();

        // What do I do?
        //public static readonly MethodInfo ProduceWithParam = Info.OfMethod<MyClass>(nameof(Produce), "System.Runtime|System.Int32");
        //public static readonly MethodInfo ProduceWithParam2 = Info.OfMethod("InfoOfMethodOverload", "MyNs.MyClass", "Produce", "mscorlib|System.Int32");
        //public static readonly MethodInfo ProduceWithParam2 = Info.OfMethod("InfoOfMethodOverload", "MyNs.MyClass", "Produce", "int");
        public int Produce(int z) => throw new NotImplementedException();
    }
}

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