@@ -51,7 +51,7 @@ void IAsyncInterceptor.InterceptSynchronous(IInvocation invocation)
5151 /// <param name="invocation">The method invocation.</param>
5252 void IAsyncInterceptor . InterceptAsynchronous ( IInvocation invocation )
5353 {
54- invocation . ReturnValue = InterceptAsync ( invocation . GetProceedInfo ( ) , ProceedAsynchronous ) ;
54+ invocation . ReturnValue = InterceptAsync ( invocation , invocation . GetProceedInfo ( ) , ProceedAsynchronous ) ;
5555 }
5656
5757 /// <summary>
@@ -61,29 +61,34 @@ void IAsyncInterceptor.InterceptAsynchronous(IInvocation invocation)
6161 /// <param name="invocation">The method invocation.</param>
6262 void IAsyncInterceptor . InterceptAsynchronous < TResult > ( IInvocation invocation )
6363 {
64- invocation . ReturnValue = InterceptAsync ( invocation . GetProceedInfo ( ) , ProceedAsynchronous < TResult > ) ;
64+ invocation . ReturnValue =
65+ InterceptAsync ( invocation , invocation . GetProceedInfo ( ) , ProceedAsynchronous < TResult > ) ;
6566 }
6667
6768 /// <summary>
6869 /// Override in derived classes to intercept method invocations.
6970 /// </summary>
71+ /// <param name="invocation">The method invocation.</param>
7072 /// <param name="proceedInfo">The <see cref="IInvocationProceedInfo"/>.</param>
7173 /// <param name="proceed">The function to proceed the <paramref name="proceedInfo"/>.</param>
7274 /// <returns>A <see cref="Task" /> object that represents the asynchronous operation.</returns>
7375 protected abstract Task InterceptAsync (
76+ IInvocation invocation ,
7477 IInvocationProceedInfo proceedInfo ,
75- Func < IInvocationProceedInfo , Task > proceed ) ;
78+ Func < IInvocation , IInvocationProceedInfo , Task > proceed ) ;
7679
7780 /// <summary>
7881 /// Override in derived classes to intercept method invocations.
7982 /// </summary>
8083 /// <typeparam name="TResult">The type of the <see cref="Task{T}"/> <see cref="Task{T}.Result"/>.</typeparam>
84+ /// <param name="invocation">The method invocation.</param>
8185 /// <param name="proceedInfo">The <see cref="IInvocationProceedInfo"/>.</param>
8286 /// <param name="proceed">The function to proceed the <paramref name="proceedInfo"/>.</param>
8387 /// <returns>A <see cref="Task" /> object that represents the asynchronous operation.</returns>
8488 protected abstract Task < TResult > InterceptAsync < TResult > (
89+ IInvocation invocation ,
8590 IInvocationProceedInfo proceedInfo ,
86- Func < IInvocationProceedInfo , Task < TResult > > proceed ) ;
91+ Func < IInvocation , IInvocationProceedInfo , Task < TResult > > proceed ) ;
8792
8893 private static GenericSynchronousHandler CreateHandler ( Type returnType )
8994 {
@@ -93,7 +98,7 @@ private static GenericSynchronousHandler CreateHandler(Type returnType)
9398
9499 private static void InterceptSynchronousVoid ( AsyncInterceptorBase me , IInvocation invocation )
95100 {
96- Task task = me . InterceptAsync ( invocation . GetProceedInfo ( ) , ProceedSynchronous ) ;
101+ Task task = me . InterceptAsync ( invocation , invocation . GetProceedInfo ( ) , ProceedSynchronous ) ;
97102
98103 // If the intercept task has yet to complete, wait for it.
99104 if ( ! task . IsCompleted )
@@ -112,7 +117,7 @@ private static void InterceptSynchronousVoid(AsyncInterceptorBase me, IInvocatio
112117
113118 private static void InterceptSynchronousResult < TResult > ( AsyncInterceptorBase me , IInvocation invocation )
114119 {
115- Task < TResult > task = me . InterceptAsync ( invocation . GetProceedInfo ( ) , ProceedSynchronous < TResult > ) ;
120+ Task < TResult > task = me . InterceptAsync ( invocation , invocation . GetProceedInfo ( ) , ProceedSynchronous < TResult > ) ;
116121
117122 // If the intercept task has yet to complete, wait for it.
118123 if ( ! task . IsCompleted )
@@ -129,7 +134,7 @@ private static void InterceptSynchronousResult<TResult>(AsyncInterceptorBase me,
129134 }
130135 }
131136
132- private static Task ProceedSynchronous ( IInvocationProceedInfo proceedInfo )
137+ private static Task ProceedSynchronous ( IInvocation invocation , IInvocationProceedInfo proceedInfo )
133138 {
134139 try
135140 {
@@ -152,12 +157,14 @@ private static Task ProceedSynchronous(IInvocationProceedInfo proceedInfo)
152157 }
153158 }
154159
155- private static Task < TResult > ProceedSynchronous < TResult > ( IInvocationProceedInfo proceedInfo )
160+ private static Task < TResult > ProceedSynchronous < TResult > (
161+ IInvocation invocation ,
162+ IInvocationProceedInfo proceedInfo )
156163 {
157164 try
158165 {
159166 proceedInfo . Invoke ( ) ;
160- return Task . FromResult ( ( TResult ) proceedInfo . Invocation . ReturnValue ) ;
167+ return Task . FromResult ( ( TResult ) invocation . ReturnValue ) ;
161168 }
162169 catch ( Exception e )
163170 {
@@ -171,22 +178,24 @@ private static Task<TResult> ProceedSynchronous<TResult>(IInvocationProceedInfo
171178 }
172179 }
173180
174- private static async Task ProceedAsynchronous ( IInvocationProceedInfo proceedInfo )
181+ private static async Task ProceedAsynchronous ( IInvocation invocation , IInvocationProceedInfo proceedInfo )
175182 {
176183 proceedInfo . Invoke ( ) ;
177184
178185 // Get the task to await.
179- var originalReturnValue = ( Task ) proceedInfo . Invocation . ReturnValue ;
186+ var originalReturnValue = ( Task ) invocation . ReturnValue ;
180187
181188 await originalReturnValue . ConfigureAwait ( false ) ;
182189 }
183190
184- private static async Task < TResult > ProceedAsynchronous < TResult > ( IInvocationProceedInfo proceedInfo )
191+ private static async Task < TResult > ProceedAsynchronous < TResult > (
192+ IInvocation invocation ,
193+ IInvocationProceedInfo proceedInfo )
185194 {
186195 proceedInfo . Invoke ( ) ;
187196
188197 // Get the task to await.
189- var originalReturnValue = ( Task < TResult > ) proceedInfo . Invocation . ReturnValue ;
198+ var originalReturnValue = ( Task < TResult > ) invocation . ReturnValue ;
190199
191200 TResult result = await originalReturnValue . ConfigureAwait ( false ) ;
192201 return result ;
0 commit comments