Browse Source
Avoid double reflection call by passing effectiveMethod into ValidateActionArgumentsAsync
pull/25105/head
maliming
7 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
3 additions and
4 deletions
-
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/AbpValidationActionFilter.cs
|
|
|
@ -54,7 +54,7 @@ public class AbpValidationActionFilter : IAsyncActionFilter, IAbpFilter, ITransi |
|
|
|
|
|
|
|
if (context.Controller is IValidationEnabled) |
|
|
|
{ |
|
|
|
await ValidateActionArgumentsAsync(context); |
|
|
|
await ValidateActionArgumentsAsync(context, effectiveMethod); |
|
|
|
} |
|
|
|
|
|
|
|
await next(); |
|
|
|
@ -75,10 +75,9 @@ public class AbpValidationActionFilter : IAsyncActionFilter, IAbpFilter, ITransi |
|
|
|
x.GetParameters().Select(p => p.ToString()).SequenceEqual(baseMethod.GetParameters().Select(p => p.ToString()))); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task ValidateActionArgumentsAsync(ActionExecutingContext context) |
|
|
|
protected virtual async Task ValidateActionArgumentsAsync(ActionExecutingContext context, MethodInfo? effectiveMethod = null) |
|
|
|
{ |
|
|
|
var baseMethod = context.ActionDescriptor.GetMethodInfo(); |
|
|
|
var methodInfo = GetEffectiveMethodInfo(context) ?? baseMethod; |
|
|
|
var methodInfo = effectiveMethod ?? context.ActionDescriptor.GetMethodInfo(); |
|
|
|
|
|
|
|
var parameterValues = methodInfo.GetParameters() |
|
|
|
.Select(p => context.ActionArguments.TryGetValue(p.Name!, out var value) ? value : null) |
|
|
|
|