diff --git a/framework/src/Volo.Abp.Castle.Core/Volo.Abp.Castle.Core.csproj b/framework/src/Volo.Abp.Castle.Core/Volo.Abp.Castle.Core.csproj
index 421261225f..35e61a6fe5 100644
--- a/framework/src/Volo.Abp.Castle.Core/Volo.Abp.Castle.Core.csproj
+++ b/framework/src/Volo.Abp.Castle.Core/Volo.Abp.Castle.Core.csproj
@@ -21,6 +21,10 @@
+
+
+
+
diff --git a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/AbpAsyncDeterminationInterceptor.cs b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/AbpAsyncDeterminationInterceptor.cs
index 3f15ad631a..022f9a4e28 100644
--- a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/AbpAsyncDeterminationInterceptor.cs
+++ b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/AbpAsyncDeterminationInterceptor.cs
@@ -6,9 +6,21 @@ namespace Volo.Abp.Castle.DynamicProxy;
public class AbpAsyncDeterminationInterceptor : AsyncDeterminationInterceptor
where TInterceptor : IAbpInterceptor
{
+ private readonly TInterceptor _abpInterceptor;
+
public AbpAsyncDeterminationInterceptor(TInterceptor abpInterceptor)
: base(new CastleAsyncAbpInterceptorAdapter(abpInterceptor))
{
+ _abpInterceptor = abpInterceptor;
+ }
+
+ public override void Intercept(IInvocation invocation)
+ {
+ if (CastleAsyncEnumerableAbpInterceptor.TryIntercept(invocation, _abpInterceptor))
+ {
+ return;
+ }
+ base.Intercept(invocation);
}
}
diff --git a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAsyncEnumerableAbpInterceptor.cs b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAsyncEnumerableAbpInterceptor.cs
new file mode 100644
index 0000000000..ce2727248d
--- /dev/null
+++ b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAsyncEnumerableAbpInterceptor.cs
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using System.Threading.Tasks;
+using Castle.DynamicProxy;
+using Volo.Abp.DynamicProxy;
+using Volo.Abp.Reflection;
+
+namespace Volo.Abp.Castle.DynamicProxy;
+
+internal static class CastleAsyncEnumerableAbpInterceptor
+{
+ private delegate object AsyncEnumerableHandler(IInvocation invocation, IAbpInterceptor interceptor);
+
+ private static readonly MethodInfo InterceptMethod = typeof(CastleAsyncEnumerableAbpInterceptor)
+ .GetMethod(nameof(Intercept), BindingFlags.Static | BindingFlags.NonPublic)!;
+
+ private static readonly ConcurrentDictionary Handlers = new();
+
+ private static readonly ConcurrentDictionary MethodsWithByRefParameters = new();
+
+ public static bool TryIntercept(IInvocation invocation, IAbpInterceptor interceptor)
+ {
+ var returnType = invocation.Method.ReturnType;
+ if (!TypeHelper.IsAsyncEnumerable(returnType))
+ {
+ return false;
+ }
+
+ if (MethodsWithByRefParameters.GetOrAdd(invocation.Method, method => method.GetParameters().Any(p => p.ParameterType.IsByRef)))
+ {
+ return false;
+ }
+
+ invocation.ReturnValue = Handlers.GetOrAdd(returnType, CreateHandler)(invocation, interceptor);
+ return true;
+ }
+
+ private static AsyncEnumerableHandler CreateHandler(Type returnType)
+ {
+ return (AsyncEnumerableHandler)InterceptMethod
+ .MakeGenericMethod(returnType.GetGenericArguments()[0])
+ .CreateDelegate(typeof(AsyncEnumerableHandler));
+ }
+
+ private static object Intercept(IInvocation invocation, IAbpInterceptor interceptor)
+ {
+ var methodInvocation = new CastleAbpMethodInvocationAdapterWithReturnValue>(
+ invocation,
+ invocation.CaptureProceedInfo(),
+ ProceedAsync);
+
+ return new InterceptedAsyncEnumerable(InterceptAsync(interceptor, methodInvocation), methodInvocation);
+ }
+
+ private static async Task InterceptAsync(IAbpInterceptor interceptor, IAbpMethodInvocation methodInvocation)
+ {
+ // Also captures a synchronous exception of the interceptor, so it is thrown when enumerating, like for a Task.
+ await interceptor.InterceptAsync(methodInvocation);
+ }
+
+ private static async Task> ProceedAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo)
+ {
+ proceedInfo.Invoke();
+
+ // Waits for the next interceptor, like awaiting the task of a Task-returning method.
+ if (invocation.ReturnValue is InterceptedAsyncEnumerable next)
+ {
+ return (await next.GetResultAsync())!;
+ }
+
+ return (IAsyncEnumerable)invocation.ReturnValue!;
+ }
+
+ private class InterceptedAsyncEnumerable : IAsyncEnumerable, IAbpInterceptedAsyncEnumerable
+ {
+ private readonly Task _interceptTask;
+ private readonly IAbpMethodInvocation _methodInvocation;
+
+ public InterceptedAsyncEnumerable(Task interceptTask, IAbpMethodInvocation methodInvocation)
+ {
+ _interceptTask = interceptTask;
+ _methodInvocation = methodInvocation;
+ }
+
+ public async Task?> GetResultAsync()
+ {
+ await _interceptTask;
+ return (IAsyncEnumerable?)_methodInvocation.ReturnValue;
+ }
+
+ public Task WaitForInterceptorsAsync()
+ {
+ return GetResultAsync();
+ }
+
+ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default)
+ {
+ return EnumerateAsync(cancellationToken).GetAsyncEnumerator(cancellationToken);
+ }
+
+ private async IAsyncEnumerable EnumerateAsync([EnumeratorCancellation] CancellationToken cancellationToken = default)
+ {
+ // Keeps the execution context of the caller for the await below even if the caller suppresses its flow.
+ // The caller is not affected, as its execution context is restored when this step of the async iterator returns.
+ if (ExecutionContext.IsFlowSuppressed())
+ {
+ ExecutionContext.RestoreFlow();
+ }
+
+ var source = await GetResultAsync();
+ if (source == null)
+ {
+ yield break;
+ }
+
+ await foreach (var item in source.WithCancellation(cancellationToken))
+ {
+ yield return item;
+ }
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpInterceptionScope.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpInterceptionScope.cs
new file mode 100644
index 0000000000..6dbd415c8e
--- /dev/null
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpInterceptionScope.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Volo.Abp.DynamicProxy;
+
+public class AbpInterceptionScope : IAbpInterceptionScope
+{
+ private readonly IDisposable? _disposable;
+
+ public AbpInterceptionScope(IDisposable? disposable = null)
+ {
+ _disposable = disposable;
+ }
+
+ public virtual Task CompleteAsync(CancellationToken cancellationToken)
+ {
+ return Task.CompletedTask;
+ }
+
+ public virtual Task FailAsync(Exception exception)
+ {
+ return Task.CompletedTask;
+ }
+
+ public virtual void Dispose()
+ {
+ _disposable?.Dispose();
+ }
+}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpMethodInvocationAsyncEnumerableExtensions.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpMethodInvocationAsyncEnumerableExtensions.cs
new file mode 100644
index 0000000000..4941240eaa
--- /dev/null
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpMethodInvocationAsyncEnumerableExtensions.cs
@@ -0,0 +1,177 @@
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using System.Threading.Tasks;
+using Volo.Abp.Reflection;
+
+namespace Volo.Abp.DynamicProxy;
+
+public static class AbpMethodInvocationAsyncEnumerableExtensions
+{
+ private delegate object WrapHandler(object source, Func beginScope);
+
+ private static readonly MethodInfo WrapMethod = typeof(AbpMethodInvocationAsyncEnumerableExtensions)
+ .GetMethod(nameof(Wrap), BindingFlags.Static | BindingFlags.NonPublic)!;
+
+ private static readonly ConcurrentDictionary WrapHandlers = new();
+
+ ///
+ /// Runs each enumeration of a returned in a new scope.
+ /// must set its async local values (e.g. the ambient unit of work) synchronously.
+ ///
+ public static bool WrapAsyncEnumerable(this IAbpMethodInvocation invocation, Func beginScope)
+ {
+ var handler = WrapHandlers.GetOrAdd(invocation.Method, CreateHandler);
+ if (handler == null || invocation.ReturnValue == null)
+ {
+ return false;
+ }
+
+ invocation.ReturnValue = handler(invocation.ReturnValue, beginScope);
+ return true;
+ }
+
+ private static WrapHandler? CreateHandler(MethodInfo method)
+ {
+ // The return value of a method with ref or out parameters cannot be replaced, as it is not intercepted asynchronously.
+ var returnType = method.ReturnType;
+ if (!TypeHelper.IsAsyncEnumerable(returnType) ||
+ method.GetParameters().Any(p => p.ParameterType.IsByRef))
+ {
+ return null;
+ }
+
+ return (WrapHandler)WrapMethod
+ .MakeGenericMethod(returnType.GenericTypeArguments[0])
+ .CreateDelegate(typeof(WrapHandler));
+ }
+
+ private static object Wrap(object source, Func beginScope)
+ {
+ return EnumerateInScopeAsync((IAsyncEnumerable)source, beginScope);
+ }
+
+ private static async IAsyncEnumerable EnumerateInScopeAsync(
+ IAsyncEnumerable source,
+ Func beginScope,
+ [EnumeratorCancellation] CancellationToken cancellationToken = default)
+ {
+ var scope = beginScope();
+
+ // Each step of an async iterator runs in the execution context of its caller, without the async local values set by beginScope.
+ var context = CaptureExecutionContext();
+
+ try
+ {
+ IAsyncEnumerator enumerator;
+ try
+ {
+ enumerator = Run(context, () => source.GetAsyncEnumerator(cancellationToken));
+ }
+ catch (Exception exception)
+ {
+ await Run(context, () => scope.FailAsync(exception));
+ throw;
+ }
+
+ Exception? sourceException = null;
+
+ try
+ {
+ while (true)
+ {
+ bool hasNext;
+ T current = default!;
+ try
+ {
+ hasNext = await Run(context, () => MoveNextAsync(enumerator));
+ if (hasNext)
+ {
+ current = Run(context, () => enumerator.Current);
+ }
+ }
+ catch (Exception exception)
+ {
+ sourceException = exception;
+ throw;
+ }
+
+ if (!hasNext)
+ {
+ break;
+ }
+
+ yield return current;
+ }
+ }
+ finally
+ {
+ // The source is disposed first, so the scope covers its cleanup.
+ try
+ {
+ await Run(context, () => DisposeAsync(enumerator));
+ }
+ catch (Exception exception)
+ {
+ // It replaces the exception of the source, if any, as the one thrown to the caller.
+ sourceException = exception;
+ throw;
+ }
+ finally
+ {
+ if (sourceException != null)
+ {
+ await Run(context, () => scope.FailAsync(sourceException));
+ }
+ else
+ {
+ // Also when the caller stops early, like a method that has returned.
+ await Run(context, () => scope.CompleteAsync(cancellationToken));
+ }
+ }
+ }
+ }
+ finally
+ {
+ Run(context, () =>
+ {
+ scope.Dispose();
+ return true;
+ });
+ }
+ }
+
+ private static ExecutionContext CaptureExecutionContext()
+ {
+ // Capture returns null while the flow is suppressed. Restoring it does not affect the caller,
+ // whose execution context is restored when this step of the async iterator returns.
+ if (ExecutionContext.IsFlowSuppressed())
+ {
+ ExecutionContext.RestoreFlow();
+ }
+
+ return ExecutionContext.Capture()!;
+ }
+
+ // The value task of the source (e.g. an IValueTaskSource) can also run its code when completed and when its result is read.
+ private static async ValueTask MoveNextAsync(IAsyncEnumerator enumerator)
+ {
+ return await enumerator.MoveNextAsync();
+ }
+
+ private static async ValueTask DisposeAsync(IAsyncEnumerator enumerator)
+ {
+ await enumerator.DisposeAsync();
+ }
+
+ private static TResult Run(ExecutionContext context, Func func)
+ {
+ TResult result = default!;
+ ExecutionContext.Run(context.CreateCopy(), _ => result = func(), null);
+ return result;
+ }
+}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpMethodInvocationScopeExtensions.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpMethodInvocationScopeExtensions.cs
new file mode 100644
index 0000000000..b9ceb10b66
--- /dev/null
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpMethodInvocationScopeExtensions.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Threading.Tasks;
+
+namespace Volo.Abp.DynamicProxy;
+
+public static class AbpMethodInvocationScopeExtensions
+{
+ ///
+ /// Also runs each enumeration of a returned in a new scope.
+ /// must set its async local values (e.g. the ambient unit of work) synchronously.
+ ///
+ public static async Task ProceedInScopeAsync(this IAbpMethodInvocation invocation, Func beginScope)
+ {
+ using (var scope = beginScope())
+ {
+ try
+ {
+ await invocation.ProceedAsync();
+ }
+ catch (Exception exception)
+ {
+ await scope.FailAsync(exception);
+ throw;
+ }
+
+ await scope.CompleteAsync(default);
+ }
+
+ invocation.WrapAsyncEnumerable(beginScope);
+ }
+}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpScopeInterceptor.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpScopeInterceptor.cs
new file mode 100644
index 0000000000..86c423a78d
--- /dev/null
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/AbpScopeInterceptor.cs
@@ -0,0 +1,23 @@
+using System.Threading.Tasks;
+
+namespace Volo.Abp.DynamicProxy;
+
+public abstract class AbpScopeInterceptor : AbpInterceptor
+{
+ public override Task InterceptAsync(IAbpMethodInvocation invocation)
+ {
+ return ShouldIntercept(invocation)
+ ? invocation.ProceedInScopeAsync(() => BeginScope(invocation))
+ : invocation.ProceedAsync();
+ }
+
+ protected virtual bool ShouldIntercept(IAbpMethodInvocation invocation)
+ {
+ return true;
+ }
+
+ ///
+ /// Must set its async local values synchronously.
+ ///
+ protected abstract IAbpInterceptionScope BeginScope(IAbpMethodInvocation invocation);
+}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/IAbpInterceptedAsyncEnumerable.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/IAbpInterceptedAsyncEnumerable.cs
new file mode 100644
index 0000000000..a9f5a931f0
--- /dev/null
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/IAbpInterceptedAsyncEnumerable.cs
@@ -0,0 +1,8 @@
+using System.Threading.Tasks;
+
+namespace Volo.Abp.DynamicProxy;
+
+public interface IAbpInterceptedAsyncEnumerable
+{
+ Task WaitForInterceptorsAsync();
+}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/IAbpInterceptionScope.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/IAbpInterceptionScope.cs
new file mode 100644
index 0000000000..cc2695c018
--- /dev/null
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/IAbpInterceptionScope.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Volo.Abp.DynamicProxy;
+
+public interface IAbpInterceptionScope : IDisposable
+{
+ ///
+ /// Also called when the caller stops enumerating early.
+ ///
+ Task CompleteAsync(CancellationToken cancellationToken);
+
+ Task FailAsync(Exception exception);
+}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs
index eec4da40e1..3ae97879ec 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs
@@ -156,6 +156,11 @@ public static class TypeHelper
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
}
+ public static bool IsAsyncEnumerable(Type type)
+ {
+ return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>);
+ }
+
public static bool IsNullableEnum(Type type)
{
return type.IsGenericType &&
diff --git a/framework/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/Interception/Autofac_AsyncEnumerable_Interception_Test.cs b/framework/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/Interception/Autofac_AsyncEnumerable_Interception_Test.cs
new file mode 100644
index 0000000000..5654f52f31
--- /dev/null
+++ b/framework/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/Interception/Autofac_AsyncEnumerable_Interception_Test.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Threading.Tasks;
+using Volo.Abp.DynamicProxy;
+
+namespace Volo.Abp.Autofac.Interception;
+
+public class Autofac_AsyncEnumerable_Interception_Test : AbpAsyncEnumerableInterceptionTestBase
+{
+ protected override Task> SetAbpApplicationCreationOptionsAsync()
+ {
+ return Task.FromResult>(options => options.UseAutofac());
+ }
+}
diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/DynamicProxy/AbpAsyncEnumerableInterceptionTestBase.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/DynamicProxy/AbpAsyncEnumerableInterceptionTestBase.cs
new file mode 100644
index 0000000000..eba4228bb0
--- /dev/null
+++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/DynamicProxy/AbpAsyncEnumerableInterceptionTestBase.cs
@@ -0,0 +1,660 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
+using Shouldly;
+using Volo.Abp.Modularity;
+using Volo.Abp.Testing;
+using Xunit;
+
+namespace Volo.Abp.DynamicProxy;
+
+public abstract class AbpAsyncEnumerableInterceptionTestBase : AbpAsyncIntegratedTest, IAsyncLifetime
+ where TStartupModule : IAbpModule
+{
+ protected override Task BeforeAddApplicationAsync(IServiceCollection services)
+ {
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddSingleton();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddSingleton();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+
+ services.OnRegistered(registration =>
+ {
+ if (typeof(AsyncEnumerableInterceptionTargetClass) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ registration.Interceptors.Add();
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableScopeInterceptorTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableScopedTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableValueTaskSourceTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableConcurrentTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableGatedTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableGatedScopedTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableWrongReturnValueTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableNullReturnValueTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableThrowingInterceptorTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(AsyncEnumerableDecoratedTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ }
+
+ if (typeof(CachedTestObject) == registration.ImplementationType)
+ {
+ registration.Interceptors.Add();
+ }
+ });
+
+ return Task.CompletedTask;
+ }
+
+ [Fact]
+ public async Task Should_Intercept_The_Call_And_Enumerate_Lazily()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ var items = await ToListAsync(target.GetItemsAsync(2));
+
+ items.ShouldBe(new[] { 1, 2 });
+ target.Logs.ShouldBe(new[]
+ {
+ "SimpleAsyncInterceptor_InterceptAsync_BeforeInvocation",
+ "SimpleAsyncInterceptor2_InterceptAsync_BeforeInvocation",
+ "SimpleAsyncInterceptor2_InterceptAsync_AfterInvocation",
+ "SimpleAsyncInterceptor_InterceptAsync_AfterInvocation",
+ "Produce1",
+ "Produce2"
+ });
+ }
+
+ [Fact]
+ public async Task Should_Not_Block_The_Call_While_Interceptor_Is_Awaiting()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var interceptor = ServiceProvider.GetRequiredService();
+
+ try
+ {
+ // Called on another thread, so a call blocking on the interceptor fails the test instead of hanging it.
+ var sequence = await Task.Run(() => target.GetItemsAsync()).WaitAsync(TimeSpan.FromSeconds(10));
+ var enumeration = ToListAsync(sequence);
+ enumeration.IsCompleted.ShouldBeFalse();
+
+ interceptor.Gate.SetResult(true);
+ (await enumeration.WaitAsync(TimeSpan.FromSeconds(10))).ShouldBe(new[] { 1 });
+ }
+ finally
+ {
+ interceptor.Gate.TrySetResult(true);
+ }
+ }
+
+ [Fact]
+ public async Task Should_Throw_Synchronous_Interceptor_Exception_When_Enumerating()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ var sequence = target.GetItemsAsync();
+
+ await Should.ThrowAsync(ToListAsync(sequence));
+ target.Invoked.ShouldBeFalse();
+ }
+
+ [Fact]
+ public async Task Should_Throw_If_Interceptor_Sets_Wrong_Return_Value_Type()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ await Should.ThrowAsync(ToListAsync(target.GetItemsAsync()));
+ }
+
+ [Fact]
+ public async Task Should_Enumerate_Return_Value_Replaced_By_Interceptor()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ (await ToListAsync(target.GetItemsAsync())).ShouldBe(new[] { 10, 20 });
+ }
+
+ [Fact]
+ public async Task Should_Enumerate_Return_Value_Of_Short_Circuiting_Interceptor()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ var first = await ToListAsync(target.GetValuesAsync(42));
+
+ // The test cache interceptor caches by method, so a different argument only returns 42 if it short-circuits.
+ var second = await ToListAsync(target.GetValuesAsync(1));
+
+ first.ShouldBe(new[] { 42, 43 });
+ second.ShouldBe(new[] { 42, 43 });
+ }
+
+ [Fact]
+ public async Task Should_Allow_Interceptor_To_Proceed_Again()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ (await ToListAsync(target.GetItemsCreatedOnSecondAttempt())).ShouldBe(new[] { 1 });
+ }
+
+ [Fact]
+ public async Task Should_Propagate_Exception_Thrown_After_Items_Were_Delivered()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var items = new List();
+
+ var exception = await Should.ThrowAsync(async () =>
+ {
+ await foreach (var item in target.GetOneThenThrowAsync())
+ {
+ items.Add(item);
+ }
+ });
+
+ exception.Message.ShouldBe("Failed after first item");
+ items.ShouldBe(new[] { 1 });
+ }
+
+ [Fact]
+ public async Task Should_Pass_Cancellation_To_The_Source()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var items = new List();
+ using var cancellationTokenSource = new CancellationTokenSource();
+
+ await Should.ThrowAsync(async () =>
+ {
+ await foreach (var item in target.GetOneThenWaitAsync().WithCancellation(cancellationTokenSource.Token))
+ {
+ items.Add(item);
+ cancellationTokenSource.CancelAfter(50);
+ }
+ }).WaitAsync(TimeSpan.FromSeconds(10));
+
+ items.ShouldBe(new[] { 1 });
+ }
+
+ [Fact]
+ public async Task Should_Set_Out_Parameters_When_Called()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ var sequence = target.GetItemsWithOutParameter(out var value);
+
+ value.ShouldBe(42);
+ (await ToListAsync(sequence)).ShouldBe(new[] { 1 });
+ }
+
+ [Fact]
+ public async Task Should_Support_Concurrent_Enumerations_Of_The_Same_Sequence()
+ {
+ // A source without shared mutable state, so the test only checks the interception wrapper.
+ var target = ServiceProvider.GetRequiredService();
+ var sequence = target.GetItemsAsync(3);
+
+ var results = await Task.WhenAll(
+ Task.Run(() => ToListAsync(sequence)),
+ Task.Run(() => ToListAsync(sequence)));
+
+ results[0].ShouldBe(new[] { 1, 2, 3 });
+ results[1].ShouldBe(new[] { 1, 2, 3 });
+ }
+
+ [Fact]
+ public async Task Should_Keep_The_Scope_Of_The_Interceptor_For_Every_Step_Of_The_Enumeration()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ var values = new List();
+ await foreach (var value in target.GetScopeValuesAsync(fail: false))
+ {
+ // The caller is not affected by the scope.
+ ScopeTestInterceptor.ScopeValue.Value.ShouldBeNull();
+ values.Add(value);
+ }
+
+ values.ShouldBe(new[] { "in-scope", "in-scope" });
+ target.Logs.ShouldBe(new[] { "Completed:in-scope", "Disposed" });
+ }
+
+ [Fact]
+ public async Task Should_Keep_The_Scope_When_The_Enumeration_Is_Started_With_A_Suppressed_Flow()
+ {
+ // No asynchronous interceptor, so the scope begins synchronously while the flow is suppressed.
+ var target = ServiceProvider.GetRequiredService();
+ var enumerator = target.GetScopeValuesAsync(fail: false).GetAsyncEnumerator();
+
+ ValueTask moveNext;
+ using (ExecutionContext.SuppressFlow())
+ {
+ moveNext = enumerator.MoveNextAsync();
+
+ ExecutionContext.IsFlowSuppressed().ShouldBeTrue();
+ ScopeTestInterceptor.ScopeValue.Value.ShouldBeNull();
+ }
+
+ var values = new List();
+ while (await moveNext)
+ {
+ values.Add(enumerator.Current);
+ moveNext = enumerator.MoveNextAsync();
+ }
+
+ await enumerator.DisposeAsync();
+
+ ExecutionContext.IsFlowSuppressed().ShouldBeFalse();
+ ScopeTestInterceptor.ScopeValue.Value.ShouldBeNull();
+ values.ShouldBe(new[] { "in-scope", "in-scope" });
+ target.Logs.ShouldBe(new[] { "Completed:in-scope", "Disposed" });
+ }
+
+ [Fact]
+ public async Task Should_Keep_The_Context_Of_The_Caller_When_The_Enumeration_Is_Started_With_A_Suppressed_Flow_Before_The_Interceptors_Complete()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var interceptor = ServiceProvider.GetRequiredService();
+ var enumerator = target.GetCallerValueAsync().GetAsyncEnumerator();
+
+ AsyncEnumerableCallerContext.Value.Value = "enumeration";
+ ValueTask moveNext;
+ using (ExecutionContext.SuppressFlow())
+ {
+ moveNext = enumerator.MoveNextAsync();
+
+ ExecutionContext.IsFlowSuppressed().ShouldBeTrue();
+ }
+
+ AsyncEnumerableCallerContext.Value.Value = null;
+ interceptor.Gate.SetResult(true);
+
+ (await moveNext).ShouldBeTrue();
+ enumerator.Current.ShouldBe("enumeration");
+ await enumerator.DisposeAsync();
+ }
+
+ [Fact]
+ public async Task Should_Keep_The_Context_Of_The_Caller_And_The_Scope_When_The_Enumeration_Is_Started_With_A_Suppressed_Flow_Before_The_Interceptors_Complete()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var interceptor = ServiceProvider.GetRequiredService();
+ var enumerator = target.GetCallerAndScopeValuesAsync().GetAsyncEnumerator();
+
+ AsyncEnumerableCallerContext.Value.Value = "enumeration";
+ ValueTask moveNext;
+ using (ExecutionContext.SuppressFlow())
+ {
+ moveNext = enumerator.MoveNextAsync();
+
+ ExecutionContext.IsFlowSuppressed().ShouldBeTrue();
+ }
+
+ AsyncEnumerableCallerContext.Value.Value = "changed";
+ interceptor.Gate.SetResult(true);
+
+ var values = new List();
+ while (await moveNext)
+ {
+ values.Add(enumerator.Current);
+ moveNext = enumerator.MoveNextAsync();
+ }
+
+ await enumerator.DisposeAsync();
+
+ values.ShouldBe(new[] { "enumeration:in-scope", "enumeration:in-scope" });
+ target.Logs.ShouldBe(new[] { "Completed:in-scope", "Disposed" });
+ AsyncEnumerableCallerContext.Value.Value.ShouldBe("changed");
+ ScopeTestInterceptor.ScopeValue.Value.ShouldBeNull();
+ }
+
+ [Fact]
+ public async Task Should_Keep_The_Context_Of_The_First_Step_For_Every_Step_Of_The_Enumeration()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var enumerator = target.GetCallerValuesAsync().GetAsyncEnumerator();
+
+ AsyncEnumerableCallerContext.Value.Value = "first";
+ (await enumerator.MoveNextAsync()).ShouldBeTrue();
+ enumerator.Current.ShouldBe("first");
+
+ AsyncEnumerableCallerContext.Value.Value = "second";
+ (await enumerator.MoveNextAsync()).ShouldBeTrue();
+ enumerator.Current.ShouldBe("first");
+
+ await enumerator.DisposeAsync();
+ AsyncEnumerableCallerContext.Value.Value.ShouldBe("second");
+ }
+
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public async Task Should_Keep_The_Scope_When_The_Value_Tasks_Of_The_Source_Complete(bool completeAsynchronously)
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ var items = new List();
+ await foreach (var item in target.GetItemsAsync(completeAsynchronously))
+ {
+ ScopeTestInterceptor.ScopeValue.Value.ShouldBeNull();
+ items.Add(item);
+ }
+
+ items.ShouldBe(new[] { 1, 2 });
+ target.Logs.ShouldBe(new[]
+ {
+ "MoveNext:in-scope", "MoveNext:in-scope", "MoveNext:in-scope", "Dispose:in-scope", "Completed:in-scope", "Disposed"
+ });
+ }
+
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public async Task Should_Keep_The_Scope_When_The_Value_Task_Of_Disposing_The_Source_Completes(bool completeAsynchronously)
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ await foreach (var _ in target.GetItemsAsync(completeAsynchronously))
+ {
+ break;
+ }
+
+ ScopeTestInterceptor.ScopeValue.Value.ShouldBeNull();
+ target.Logs.ShouldBe(new[] { "MoveNext:in-scope", "Dispose:in-scope", "Completed:in-scope", "Disposed" });
+ }
+
+ [Fact]
+ public async Task Should_Keep_The_Scope_When_The_Value_Tasks_Of_The_Source_Are_Completed_Without_The_Execution_Context()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ var items = new List();
+ await foreach (var item in target.GetItemsCompletedWithoutExecutionContextAsync())
+ {
+ ScopeTestInterceptor.ScopeValue.Value.ShouldBeNull();
+ items.Add(item);
+ }
+
+ items.ShouldBe(new[] { 1, 2 });
+ target.Logs.ShouldBe(new[]
+ {
+ "OnCompleted:in-scope", "SetResult:", "MoveNext:in-scope",
+ "OnCompleted:in-scope", "SetResult:", "MoveNext:in-scope",
+ "OnCompleted:in-scope", "SetResult:", "MoveNext:in-scope",
+ "OnCompleted:in-scope", "SetResult:", "Dispose:in-scope",
+ "Completed:in-scope", "Disposed"
+ });
+ }
+
+ [Fact]
+ public async Task Should_Fail_And_Dispose_The_Scope_When_The_Sequence_Throws()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ await Should.ThrowAsync(ToListAsync(target.GetScopeValuesAsync(fail: true)));
+
+ target.Logs.ShouldBe(new[] { "Failed:Failed in scope", "Disposed" });
+ }
+
+ [Fact]
+ public async Task Should_Complete_And_Dispose_The_Scope_When_The_Caller_Stops_Early()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ await foreach (var _ in target.GetScopeValuesAsync(fail: true))
+ {
+ break;
+ }
+
+ target.Logs.ShouldBe(new[] { "Completed:in-scope", "Disposed" });
+ }
+
+ [Fact]
+ public async Task Should_Enumerate_A_Null_Return_Value_As_An_Empty_Sequence()
+ {
+ var target = ServiceProvider.GetRequiredService();
+
+ (await ToListAsync(target.GetItemsAsync())).ShouldBeEmpty();
+ }
+
+ [Fact]
+ public async Task Should_Not_Run_A_Scope_For_A_Method_The_Scope_Interceptor_Does_Not_Intercept()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ (await ToListAsync(target.GetItemsWithoutScopeAsync())).ShouldBe(new[] { 1 });
+
+ log.Events.ShouldBeEmpty();
+ }
+
+ [Fact]
+ public async Task Should_Run_One_Scope_Around_A_Task_Method()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ (await target.GetValueAsync()).ShouldBe(42);
+
+ log.Events.ShouldBe(new[] { "Scope1.Begin", "Scope1.Complete", "Scope1.Dispose" });
+ }
+
+ [Fact]
+ public async Task Should_Run_A_Scope_Around_The_Call_And_A_New_One_Around_Each_Enumeration()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ var sequence = target.GetItemsAsync();
+ (await ToListAsync(sequence)).ShouldBe(new[] { 1 });
+ (await ToListAsync(sequence)).ShouldBe(new[] { 1 });
+
+ log.TargetInvocations.ShouldBe(1);
+ log.Events.ShouldBe(new[]
+ {
+ "Scope1.Begin", "Scope1.Complete", "Scope1.Dispose",
+ "Scope2.Begin", "Scope2.Complete", "Scope2.Dispose",
+ "Scope3.Begin", "Scope3.Complete", "Scope3.Dispose"
+ });
+ }
+
+ [Fact]
+ public async Task Should_Not_Begin_An_Enumeration_Scope_Until_The_Sequence_Is_Enumerated()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ var sequence = target.GetItemsAsync();
+ await using (sequence.GetAsyncEnumerator())
+ {
+ }
+
+ // Only the scope of the call: getting and disposing the enumerator does not start an enumeration.
+ log.Events.ShouldBe(new[] { "Scope1.Begin", "Scope1.Complete", "Scope1.Dispose" });
+ }
+
+ [Fact]
+ public async Task Should_Fail_The_Scope_Of_The_Call_And_Not_Wrap_The_Sequence()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ await Should.ThrowAsync(ToListAsync(target.GetItemsAsync(throwOnCall: true)));
+
+ log.Events.ShouldBe(new[] { "Scope1.Begin", "Scope1.Fail:Failed on call", "Scope1.Dispose" });
+ }
+
+ [Fact]
+ public async Task Should_Fail_The_Enumeration_Scope_When_The_Source_Throws_On_GetAsyncEnumerator()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ await Should.ThrowAsync(ToListAsync(target.GetItemsThrowingOnGetAsyncEnumerator()));
+
+ log.Events.ShouldBe(new[]
+ {
+ "Scope1.Begin", "Scope1.Complete", "Scope1.Dispose",
+ "Scope2.Begin", "Scope2.Fail:Failed on GetAsyncEnumerator", "Scope2.Dispose"
+ });
+ }
+
+ [Fact]
+ public async Task Should_Fail_The_Enumeration_Scope_After_The_Failed_Source_Has_Been_Disposed()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ await Should.ThrowAsync(ToListAsync(target.GetItemsThrowingOnCurrent()));
+
+ log.Events.ShouldBe(new[]
+ {
+ "Scope1.Begin", "Scope1.Complete", "Scope1.Dispose",
+ "Scope2.Begin", "Source.Dispose", "Scope2.Fail:Failed on Current", "Scope2.Dispose"
+ });
+ }
+
+ [Fact]
+ public async Task Should_Fail_The_Enumeration_Scope_With_The_Exception_Thrown_When_Disposing_The_Failed_Source_Throws()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ var exception = await Should.ThrowAsync(ToListAsync(target.GetItemsThrowingOnCurrent(throwOnDispose: true)));
+
+ exception.Message.ShouldBe("Failed on dispose");
+ log.Events.ShouldBe(new[]
+ {
+ "Scope1.Begin", "Scope1.Complete", "Scope1.Dispose",
+ "Scope2.Begin", "Source.Dispose", "Scope2.Fail:Failed on dispose", "Scope2.Dispose"
+ });
+ }
+
+ [Fact]
+ public async Task Should_Dispose_But_Not_Fail_The_Enumeration_Scope_When_Completing_It_Throws()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ var exception = await Should.ThrowAsync(ToListAsync(target.GetItemsWithFailingCompleteAsync()));
+
+ exception.Message.ShouldBe("Complete failed");
+ log.Events.ShouldBe(new[]
+ {
+ "Scope1.Begin", "Scope1.Complete", "Scope1.Dispose",
+ "Scope2.Begin", "Scope2.Complete", "Scope2.Dispose"
+ });
+ }
+
+ [Fact]
+ public async Task Should_Dispose_The_Enumeration_Scope_When_Failing_It_Throws()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ var exception = await Should.ThrowAsync(ToListAsync(target.GetItemsWithFailingFailAsync()));
+
+ exception.Message.ShouldBe("Fail failed");
+ log.Events.ShouldBe(new[]
+ {
+ "Scope1.Begin", "Scope1.Complete", "Scope1.Dispose",
+ "Scope2.Begin", "Scope2.Fail:Source failed", "Scope2.Dispose"
+ });
+ }
+
+ [Fact]
+ public async Task Should_Fail_The_Enumeration_Scope_When_The_Source_Throws_On_Dispose()
+ {
+ var target = ServiceProvider.GetRequiredService();
+ var log = ServiceProvider.GetRequiredService();
+
+ // Stopping early runs the finally block of the source in DisposeAsync, not in MoveNextAsync.
+ await Should.ThrowAsync(async () =>
+ {
+ await foreach (var _ in target.GetItemsAsync(throwOnDispose: true))
+ {
+ break;
+ }
+ });
+
+ log.Events.ShouldBe(new[]
+ {
+ "Scope1.Begin", "Scope1.Complete", "Scope1.Dispose",
+ "Scope2.Begin", "Scope2.Fail:Failed on dispose", "Scope2.Dispose"
+ });
+ }
+
+ private static async Task> ToListAsync(IAsyncEnumerable source)
+ {
+ var list = new List();
+ await foreach (var item in source)
+ {
+ list.Add(item);
+ }
+
+ return list;
+ }
+}
diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/DynamicProxy/AbpInterceptionScope_Tests.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/DynamicProxy/AbpInterceptionScope_Tests.cs
new file mode 100644
index 0000000000..c8eab5fc6d
--- /dev/null
+++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/DynamicProxy/AbpInterceptionScope_Tests.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Shouldly;
+using Xunit;
+
+namespace Volo.Abp.DynamicProxy;
+
+public class AbpInterceptionScope_Tests
+{
+ [Fact]
+ public async Task Should_Dispose_The_Given_Object_When_Disposed()
+ {
+ var disposable = new TestDisposable();
+ var scope = new AbpInterceptionScope(disposable);
+
+ await scope.CompleteAsync(CancellationToken.None);
+ await scope.FailAsync(new InvalidOperationException());
+ disposable.IsDisposed.ShouldBeFalse();
+
+ scope.Dispose();
+ disposable.IsDisposed.ShouldBeTrue();
+ }
+
+ [Fact]
+ public async Task Should_Work_Without_A_Disposable()
+ {
+ var scope = new AbpInterceptionScope();
+
+ await scope.CompleteAsync(CancellationToken.None);
+ await scope.FailAsync(new InvalidOperationException());
+ scope.Dispose();
+ }
+
+ private class TestDisposable : IDisposable
+ {
+ public bool IsDisposed { get; private set; }
+
+ public void Dispose()
+ {
+ IsDisposed = true;
+ }
+ }
+}
diff --git a/framework/test/Volo.Abp.Core.Tests/Volo/Abp/DynamicProxy/AbpMethodInvocationAsyncEnumerableExtensions_Tests.cs b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/DynamicProxy/AbpMethodInvocationAsyncEnumerableExtensions_Tests.cs
new file mode 100644
index 0000000000..6007bda92e
--- /dev/null
+++ b/framework/test/Volo.Abp.Core.Tests/Volo/Abp/DynamicProxy/AbpMethodInvocationAsyncEnumerableExtensions_Tests.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Threading;
+using System.Threading.Tasks;
+using Shouldly;
+using Xunit;
+
+namespace Volo.Abp.DynamicProxy;
+
+public class AbpMethodInvocationAsyncEnumerableExtensions_Tests
+{
+ private static readonly AsyncLocal ScopeValue = new();
+
+ [Fact]
+ public async Task Should_Keep_The_Scope_When_The_Enumeration_Is_Started_With_A_Suppressed_Flow()
+ {
+ var invocation = new TestMethodInvocation(typeof(AbpMethodInvocationAsyncEnumerableExtensions_Tests).GetMethod(nameof(GetScopeValuesAsync))!)
+ {
+ ReturnValue = GetScopeValuesAsync()
+ };
+
+ invocation.WrapAsyncEnumerable(() =>
+ {
+ ScopeValue.Value = "in-scope";
+ return new AbpInterceptionScope();
+ }).ShouldBeTrue();
+
+ var enumerator = ((IAsyncEnumerable)invocation.ReturnValue).GetAsyncEnumerator();
+ ValueTask moveNext;
+ using (ExecutionContext.SuppressFlow())
+ {
+ moveNext = enumerator.MoveNextAsync();
+
+ ExecutionContext.IsFlowSuppressed().ShouldBeTrue();
+ ScopeValue.Value.ShouldBeNull();
+ }
+
+ var values = new List();
+ while (await moveNext)
+ {
+ values.Add(enumerator.Current);
+ moveNext = enumerator.MoveNextAsync();
+ }
+
+ await enumerator.DisposeAsync();
+
+ values.ShouldBe(new[] { "in-scope", "in-scope" });
+ ScopeValue.Value.ShouldBeNull();
+ }
+
+ public static async IAsyncEnumerable GetScopeValuesAsync()
+ {
+ await Task.Delay(1);
+ yield return ScopeValue.Value;
+ await Task.Delay(1);
+ yield return ScopeValue.Value;
+ }
+
+ private class TestMethodInvocation : IAbpMethodInvocation
+ {
+ public TestMethodInvocation(MethodInfo method)
+ {
+ Method = method;
+ }
+
+ public object?[] Arguments => Array.Empty