New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contravariant type search doesn't consider decorators for more general variants #54

LordZoltan opened this Issue Sep 21, 2017 · 1 comment


None yet
1 participant

LordZoltan commented Sep 21, 2017

Expanding again on the shapes examples in the contravariance documentation, if we reimplement the RectangleComparer as a decorator and register it thus:

container.RegisterDecorator<RectangleComparerDecorator, IComparer<Rectangle>>();

We would expect both the following two assertions to hold:

Assert.IsType<RectangleComparerDecorator>(container.Resolve<IComparer<Square>>()); //fails

Unfortunately, the second fails because the contravariant search for IComparer<Square> doesn't pick up the decorator. It's clearly blind to anything other than a traditional registration.

See this test in the examples project:

public void EmptyDecoratorShouldInjectContravariantBase()

It currently passes because it does partly demonstrate that contravariant decorators do almost work - but the crucial lines within it are commented out:

// BUG #54: this should also work:

@LordZoltan LordZoltan added the bug label Sep 21, 2017

@LordZoltan LordZoltan self-assigned this Sep 21, 2017


This comment has been minimized.


LordZoltan commented May 15, 2018

This is actually related to #72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment