Giter Club home page Giter Club logo

Comments (4)

stakx avatar stakx commented on July 18, 2024

I don't know Autofac Interceptors so I can't really help much.

I can tell you, however, that DynamicProxy is unable to intercept sealed methods such as your Calculator class' Add and Subtract. Try making them virtual and see what happens.

Depending on how exactly Autofac Interceptors makes use of DynamicProxy, they might even be able to get this to work for you automatically by re-implementing ICalculator, then intercept those interface methods, and possibly forward to the Calculator class' implementations if so desired. But you'd need to have a discussion about that with their team.

from core.

tskong avatar tskong commented on July 18, 2024

It does intercept Add() and Subtract() even though they aren't virtual, which goes against what's in the documentation.

Infact, it intercepts all public methods on Calculator(), except when one of these methods invokes another public method inside the same class. It only appears to intercept the very first call.

I did try making them all virtual but the behaviour is the same.

from core.

stakx avatar stakx commented on July 18, 2024

If Autofac Interceptors intercepts your sealed Calculator methods (or at least you think that this is what it does), it is much more likely that it actually reimplements ICalculator in the proxy subclass (which derives from Calculator) and intercepts those methods. If these methods then delegate to the base class implementation, and those base class methods call each other (while seeing this typed as Calculator instead of ICalculator), then interception is effectively bypassed, since the method implementations that kick off the interception sit in the more derived proxy subclass and the base class implementations never call those.

This isn't a problem with DynamicProxy, but with the specific usage pattern found in Autofac Interceptors. I have to refer you back to their team, there's nothing wrong with DynamicProxy if my guess is correct, and there's nothing we can do here.

from core.

tskong avatar tskong commented on July 18, 2024

Hi, thanks for looking into this. After much investigation over the weekend, I discovered that the interception was working to spec. The sub interception I had been told by a more experienced developer for this application wasn't actually happening, and there was other application code in play.

Sorry for wasting your time on this, but it was very interesting looking through the source.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.