This is just an assert guarding some invariant that the reflection stack relies on. The test "works" with a release build of the runtime, but whatever invariant it's guarding obviously doesn't hold.
Ran into this while writing tests for #103220, going to disable newly added tests on this.
Process terminated. Assertion failed.
The class hierarchy should declare the method
at System.Delegate.GetMethodImpl()
at System.MulticastDelegate.GetMethodImpl()
at Program.<Main>$(String[] args)
Hit for the following program:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using Internal;
foreach (var o in Create_ClosedDelegate_TestData())
Console.WriteLine(((Delegate)o[0]).Method.ToString());
static IEnumerable<object[]> Create_ClosedDelegate_TestData()
{
const string TestNamespace = nameof(System);
IGenericInterfaceForDiagnosticMethodInfoTests<object> og = new GenericClassForDiagnosticMethodInfoTests<object>();
yield return new object[] {
(Action)og.NonGenericDefaultMethod,
nameof(IGenericInterfaceForDiagnosticMethodInfoTests<object>.NonGenericDefaultMethod) ,
TestNamespace + nameof(IGenericInterfaceForDiagnosticMethodInfoTests<object>) + "`1"
};
yield return new object[] {
(Action)og.GenericDefaultMethod<object>,
nameof(IGenericInterfaceForDiagnosticMethodInfoTests<object>.GenericDefaultMethod),
TestNamespace + nameof(IGenericInterfaceForDiagnosticMethodInfoTests<object>) + "`1"
};
}
interface IGenericInterfaceForDiagnosticMethodInfoTests<T>
{
void NonGenericMethod();
void GenericMethod<U>();
void NonGenericDefaultMethod() { }
void GenericDefaultMethod<U>() { }
}
class GenericClassForDiagnosticMethodInfoTests<T> : IGenericInterfaceForDiagnosticMethodInfoTests<T>
{
void IGenericInterfaceForDiagnosticMethodInfoTests<T>.GenericMethod<U>() => throw new NotImplementedException();
void IGenericInterfaceForDiagnosticMethodInfoTests<T>.NonGenericMethod() => throw new NotImplementedException();
public void Method1() { }
public void Method2() { }
}
This is just an assert guarding some invariant that the reflection stack relies on. The test "works" with a release build of the runtime, but whatever invariant it's guarding obviously doesn't hold.
Ran into this while writing tests for #103220, going to disable newly added tests on this.
Hit for the following program: