Skip to content

[RuntimeAsync] Reflection complains about ambiguity when querying async2 methods #115258

Closed

Description

@jakobbotsch
using System;
using System.Reflection;
using System.Threading.Tasks;
using Xunit;

public class Async2Reflection
{
    [Fact]
    public static void TestEntryPoint()
    {
        typeof(Async2Reflection).GetMethod("Foo", BindingFlags.Static | BindingFlags.NonPublic);
    }

#pragma warning disable CS1998
    private static async2 Task Foo()
    {
    }
}

Gives

System.Reflection.AmbiguousMatchException: Ambiguous match found for 'Async2Reflection Void Foo()'.
   at System.DefaultBinder.FindMostDerivedNewSlotMeth(MethodBase[] match, Int32 cMatches)
   at System.RuntimeType.GetMethodImplCommon(String name, Int32 genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.Type.GetMethod(String name, BindingFlags bindingAttr)
   at Async2Reflection.TestEntryPoint() in C:\dev\dotnet\runtimelab\src\tests\async\reflection.cs:line 16
   at __GeneratedMainWrapper.Main() in C:\dev\dotnet\runtimelab\artifacts\tests\coreclr\obj\windows.x64.Release\Managed\async\reflection\XUnitWrapperGenerator\XUnitWrapperGenerator.XUnitWrapperGenerator\SimpleRunner.g.cs:line 7

Activity

  1. jakobbotsch commented on Nov 28, 2024

    @jakobbotsch
    MemberAuthor

    Also happens for any Task returning function.

  2. VSadov commented on May 3, 2025

    @VSadov
    Member

    This may no longer be a problem in the last implementation, but needs to be checked.

  3. self-assigned this
    on May 3, 2025
  4. transferred this issue fromdotnet/runtimelabon May 3, 2025
  5. added
    untriaged
    on May 3, 2025
  6. dotnet-policy-service commented on May 3, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-reflection
    See info in area-owners.md if you want to be subscribed.

  7. added
    needs-further-triage
    and removed
    untriaged
    on May 28, 2025
  8. added this to the 10.0.0 milestone on May 28, 2025
  9. locked and limited conversation to collaborators on Jul 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Reflectionneeds-further-triageruntime-async

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions