Implement nested interface of generic parent class with ironpython
Question: I wan't to implement the following C#/.Net interface with IronPython:

    
    
    public static class Consumes<TMessage> where TMessage : class
    {
       public interface All
       {
           void Consume(TMessage message);
       }
    }
    

This is the python code I tried so far:

    
    
    class TestMessage(object):
         pass
    
    class TestConsumer(Consumes[TestMessage].All):
         def Consume(self, message):
             pass
    

From this I get the following exception:

> TypeError: TestConsumer: cannot inhert from open generic instantiation
> MassTransit.Consumes`1+All[TMessage]. Only closed instantiations are
> supported.

A valid C# class definition to implement this interface looks following:

    
    
    public class TestConsumer : Consumes<TestMessage>.All
    {
        public void Consume(TestMessage msg) { }
    }
    

So is it not possible to implement this kind of in IronPython? Or am I doing
wrong?

Thank you in advance!


Answer: It looks like implementing the nested interface as

    
    
    class TestConsumer(Consumes[TestMessage].All):
    

does not correctly bind the type parameter `TMessage` even though that would
be expected from the syntax. If the type is provided at the end ("for the
interface instead of the surrounding class") it seems to work as expected:

    
    
    class TestConsumer(Consumes.All[TestMessage]):
    

What would also work is importing the interface `All` explicitly and use it
looking like a standalone generic interface:

    
    
    from MyLib.Consumes import All
    class TestConsumer(All[TestMessage]):
    

It does not seem obvious if this behavior is correct/defined that way or if
there is a bug in the [type
generation](https://github.com/IronLanguages/main/blob/master/Languages/IronPython/IronPython/Runtime/Types/NewTypeInfo.cs)
(besides from the "inhert"-typo) or in the way the generic parameters are
defined/bound. It looks to be also accepted to bind the parameter twice:

    
    
    class PyTestConsumer(Consumes[String].All[String]):
    

even with different values which does not make much sense looking at it from a
.NET perspective:

    
    
    class PyTestConsumer(Consumes[List[String]].All[String]):
    

