autofac / Autofac.Extras.DynamicProxy

Interceptor and decorator support for Autofac IoC via Castle DynamicProxy
MIT License
106 stars 33 forks source link

Intercept all registrations with an interceptor #49

Open mannok opened 1 year ago

mannok commented 1 year ago

Problem Statement

Currently, there isn't a way to intercept all registrations and we cannot make a global interceptor like "global logger". Most of the workarounds in stackoverflow are hacky and not concise https://stackoverflow.com/questions/22782086/autofac-global-interface-interceptor-with-autofac-extras-dynamicproxy2

Desired Solution

To intercept all registered interfaces in Autofac setup.

tillig commented 1 year ago

Given you need to tell us whether it's interface interception or class interception when you register, and whatever we do here needs to also work with the other features in core Autofac like adapters, decorators, aggregate services, and so on, can you elaborate on your proposal to explain how you would expect it to behave in all of these various situations?

mannok commented 1 year ago

Hi @tillig , Thanks for awaring.

I would like to intercept all implementation of DI services in order to enable all-round exception logging, i.e. using interface and implementation pattern I am able to intercept all function executions by enclosing it with try-catch block.

May I know if it is possible?

tillig commented 1 year ago

@mannok it is not currently possible to register a global interceptor. This issue is about a proposal to make that work. I posed several questions about the desired functionally and those haven't been answered. There is no current ongoing work on this issue.

mannok commented 1 year ago

@tillig May I know what are those questions about? Thanks

tillig commented 1 year ago

@mannok Scroll through the issue and read all the comments.