Skip to content
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

Interface interception doesn't work if the interface is implemented by a base type of the implementing type #17

Open
ENikS opened this issue Sep 1, 2018 · 0 comments
Labels
Enhancement 🔨 Improvement of existing features
Milestone

Comments

@ENikS
Copy link
Contributor

ENikS commented Sep 1, 2018

@vmelamed wrote:

The following code illustrates the problem:

public interface ITestCalls
{
    void Test1();
}

public abstract class BaseTestCalls : ITestCalls
{
    public void Test()
    {
    }
}

[Tag("track")]
public class TrackTestCalls : BaseTestCalls
{
}

[Tag("track1")]
public class TrackTestCalls1 : ITestCalls
{
    public void Test()
    {
    }
}

static void Main(string[] args)
{
    IUnityContainer container = new UnityContainer();

    container.AddNewExtension<Interception>();

    container
        .Configure<Interception>()
        .AddPolicy("track")
        .AddMatchingRule<TagAttributeMatchingRule>(
                            new InjectionConstructor("track", false))
        .AddCallHandler<TrackCallHandler>(
                            new ContainerControlledLifetimeManager())
        ;

    container
        .RegisterType<ITestCalls, TrackTestCalls>(
            "track",
            new InterceptionBehavior<PolicyInjectionBehavior>(),
            new Interceptor<TransparentProxyInterceptor>())

        .RegisterType<ITestCalls, TrackTestCalls1>(
            "track1",
            new InterceptionBehavior<PolicyInjectionBehavior>(),
            new Interceptor<TransparentProxyInterceptor>())
        ;

    var test = container.Resolve<ITestCalls>("track");

    test.Test();

    var test1 = container.Resolve<ITestCalls>("track1");

    test1.Test();
}

test.Test() does not exhibit the decorated behavior and the object test is not supplied with a pipeline. However test1.Test() behaves as expected and test1 has the pipeline.

I could not find this being documented anywhere.

@ENikS ENikS added the Enhancement 🔨 Improvement of existing features label Sep 1, 2018
@ENikS ENikS added this to the 5.6.0 milestone Sep 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 🔨 Improvement of existing features
Projects
None yet
Development

No branches or pull requests

1 participant