Implement auto-indenting for CSConsole, some cleanups

This commit is contained in:
Sinai
2021-05-12 20:48:56 +10:00
parent fedecb80a0
commit ada239c828
21 changed files with 681 additions and 3702 deletions

View File

@ -37,7 +37,23 @@ namespace UnityExplorer
/// <summary>Key: Type.FullName</summary>
public static readonly SortedDictionary<string, Type> AllTypes = new SortedDictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
private static readonly SortedSet<string> allTypeNames = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
//private static readonly SortedSet<string> allTypeNames = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
private static string[] allTypesArray;
private static string[] GetTypeNameArray()
{
if (allTypesArray == null || allTypesArray.Length != AllTypes.Count)
{
allTypesArray = new string[AllTypes.Count];
int i = 0;
foreach (var name in AllTypes.Keys)
{
allTypesArray[i] = name;
i++;
}
}
return allTypesArray;
}
private static void SetupTypeCache()
{
@ -64,7 +80,7 @@ namespace UnityExplorer
else
{
AllTypes.Add(type.FullName, type);
allTypeNames.Add(type.FullName);
//allTypeNames.Add(type.FullName);
}
OnTypeLoaded?.Invoke(type);
@ -211,14 +227,24 @@ namespace UnityExplorer
/// </summary>
/// <param name="baseType">The base type, which can optionally be abstract / interface.</param>
/// <returns>All implementations of the type in the current AppDomain.</returns>
public static HashSet<Type> GetImplementationsOf(Type baseType, bool allowAbstract, bool allowGeneric)
public static HashSet<Type> GetImplementationsOf(Type baseType, bool allowAbstract, bool allowGeneric, bool allowRecursive = true)
{
var key = GetImplementationKey(baseType); //baseType.FullName;
var key = GetImplementationKey(baseType);
int count = AllTypes.Count;
HashSet<Type> ret;
if (!baseType.IsGenericParameter)
return GetImplementations(key, baseType, allowAbstract, allowGeneric);
ret = GetImplementations(key, baseType, allowAbstract, allowGeneric);
else
return GetGenericParameterImplementations(key, baseType, allowAbstract, allowGeneric);
ret = GetGenericParameterImplementations(key, baseType, allowAbstract, allowGeneric);
// types were resolved during the parse, do it again if we're not already rebuilding.
if (allowRecursive && AllTypes.Count != count)
{
ret = GetImplementationsOf(baseType, allowAbstract, allowGeneric, false);
}
return ret;
}
private static HashSet<Type> GetImplementations(string key, Type baseType, bool allowAbstract, bool allowGeneric)
@ -226,8 +252,10 @@ namespace UnityExplorer
if (!typeInheritance.ContainsKey(key))
{
var set = new HashSet<Type>();
foreach (var name in allTypeNames)
var names = GetTypeNameArray();
for (int i = 0; i < names.Length; i++)
{
var name = names[i];
try
{
var type = AllTypes[name];
@ -263,8 +291,10 @@ namespace UnityExplorer
{
var set = new HashSet<Type>();
foreach (var name in allTypeNames)
var names = GetTypeNameArray();
for (int i = 0; i < names.Length; i++)
{
var name = names[i];
try
{
var type = AllTypes[name];

View File

@ -10,9 +10,6 @@ using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityExplorer.Core;
using UnityExplorer.Core.CSharp;
using UnityExplorer.Core.Input;
namespace UnityExplorer.Core.Runtime.Mono
{

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,7 @@ namespace UnityExplorer
public static readonly Color StringOrange = new Color(0.83f, 0.61f, 0.52f);
public static readonly Color EnumGreen = new Color(0.57f, 0.76f, 0.43f);
public static readonly Color KeywordBlue = new Color(0.3f, 0.61f, 0.83f);
public static readonly string keywordBlueHex = KeywordBlue.ToHex();
public static readonly Color NumberGreen = new Color(0.71f, 0.8f, 0.65f);
internal static string GetClassColor(Type type)