Add memento capture to IInvocation (aka async interception groundwork)#438
Closed
stakx wants to merge 3 commits intocastleproject:masterfrom
Closed
Add memento capture to IInvocation (aka async interception groundwork)#438stakx wants to merge 3 commits intocastleproject:masterfrom
IInvocation (aka async interception groundwork)#438stakx wants to merge 3 commits intocastleproject:masterfrom
Conversation
This is a sneaky way of making `AbstractInvocation.currentInterceptor- Index` modifiable without exposing it.
Member
Author
|
Closing for the time being... while this doesn't expose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the smallest change I can think of that might just be sufficient to enable people to write async interceptors. While technically still a breaking change (it adds a new member to the pre-existing
IInvocationinterface) it's a comparatively minor one, and it does fix the same unit test from #429.What problem does this PR attempt to solve? As soon as an async continuation is set up in an interceptor's
Interceptmethod (e.g. by means of anawait), interception starts to regress back to the caller and the invocation'scurrentInterceptorIndexstarts getting decremented—this is whyinvocation.Proceed()will no longer work in the async continuations: it will end up proceeding to an earlier interceptor instead of to the next one.I therefore tried to find a way to make
currentInterceptorIndexmodifiable without exposing it, and ended up with the Memento pattern.While I think completely removing
Proceed(andcurrentInterceptorIndexwith it) fromAbstractInvocationwould possibly be the cleaner solution in the long term, it would also trigger the need for a fairly large breaking change in DynamicProxy'sIntercept/ProceedAPI, and I'm not sure we're ready for that.I don't expect this to get merged, as we probably don't really need a generic memento facility for invocation objects 😜, but I am still curious what others think about this approach.
/cc @JSkimming, @brunoblank