Skip to content

MethodInvoker synthesizes arguments not provided? #90039

Closed

Description

@stephentoub

I was expecting this to throw an exception:

using System.Reflection;

internal class Program
{
    private static void Main()
    {
        var invoker = MethodInvoker.Create(typeof(Program).GetMethod("MyMethod", BindingFlags.NonPublic | BindingFlags.Static)!);
        invoker.Invoke(null);
    }

    static void MyMethod(int arg0, int arg1, int arg2) => Console.WriteLine($"{arg0} {arg1} {arg2}");
}

since the method has three non-optional parameters and zero arguments are being supplied, but instead it printed:

0 0 0

Is that by design?

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Aug 4, 2023
  2. added this to the 8.0.0 milestone on Aug 5, 2023
  3. ghost removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 5, 2023
  4. added
    untriagedNew issue has not been triaged by the area owner
    on Aug 5, 2023
  5. jkotas commented on Aug 5, 2023

    @jkotas
    Member

    Is that by design?

    This looks like a bug to me. @steveharter ?

  6. removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 7, 2023
  7. steveharter commented on Aug 10, 2023

    @steveharter
    Contributor

    Fixed with #90119

  8. ghost locked as resolved and limited conversation to collaborators on Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions