diff --git a/src/CachedObjects/CacheObjectBase.cs b/src/CachedObjects/CacheObjectBase.cs index b39f72c..3847fd8 100644 --- a/src/CachedObjects/CacheObjectBase.cs +++ b/src/CachedObjects/CacheObjectBase.cs @@ -114,8 +114,9 @@ namespace Explorer var pi = memberInfo as PropertyInfo; var mi = memberInfo as MethodInfo; - // if PropertyInfo, check if can process args - if (pi != null && !CanProcessArgs(pi.GetIndexParameters())) + // Check if can process args + if ((pi != null && !CanProcessArgs(pi.GetIndexParameters())) + || (mi != null && !CanProcessArgs(mi.GetParameters()))) { return null; } @@ -127,14 +128,7 @@ namespace Explorer if (mi != null) { - if (CacheMethod.CanEvaluate(mi)) - { - holder = new CacheMethod(); - } - else - { - return null; - } + holder = new CacheMethod(); } else if (valueType == typeof(GameObject) || valueType == typeof(Transform)) { @@ -211,7 +205,18 @@ namespace Explorer { foreach (var param in parameters) { - if (!param.ParameterType.IsPrimitive && param.ParameterType != typeof(string)) + var pType = param.ParameterType; + + if (pType.IsByRef && pType.HasElementType) + { + pType = pType.GetElementType(); + } + + if (pType.IsPrimitive || pType == typeof(string)) + { + continue; + } + else { return false; } @@ -241,6 +246,11 @@ namespace Explorer var input = m_argumentInput[i]; var type = m_arguments[i].ParameterType; + if (type.IsByRef) + { + type = type.GetElementType(); + } + if (!string.IsNullOrEmpty(input)) { // strings can obviously just be used directly diff --git a/src/CachedObjects/Other/CacheMethod.cs b/src/CachedObjects/Other/CacheMethod.cs index 9a961eb..47feb99 100644 --- a/src/CachedObjects/Other/CacheMethod.cs +++ b/src/CachedObjects/Other/CacheMethod.cs @@ -18,12 +18,6 @@ namespace Explorer public string[] GenericArgInput = new string[0]; - public static bool CanEvaluate(MethodInfo mi) - { - // primitive and string args supported - return CanProcessArgs(mi.GetParameters()); - } - public override void Init() { var mi = (MemInfo as MethodInfo); diff --git a/src/Tests/TestClass.cs b/src/Tests/TestClass.cs index 21ff3e8..5bd80eb 100644 --- a/src/Tests/TestClass.cs +++ b/src/Tests/TestClass.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using System; using UnityEngine; namespace Explorer.Tests @@ -21,10 +22,16 @@ namespace Explorer.Tests public static int StaticField = 5; public int NonStaticField; - // test a generic method public static string TestGeneric(string arg0) where C : Component { - return "C: " + typeof(C).FullName + ", T: " + typeof(T).FullName + ", arg0: " + arg0; + return $"C: '{typeof(C).FullName}', T: '{typeof(T).FullName}', arg0: '{arg0}'"; + } + + public static string TestRefInOutGeneric(ref string arg0, in int arg1, out string arg2) + { + arg2 = "this is arg2"; + + return $"T: '{typeof(T).FullName}', ref arg0: '{arg0}', in arg1: '{arg1}', out arg2: '{arg2}'"; } //// this type of generic is not supported, due to requiring a non-primitive argument.