Closed
Description
Description
InterfaceMap when mapping static abstract generic methods does not return a generic method definition. The generic arguments are also generic method type parameters, but they are the ones for the interface type.
Reproduction Steps
public interface I<T> where T : I<T>
{
public void Instance<M>(M m);
public static abstract void Static<M>(M m);
}
public readonly struct C : I<C>
{
public void Instance<M>(M m) { }
public static void Static<M>(M m) { }
}
internal class Program
{
static void Main(string[] args)
{
var interfaceMap = typeof(C).GetInterfaceMap(typeof(I<C>));
for (int i = 0; i < interfaceMap.InterfaceMethods.Length; i++)
{
var imethod = interfaceMap.InterfaceMethods[i];
var tmethod = interfaceMap.TargetMethods[i];
Console.WriteLine($"Interface.{imethod.Name} is generic method def: {imethod.IsGenericMethodDefinition}");
Console.WriteLine($"Target.{tmethod.Name} is generic method def: {tmethod.IsGenericMethodDefinition}");
}
Console.Read();
}
}
Expected behavior
Interface.Instance is generic method def: True
Target.Instance is generic method def: True
Interface.Static is generic method def: True
Target.Static is generic method def: True
Actual behavior
Interface.Instance is generic method def: True
Target.Instance is generic method def: True
Interface.Static is generic method def: True
Target.Static is generic method def: False
Regression?
No as these are new.
Known Workarounds
No response
Configuration
.net 7 preview 7.
Other information
No response