From c999635ff356130183616239b2dc3049a12fe0b6 Mon Sep 17 00:00:00 2001 From: johnche Date: Mon, 4 Nov 2024 20:19:29 +0800 Subject: [PATCH] =?UTF-8?q?[unity]=E8=8E=B7=E5=8F=96=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=87=BD=E6=95=B0=E6=89=80=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E6=97=B6=EF=BC=8C=E4=B8=8D=E7=AC=A6=E5=90=88?= =?UTF-8?q?=E6=A0=87=E5=87=86=E7=9A=84=E8=BF=94=E5=9B=9Enull=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E6=8A=A5=E9=94=99=EF=BC=8Cfix=20https://github.com/Te?= =?UTF-8?q?ncent/puerts/issues/1893?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/upm/Runtime/Src/IL2Cpp/TypeUtils.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/unity/Assets/core/upm/Runtime/Src/IL2Cpp/TypeUtils.cs b/unity/Assets/core/upm/Runtime/Src/IL2Cpp/TypeUtils.cs index 4fd5a37a2e..a5f6ab589e 100644 --- a/unity/Assets/core/upm/Runtime/Src/IL2Cpp/TypeUtils.cs +++ b/unity/Assets/core/upm/Runtime/Src/IL2Cpp/TypeUtils.cs @@ -20,15 +20,28 @@ public static class ExtensionMethodInfo { private static Type GetExtendedType(MethodInfo method) { + var paramInfo = method.GetParameters(); + if (paramInfo.Length == 0) + { + return null; + } + if (method.GetCustomAttribute() == null) + { + return null; + } var type = method.GetParameters()[0].ParameterType; if (!type.IsGenericParameter) return type; var parameterConstraints = type.GetGenericParameterConstraints(); - if (parameterConstraints.Length == 0) - throw new InvalidOperationException(); + if (parameterConstraints.Length == 0) + { + return null; + } var firstParameterConstraint = parameterConstraints[0]; - if (!firstParameterConstraint.IsClass) - throw new InvalidOperationException(); + if (!firstParameterConstraint.IsClass) + { + return null; + } return firstParameterConstraint; }