Closed
Description
Description
When you have a generic interface I2<S>
, providing a default interface implementation for a generic method void G<T>()
on a generic interface I1<S>
, and you have a class C2Implicit<S>
which implements I2<S>
implicitly, and then you call GetInterfaceMap
on a specific generic instantiation of these (e.g., I1 and C2Implicit<string>
), the the target method for void I1<S>.G<T>()
is invalid.
Reproduction Steps
var x1 = typeof(I2<string>).GetMethod("I1<S>.G", (BindingFlags)(-1));
var x2 = typeof(C2<string>).GetInterfaceMap(typeof(I1<string>)).TargetMethods.Single((x) => x.Name == "I1<S>.G");
Console.WriteLine(x1 == x2);
Console.WriteLine(x1.MakeGenericMethod(typeof(int)).ContainsGenericParameters);
Console.WriteLine(x2.MakeGenericMethod(typeof(int)).ContainsGenericParameters);
interface I1<S>
{
static abstract void G<T>();
}
interface I2<S> : I1<S>
{
static void I1<S>.G<T>() { }
}
class C2<S> : I2<S>
{
}
Expected behavior
Prints:
True
False
False
Actual behavior
False
False
Unhandled exception. System.InvalidOperationException: Void I1<S>.G[T]() is not a GenericMethodDefinition. MakeGenericMethod may only be called on a method for which MethodBase.IsGenericMethodDefinition is true.
at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
Follow up to #90351 (comment) and #90518 (comment)