I suggest you ...

[Windsor] Support interception for services created UsingFactoryMethod

It would be interesting if Windsor could support the interception of calls made to services created via the 'UsingFactoryMethod' syntax:

container.Register(Component.For<ISomeService>().UsingFactoryMethod(()
=> new
SomeServiceImpl(5)).Interceptors(InterceptorReference.ForType<SomeServiceIn terceptor>()).First);

Currently, this will generate the following exception when any member of the resolved service is called:

System.NotImplementedException: This is a DynamicProxy2 error: the
interceptor attempted to 'Proceed' for method 'Int32
DoSomething(Int32)' which has no target. When calling method without
target there is no implementation to 'proceed' to and it is the
responsibility of the interceptor to mimic the implementation (set
return value, out arguments etc)

6 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    anonymousanonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • AnonymousAnonymous commented  ·   ·  Flag as inappropriate

        Had the same issue (IModelInterceptorsSelector) and also discovered this at late stage and now need to change the implementation, also documentation didn’t mention any such limitation.
        I think it can be supported by the framework.

      • Mark SeemannMark Seemann commented  ·   ·  Flag as inappropriate

        I just spent a couple of hours before discovering that there might be an issue here, so I'd appreciate this ability.

        However, my approach was slightly different than above because I implemented IModelInterceptorsSelector, but it turns out that the HasInterceptors method is never called with the service in question because it has been registered with UsingFactoryMethod.

      Feedback and Knowledge Base