Use Il2CppObjectBase instead of Il2CppSystem.Object where possible.

Attempt to fix il2cpp lists/dicts, not currently working properly. Will probably wait for Unhollower rewrite.
This commit is contained in:
Sinai
2021-05-15 18:00:16 +10:00
parent bf8f838f01
commit 83f15c7168
5 changed files with 228 additions and 16 deletions
File diff suppressed because it is too large Load Diff
+27
View File
@@ -206,6 +206,7 @@ namespace UnityExplorer
#endregion
#region Type and Generic Parameter implementation cache
// cache for GetImplementationsOf
@@ -340,6 +341,7 @@ namespace UnityExplorer
#endregion
#region Internal MemberInfo Cache
internal static Dictionary<Type, Dictionary<string, FieldInfo>> fieldInfos = new Dictionary<Type, Dictionary<string, FieldInfo>>();
@@ -411,6 +413,7 @@ namespace UnityExplorer
#endregion
#region Reflection Blacklist
public virtual string DefaultReflectionBlacklist => string.Empty;
@@ -454,5 +457,29 @@ namespace UnityExplorer
#endregion
// This is NOT working properly. Fails on IL2CPP IList, probably more stuff too.
//// Temp fix for IL2CPP until interface support improves
//
//public static bool IsEnumerable(Type type)
//{
// return Instance.Internal_IsEnumerable(type);
//}
//
//public virtual bool Internal_IsEnumerable(Type type)
//{
// return typeof(IEnumerable).IsAssignableFrom(type);
//}
//
//public static bool IsDictionary(Type type)
//{
// return Instance.Internal_IsDictionary(type);
//}
//
//public virtual bool Internal_IsDictionary(Type type)
//{
// return typeof(IDictionary).IsAssignableFrom(type);
//}
}
}
+2 -2
View File
@@ -183,9 +183,9 @@ namespace UnityExplorer.UI.CacheObject
return ValueState.Color;
else if (InteractiveValueStruct.SupportsType(type))
return ValueState.ValueStruct;
else if (typeof(IDictionary).IsAssignableFrom(type))
else if (typeof(IDictionary).IsAssignableFrom(type)) //(ReflectionUtility.IsDictionary(type))
return ValueState.Dictionary;
else if (!typeof(Transform).IsAssignableFrom(type) && typeof(IEnumerable).IsAssignableFrom(type))
else if (!typeof(Transform).IsAssignableFrom(type) && typeof(IEnumerable).IsAssignableFrom(type)) //ReflectionUtility.IsEnumerable(type))
return ValueState.Collection;
else
return ValueState.Unsupported;
+1
View File
@@ -53,6 +53,7 @@ namespace UnityExplorer.UI.IValues
private void ClearAndRelease()
{
RefIDictionary = null;
keys.Clear();
values.Clear();
+11 -9
View File
@@ -22,7 +22,7 @@ namespace UnityExplorer.UI.IValues
public override bool CanWrite => base.CanWrite && RefIList != null && !RefIList.IsReadOnly;
public Type EntryType;
public IEnumerable RefIEnumerable;
//public IEnumerable RefIEnumerable;
public IList RefIList;
public int ItemCount => values.Count;
@@ -49,6 +49,8 @@ namespace UnityExplorer.UI.IValues
private void ClearAndRelease()
{
//RefIEnumerable = null;
RefIList = null;
values.Clear();
foreach (var entry in cachedEntries)
@@ -90,20 +92,20 @@ namespace UnityExplorer.UI.IValues
private void CacheEntries(object value)
{
RefIEnumerable = value as IEnumerable;
RefIList = value as IList;
if (RefIEnumerable == null)
{
// todo il2cpp
return;
}
IEnumerator enumerator = (value as IEnumerable).GetEnumerator();
//if (value is IEnumerable enumerable)
// enumerator = enumerable.GetEnumerator();
//else
// enumerator = Il2CppReflection.EnumerateCppList(value);
values.Clear();
int idx = 0;
foreach (var entry in RefIEnumerable)
while (enumerator.MoveNext())
{
// var entry = item.TryCast();
var entry = enumerator.Current;
values.Add(entry);