Skip to content

Delegate creation with optional methods throw TargetParameterCountException when Dispatcher consumes #101400

Open

Description

@Aytackydln

Hopefully this is the correct repository to report. This behaviour is really annoying since you cannot find where this is caused from the exception trace since this is thrown in the consuming thread.

Version Used:
NET 8

Steps to Reproduce:

Dispatcher case code sample:
https://github.com/Aytackydln/OptionalParameterTaskWpf

  1. Define a method with optional parameter
  2. Pass it to an "async" method with only method name
    Like:
    Dispatcher.BeginInvoke(MethodWithOptionalParameter)
    AsyncMethod(MethodWithOptionalParameter)
  3. Let the dispatcher consume

quick sharplab sample

Activity

  1. ghost added
    untriaged
    on Apr 7, 2024
  2. jaredpar commented on Apr 22, 2024

    @jaredpar
    Member

    Moving to runtime as this is not a compiler bug, it's about the exception information generated for this scenario.

    Note: not a regression, tested this all the way back to net6.0 and observe the same behavior.

  3. transferred this issue fromdotnet/roslynon Apr 22, 2024
  4. ghost added
    needs-area-label
    on Apr 22, 2024
  5. removed
    needs-area-label
    on Apr 25, 2024
  6. added
    enhancement
    and removed
    untriaged
    on Jun 14, 2024
  7. added this to the Future milestone on Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-TypeSystem-coreclrenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions