Autofac.Extras.DynamicProxy icon indicating copy to clipboard operation
Autofac.Extras.DynamicProxy copied to clipboard

Intercept all registrations with an interceptor

Open mannok opened this issue 3 years ago • 5 comments

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.

mannok avatar Sep 26 '22 01:09 mannok

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?

tillig avatar Sep 26 '22 02:09 tillig

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?

mannok avatar Nov 22 '22 06:11 mannok

@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.

tillig avatar Nov 22 '22 06:11 tillig

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

mannok avatar Nov 22 '22 09:11 mannok

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

tillig avatar Nov 22 '22 15:11 tillig