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

Intercept Async Methods, IInterceptor vs IAsyncInterceptor #272

Open
scovel opened this issue Nov 16, 2020 · 4 comments
Open

Intercept Async Methods, IInterceptor vs IAsyncInterceptor #272

scovel opened this issue Nov 16, 2020 · 4 comments

Comments

@scovel
Copy link

scovel commented Nov 16, 2020

I've been using Grace for some time. Thanks! It has been working really well.

I've been implementing IInterceptor, but as our code gets more and more async, I'm finding that this isn't working. I'm using Castle.Core for interception.

Someone has written an extension for Castle.Core to help simplify Async Interception. Castle.Core.AsyncInterceptor. The type I'm using is IAsyncInterceptor, as mentioned in Option 2.

In order for this to work, there needs to be some support in Grace for the new interface, IAsyncInterceptor.

So 2 questions I guess.

  1. Is there a currently supported way to handle intercepting Async and Synchronous Methods? (example?)
  2. If not, would it be possible to support IAsyncInterceptor in Grace?

Thanks,

Sean

@silkfire
Copy link
Contributor

@ipjohnson Could this be a limitation due to the lack of async support in LINQ expressions (Expression)? Seeing as System.Linq.Expressions have been archived this doesn't look very promising.

dotnet/csharplang#158
dotnet/runtime#27790

@ipjohnson
Copy link
Owner

@silkfire is correct that Grace itself can not have async parts in dependency construction.

That said Grace doesn't do any interception itself so it should be possible to plug in any interception library be it sync or async.

What specifically isn't work?

@scovel
Copy link
Author

scovel commented Nov 16, 2020

Good question. I guess I've been using it so long I forgot who owns the interception code.

I'm using (an old copy, I just noticed) of this InterceptionExtensions to hook up interception.

It doesn't support the new IAsyncInterceptor interface. Now that I realize where that came from, I can understand your confusion!

InterceptionHandler class implements IAsyncInterceptor. It used to implement IInteceptor.

exportRegistrationBlock.Intercept(interceptInterface);

The constraint on this is for IInterceptor. I guess I need to spend some time on this code, see if I can get it working with IAsyncInterceptor.

I may need some help if I get stuck.

Thanks,

Sean

@ipjohnson
Copy link
Owner

Let me know if you run into any trouble, my hope is that it's pretty straight forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants