Skip to content

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

Open
@jakobbotsch

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions