From 976d309119da17b6c44c08905fcdb22b22a83c52 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 18 Aug 2025 09:31:27 +0800 Subject: [PATCH] Support DateOnly and TimeOnly in type checks Added DateOnly and TimeOnly to TypeHelper.IsPrimitiveExtended for .NET Core. Also updated MethodInvocationValidator to allow nulls for nullable parameter types, improving validation logic for modern .NET types. --- framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs | 4 ++++ .../Volo/Abp/Validation/MethodInvocationValidator.cs | 1 + 2 files changed, 5 insertions(+) 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 06d2ee885b..8a67d20b31 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs @@ -176,6 +176,10 @@ public static class TypeHelper type == typeof(decimal) || type == typeof(DateTime) || type == typeof(DateTimeOffset) || +#if NETCOREAPP + type == typeof(DateOnly) || + type == typeof(TimeOnly) || +#endif type == typeof(TimeSpan) || type == typeof(Guid); } diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/MethodInvocationValidator.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/MethodInvocationValidator.cs index 1651d9e0dc..f0a34c96c6 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/MethodInvocationValidator.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/MethodInvocationValidator.cs @@ -95,6 +95,7 @@ public class MethodInvocationValidator : IMethodInvocationValidator, ITransientD { var allowNulls = parameterInfo.IsOptional || parameterInfo.IsOut || + TypeHelper.IsNullable(parameterInfo.ParameterType) || TypeHelper.IsPrimitiveExtended(parameterInfo.ParameterType, includeEnums: true); context.Errors.AddRange(