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; }