diff --git a/Assets/Baracuda/Monitoring.Editor/IL2CPPBuildPreprocessor.cs b/Assets/Baracuda/Monitoring.Editor/IL2CPPBuildPreprocessor.cs index 28f146b4..2363b2d0 100644 --- a/Assets/Baracuda/Monitoring.Editor/IL2CPPBuildPreprocessor.cs +++ b/Assets/Baracuda/Monitoring.Editor/IL2CPPBuildPreprocessor.cs @@ -39,7 +39,7 @@ public static void GenerateIL2CPPAheadOfTimeTypes() OnPreprocessBuildInternal(); #endif } - + #endregion #region --- Interface --- @@ -62,7 +62,7 @@ public void OnPreprocessBuild(BuildReport report) } #endif } - + #endregion //-------------------------------------------------------------------------------------------------------------- @@ -70,54 +70,54 @@ public void OnPreprocessBuild(BuildReport report) #region --- Fields --- /* - * Const fields + * Const fields */ - private const BindingFlags STATIC_FLAGS = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; + private const BindingFlags StaticFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; - private const BindingFlags INSTANCE_FLAGS = BindingFlags.Instance | BindingFlags.Public | + private const BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; - - + + private static readonly string preserveAttribute = $"[{typeof(PreserveAttribute).FullName}]"; private static readonly string methodImpAttribute = $"[{typeof(MethodImplAttribute).FullName}({typeof(MethodImplOptions).FullName}.{MethodImplOptions.NoOptimization.ToString()})]"; private static readonly string aotBridgeClass = typeof(AOTBridge).FullName; - + /* - * Queues & Caches + * Queues & Caches */ private static readonly List fieldProfileDefinitions = new List(); private static readonly List propertyProfileDefinitions = new List(); private static readonly List eventProfileDefinitions = new List(); private static readonly List methodProfileDefinitions = new List(); - + private static readonly HashSet uniqueTypeDefinitions = new HashSet(); private static readonly HashSet uniqueMonitoredTypes = new HashSet(); private static readonly List signatureDefinitions = new List(); - + private static readonly List errorBuffer = new List(); private static int id; private static IStatCounter Stats { get; set; } - + #endregion - + #region --- Preprocess Internal --- private static void OnPreprocessBuildInternal() { ResetQueuesAndCaches(); unityAssemblies = CompilationPipeline.GetAssemblies(); - + var textFile = MonitoringSystems.Resolve().ScriptFileIL2CPP; var filePath = AssetDatabase.GetAssetPath(textFile); - + Debug.Log($"Starting IL2CPP AOT type definition generation.\nFilePath: {filePath}"); ProfileAssembliesAndCreateDefinitions(); - + var stringBuilder = new StringBuilder(short.MaxValue); AppendHeaderText(stringBuilder); @@ -128,16 +128,16 @@ private static void OnPreprocessBuildInternal() AppendProfileDefinitions(stringBuilder, propertyProfileDefinitions, "Property Profiles"); AppendProfileDefinitions(stringBuilder, eventProfileDefinitions, "Event Profiles"); AppendProfileDefinitions(stringBuilder, methodProfileDefinitions, "Method Profiles"); - + AppendMethodDefinitions(stringBuilder); - + AppendCloseClass(stringBuilder); AppendIfDefEnd(stringBuilder); - + AppendStats(stringBuilder); - + Debug.Log($"Writing type definitions to file.\nFilePath: {filePath}"); - + WriteContentToFile(filePath, stringBuilder); if (errorBuffer.Any()) @@ -147,7 +147,7 @@ private static void OnPreprocessBuildInternal() Debug.LogWarning(errorMessage); } } - + AssetDatabase.Refresh(); Debug.Log("Successfully completed IL2CPP AOT type definition generation"); @@ -155,7 +155,7 @@ private static void OnPreprocessBuildInternal() { Debug.Log(Stats.ToString(false)); } - + ResetQueuesAndCaches(); } @@ -191,12 +191,12 @@ private static void AppendProfileDefinitions(StringBuilder stringBuilder, IReadO AppendLineBreak(stringBuilder); AppendLine(stringBuilder); } - + private static void AppendMethodDefinitions(StringBuilder stringBuilder) { AppendComment(stringBuilder, "Value Processor Method Definitions"); AppendLineBreak(stringBuilder); - + stringBuilder.Append("\n "); stringBuilder.Append(preserveAttribute); stringBuilder.Append("\n "); @@ -205,17 +205,17 @@ private static void AppendMethodDefinitions(StringBuilder stringBuilder) stringBuilder.Append("private static void AOT()"); stringBuilder.Append("\n "); stringBuilder.Append("{"); - + for (var i = 0; i < signatureDefinitions.Count; i++) { var definition = signatureDefinitions[i]; stringBuilder.Append(definition); } - + stringBuilder.Append("\n "); stringBuilder.Append("}"); } - + #endregion #region --- Append Meta --- @@ -241,7 +241,7 @@ private static void AppendHeaderText(StringBuilder stringBuilder) stringBuilder.Append("//https://github.com/JohnBaracuda/Runtime-Monitoring"); stringBuilder.Append('\n'); } - + private static void AppendCopyrightNote(StringBuilder stringBuilder) { stringBuilder.Append("// Copyright (c) 2022 Jonathan Lang\n"); @@ -282,7 +282,7 @@ private static void AppendCloseClass(StringBuilder stringBuilder) stringBuilder.Append('}'); stringBuilder.Append('\n'); } - + #endregion #region --- Append Stats --- @@ -290,18 +290,18 @@ private static void AppendCloseClass(StringBuilder stringBuilder) private static void AppendStats(StringBuilder stringBuilder) { AppendComment(stringBuilder, new string('-', 118), 0); - AppendLineBreak(stringBuilder,2); + AppendLineBreak(stringBuilder, 2); stringBuilder.Append(Stats.ToString(true)); AppendComment(stringBuilder, new string('-', 118), 0); AppendLineBreak(stringBuilder); AppendComment(stringBuilder, "If this file contains any errors please contact me and/or create an issue in the linked repository." , 0); AppendComment(stringBuilder, "https://github.com/JohnBaracuda/Runtime-Monitoring" , 0); } - + #endregion #region --- Append Misc --- - + private static void AppendLineBreak(StringBuilder stringBuilder, int breaks = 1) { for (var i = 0; i < breaks; i++) @@ -309,7 +309,7 @@ private static void AppendLineBreak(StringBuilder stringBuilder, int breaks = 1) stringBuilder.Append('\n'); } } - + private static void AppendComment(StringBuilder stringBuilder, string comment, int indent = 4) { stringBuilder.Append('\n'); @@ -317,14 +317,14 @@ private static void AppendComment(StringBuilder stringBuilder, string comment, i stringBuilder.Append("//"); stringBuilder.Append(comment); } - + private static void AppendLine(StringBuilder stringBuilder) { stringBuilder.Append(" //"); stringBuilder.Append(new string('-', 114)); stringBuilder.Append('\n'); } - + #endregion //-------------------------------------------------------------------------------------------------------------- @@ -339,11 +339,11 @@ private static void ProfileAssembliesAndCreateDefinitions() { continue; } - + foreach (var type in filteredAssembly.GetTypes()) { // Static Fields - foreach (var fieldInfo in type.GetFields(STATIC_FLAGS)) + foreach (var fieldInfo in type.GetFields(StaticFlags)) { if (fieldInfo.HasAttribute(true)) { @@ -351,16 +351,16 @@ private static void ProfileAssembliesAndCreateDefinitions() } } // Instance Fields - foreach (var fieldInfo in type.GetFields(INSTANCE_FLAGS)) + foreach (var fieldInfo in type.GetFields(InstanceFlags)) { if (fieldInfo.HasAttribute(true)) { ProfileFieldInfo(fieldInfo); } } - + // Static Properties - foreach (var propertyInfo in type.GetProperties(STATIC_FLAGS)) + foreach (var propertyInfo in type.GetProperties(StaticFlags)) { if (propertyInfo.HasAttribute(true)) { @@ -368,16 +368,16 @@ private static void ProfileAssembliesAndCreateDefinitions() } } // Instance Properties - foreach (var propertyInfo in type.GetProperties(INSTANCE_FLAGS)) + foreach (var propertyInfo in type.GetProperties(InstanceFlags)) { if (propertyInfo.HasAttribute(true)) { ProfilePropertyInfo(propertyInfo); } } - + // Static Events - foreach (var eventInfo in type.GetEvents(STATIC_FLAGS)) + foreach (var eventInfo in type.GetEvents(StaticFlags)) { if (eventInfo.HasAttribute(true)) { @@ -385,16 +385,16 @@ private static void ProfileAssembliesAndCreateDefinitions() } } // Instance Events - foreach (var eventInfo in type.GetEvents(INSTANCE_FLAGS)) + foreach (var eventInfo in type.GetEvents(InstanceFlags)) { if (eventInfo.HasAttribute(true)) { ProfileEventInfo(eventInfo); } } - + // Static Methods - foreach (var methodInfo in type.GetMethods(STATIC_FLAGS)) + foreach (var methodInfo in type.GetMethods(StaticFlags)) { if (methodInfo.HasAttribute(true)) { @@ -402,7 +402,7 @@ private static void ProfileAssembliesAndCreateDefinitions() } } // Instance Methods - foreach (var methodInfo in type.GetMethods(INSTANCE_FLAGS)) + foreach (var methodInfo in type.GetMethods(InstanceFlags)) { if (methodInfo.HasAttribute(true)) { @@ -485,7 +485,7 @@ private static void ProfileEventInfo(EventInfo eventInfo) errorBuffer.Add(exception.Message); } } - + private static void ProfileMethodInfo(MethodInfo methodInfo) { try @@ -495,12 +495,12 @@ private static void ProfileMethodInfo(MethodInfo methodInfo) Debug.LogWarning($"Monitored Method {methodInfo.DeclaringType?.Name}.{methodInfo.Name} needs a return value or out parameter!"); return; } - + Stats.IncrementStat("Monitored Member"); Stats.IncrementStat($"Monitored Member {(methodInfo.IsStatic? "Static" : "Instance")}"); Stats.IncrementStat("Monitored Methods", "MemberInfo"); Stats.IncrementStat($"Monitored Methods {(methodInfo.IsStatic? "Static" : "Instance")}", "MemberInfo"); - + var template = typeof(MethodProfile<,>); var declaring = methodInfo.DeclaringType; var monitored = methodInfo.ReturnType; @@ -514,13 +514,13 @@ private static void ProfileMethodInfo(MethodInfo methodInfo) } errorBuffer.Add(exception.Message); } - + foreach (var parameterInfo in methodInfo.GetParameters().Where(info => info.IsOut)) { try { Stats.IncrementStat("Monitored Out Parameter", "Out Parameter"); - Stats.IncrementStat($"Monitored Out Parameter {parameterInfo.ParameterType.ToReadableTypeString()}", "Out Parameter"); + Stats.IncrementStat($"Monitored Out Parameter {parameterInfo.ParameterType.HumanizedName()}", "Out Parameter"); TryCreateOutParameterHandleDefinition(parameterInfo.ParameterType); } catch (Exception exception) @@ -533,13 +533,13 @@ private static void ProfileMethodInfo(MethodInfo methodInfo) } } } - + #endregion #region --- Type Definitions --- /* - * Out Param Type Def + * Out Param Type Def */ private static void TryCreateOutParameterHandleDefinition(Type type) @@ -550,7 +550,7 @@ private static void TryCreateOutParameterHandleDefinition(Type type) return; } var concreteType = typeof(OutParameterHandleT<>).MakeGenericType(underlying); - + if (TryCreateUniqueTypeDefString(concreteType, out var str)) { methodProfileDefinitions.Add(str); @@ -559,16 +559,16 @@ private static void TryCreateOutParameterHandleDefinition(Type type) /* - * Profile Type Def + * Profile Type Def */ - + private static void CreateProfileTypeDefFor(Type template, Type declaringType, Type monitoredType, in ICollection definitionList) { if (monitoredType.IsGenericParameter) { return; } - + var declaring = MakeViableType(declaringType); var monitored = MakeViableType(monitoredType); @@ -576,13 +576,13 @@ private static void CreateProfileTypeDefFor(Type template, Type declaringType, T { return; } - - + + CreateMethodSig(monitored); - Stats.IncrementStat($"Monitored {monitored.ToReadableTypeString()}", "Monitored Types"); - + Stats.IncrementStat($"Monitored {monitored.HumanizedName()}", "Monitored Types"); + var definition = template.MakeGenericType(declaring, monitored); - + if (TryCreateUniqueTypeDefString(definition, out var str)) { definitionList.Add(str); @@ -590,9 +590,9 @@ private static void CreateProfileTypeDefFor(Type template, Type declaringType, T } /* - * Create Definition String + * Create Definition String */ - + private static bool TryCreateUniqueTypeDefString(Type type, out string defString) { if (uniqueTypeDefinitions.Contains(type)) @@ -605,16 +605,16 @@ private static bool TryCreateUniqueTypeDefString(Type type, out string defString defString = CreateTypeDefinitionString(type); return true; } - + private static string CreateTypeDefinitionString(Type type) { var stringBuilder = StringBuilderPool.Get(); stringBuilder.Append("\n //"); - stringBuilder.Append(type.ToReadableTypeString()); + stringBuilder.Append(type.HumanizedName()); stringBuilder.Append("\n "); stringBuilder.Append(preserveAttribute); stringBuilder.Append("\n "); - stringBuilder.Append(type.ToReadableTypeStringFullName()); + stringBuilder.Append(MakeAccessibleSyntaxString(type)); stringBuilder.Append(' '); stringBuilder.Append("AOT_GENERATED_TYPE_"); stringBuilder.Append(id++); @@ -639,7 +639,7 @@ private static void CreateMethodSig(Type type) } uniqueMonitoredTypes.Add(viableType); - + if (viableType.IsValueTypeArray()) { ProcessValueTypeArray(type); @@ -660,7 +660,7 @@ private static void CreateMethodSig(Type type) { ProcessList(type); } - + void ProcessList(Type valueType) { var stringBuilder = StringBuilderPool.Get(); @@ -669,13 +669,13 @@ void ProcessList(Type valueType) stringBuilder.Append('.'); stringBuilder.Append("AOTList"); stringBuilder.Append('<'); - stringBuilder.Append(valueType.ToReadableTypeStringFullName()); + stringBuilder.Append(MakeAccessibleSyntaxString(valueType)); stringBuilder.Append(", "); - stringBuilder.Append(valueType.GetGenericArguments()[0].ToReadableTypeStringFullName()); + stringBuilder.Append(MakeAccessibleSyntaxString(valueType.GetGenericArguments()[0])); stringBuilder.Append(">();"); signatureDefinitions.Add(StringBuilderPool.Release(stringBuilder)); } - + void ProcessValueTypeArray(Type valueType) { var stringBuilder = StringBuilderPool.Get(); @@ -684,11 +684,11 @@ void ProcessValueTypeArray(Type valueType) stringBuilder.Append('.'); stringBuilder.Append("AOTValueTypeArray"); stringBuilder.Append('<'); - stringBuilder.Append(valueType.GetElementType().ToReadableTypeStringFullName()); + stringBuilder.Append(MakeAccessibleSyntaxString(valueType.GetElementType())); stringBuilder.Append(">();"); signatureDefinitions.Add(StringBuilderPool.Release(stringBuilder)); } - + void ProcessArray(Type arrayType) { var stringBuilder = StringBuilderPool.Get(); @@ -697,7 +697,7 @@ void ProcessArray(Type arrayType) stringBuilder.Append('.'); stringBuilder.Append("AOTReferenceTypeArray"); stringBuilder.Append('<'); - stringBuilder.Append(arrayType.GetElementType().ToReadableTypeStringFullName()); + stringBuilder.Append(MakeAccessibleSyntaxString(arrayType.GetElementType())); stringBuilder.Append(">();"); signatureDefinitions.Add(StringBuilderPool.Release(stringBuilder)); } @@ -710,9 +710,9 @@ void ProcessDictionary(Type dictionaryType) stringBuilder.Append('.'); stringBuilder.Append("AOTDictionary"); stringBuilder.Append('<'); - stringBuilder.Append(dictionaryType.GetGenericArguments()[0].ToReadableTypeStringFullName()); + stringBuilder.Append(MakeAccessibleSyntaxString(dictionaryType.GetGenericArguments()[0])); stringBuilder.Append(','); - stringBuilder.Append(dictionaryType.GetGenericArguments()[1].ToReadableTypeStringFullName()); + stringBuilder.Append(MakeAccessibleSyntaxString(dictionaryType.GetGenericArguments()[1])); stringBuilder.Append(">();"); signatureDefinitions.Add(StringBuilderPool.Release(stringBuilder)); } @@ -725,12 +725,12 @@ void ProcessEnumerable(Type enumerableType) stringBuilder.Append('.'); stringBuilder.Append("AOTEnumerable"); stringBuilder.Append('<'); - stringBuilder.Append(enumerableType.GetGenericArguments()[0].ToReadableTypeStringFullName()); + stringBuilder.Append(MakeAccessibleSyntaxString(enumerableType.GetGenericArguments()[0])); stringBuilder.Append(">();"); signatureDefinitions.Add(StringBuilderPool.Release(stringBuilder)); } } - + #endregion //-------------------------------------------------------------------------------------------------------------- @@ -746,7 +746,7 @@ private static Type MakeViableType(Type type) } var underlying = (type.IsByRef ? type.GetElementType() : type) ?? type; - + if (underlying == typeof(void)) { return typeof(VoidValue); @@ -783,34 +783,89 @@ private static Type MakeViableType(Type type) } var error = - $"[MONITORING] Error: {type.ToReadableTypeString()} is not accessible! ({type.FullName?.Replace('+', '.')})" + + $"[MONITORING] Error: {type.HumanizedName()} is not accessible! ({type.FullName?.Replace('+', '.')})" + $"\nCannot generate AOT code for unmanaged internal/private types! " + - $"Please make sure that {type.ToReadableTypeString()} and all of its declaring types are either public or use a managed type instead of struct!"; - + $"Please make sure that {type.HumanizedName()} and all of its declaring types are either public or use a managed type instead of struct!"; + errorBuffer.Add(error); - + return null; } - - + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string MakeAccessibleSyntaxString(Type type) + { + if (type.IsStatic()) + { + return typeof(object).FullName?.Replace('+', '.'); + } + + if (!type.IsAccessible()) + { + return typeof(object).FullName?.Replace('+', '.'); + } + + if (type.IsGenericType) + { + var builder = ConcurrentStringBuilderPool.Get(); + var argBuilder = ConcurrentStringBuilderPool.Get(); + + var arguments = type.GetGenericArguments(); + + foreach (var typeArg in arguments) + { + // Let's make sure we get the argument list. + var arg = MakeAccessibleSyntaxString(typeArg); + + if (argBuilder.Length > 0) + { + argBuilder.AppendFormat(", {0}", arg); + } + else + { + argBuilder.Append(arg); + } + } + + if (argBuilder.Length > 0) + { + Debug.Assert(type.FullName != null, "type.FullName != null"); + builder.AppendFormat("{0}<{1}>", type.FullName.Split('`')[0], + argBuilder); + } + + var retType = builder.ToString(); + + ConcurrentStringBuilderPool.ReleaseStringBuilder(builder); + ConcurrentStringBuilderPool.ReleaseStringBuilder(argBuilder); + return retType.Replace('+', '.'); + } + + Debug.Assert(type.FullName != null, $"type.FullName != null | {type.Name}, {type.DeclaringType}"); + + var returnValue = type.FullName.Replace('+', '.'); + return returnValue; + } + + private static void ResetQueuesAndCaches() { id = 0; - + fieldProfileDefinitions.Clear(); propertyProfileDefinitions.Clear(); eventProfileDefinitions.Clear(); methodProfileDefinitions.Clear(); - + signatureDefinitions.Clear(); uniqueTypeDefinitions.Clear(); uniqueMonitoredTypes.Clear(); - + errorBuffer.Clear(); Stats = new StatCounter(); } - + #endregion #region --- Editor Misc --- diff --git a/Assets/Baracuda/Monitoring/Source/Profiles/EventProfile.cs b/Assets/Baracuda/Monitoring/Source/Profiles/EventProfile.cs index a60ca375..9ff99808 100644 --- a/Assets/Baracuda/Monitoring/Source/Profiles/EventProfile.cs +++ b/Assets/Baracuda/Monitoring/Source/Profiles/EventProfile.cs @@ -133,7 +133,7 @@ private static Func CreateSubscriberDataExpression(Func().CreateProcessorForType(FormatData); - + var parameter = CreateParameterArray(methodInfo, attribute); _getValueDelegate = CreateGetDelegate(methodInfo, parameter, valueProcessor, FormatData, args.Settings); } @@ -42,12 +42,12 @@ private static Func> CreateGetDelegate(MethodInfo var sb = new StringBuilder(); var parameterInfos = methodInfo.GetParameters(); var parameterHandles = CreateParameterHandles(parameterInfos, format, settings); - - + + if (methodInfo.ReturnType == typeof(void)) { var @void = new VoidValue().ConvertFast(); - + return target => { sb.Clear(); @@ -102,8 +102,8 @@ private static Dictionary CreateParameterHandles(IReadO Group = format.Group, ElementIndent = Mathf.Max(format.ElementIndent * 2, 4) }; - - + + var handle = OutParameterHandle.CreateForType(current.ParameterType, parameterFormat); handles.Add(i, handle); } @@ -116,7 +116,7 @@ private static object[] CreateParameterArray(MethodInfo methodInfo, MonitorAttri var parameterInfos = methodInfo.GetParameters(); var paramArray = new object[parameterInfos.Length]; var monitorMethodAttribute = attribute as MonitorMethodAttribute; - + for (var i = 0; i < parameterInfos.Length; i++) { var current = parameterInfos[i]; @@ -127,7 +127,7 @@ private static object[] CreateParameterArray(MethodInfo methodInfo, MonitorAttri } else { - var defaultValue = current.HasDefaultValue? current.DefaultValue : currentType.GetDefault(); + var defaultValue = current.HasDefaultValue ? current.DefaultValue : currentType.GetDefault(); paramArray[i] = defaultValue; } } diff --git a/Assets/Baracuda/Monitoring/Source/Profiles/MonitorProfile.cs b/Assets/Baracuda/Monitoring/Source/Profiles/MonitorProfile.cs index 9b424155..8ae2500b 100644 --- a/Assets/Baracuda/Monitoring/Source/Profiles/MonitorProfile.cs +++ b/Assets/Baracuda/Monitoring/Source/Profiles/MonitorProfile.cs @@ -161,7 +161,7 @@ protected MonitorProfile( if(settings.FilterType) { - var readableString = MonitoredMemberType.ToReadableTypeString(); + var readableString = MonitoredMemberType.HumanizedName(); tags.Add(readableString); utility.AddTypeString(readableString); } diff --git a/Assets/Baracuda/Monitoring/Source/Systems/MonitoringUISystem.cs b/Assets/Baracuda/Monitoring/Source/Systems/MonitoringUISystem.cs index eb959bf8..55027dde 100644 --- a/Assets/Baracuda/Monitoring/Source/Systems/MonitoringUISystem.cs +++ b/Assets/Baracuda/Monitoring/Source/Systems/MonitoringUISystem.cs @@ -324,6 +324,11 @@ public void ApplyFilter(string filterString) public void ResetFilter() { + if (string.IsNullOrWhiteSpace(_activeFilter)) + { + return; + } + _activeFilter = null; _ticker.ValidationTickEnabled = true; var units = _manager.GetAllMonitoringUnits(); diff --git a/Assets/Baracuda/Monitoring/Source/Types/FormatData.cs b/Assets/Baracuda/Monitoring/Source/Types/FormatData.cs index 049d9970..f905b09c 100644 --- a/Assets/Baracuda/Monitoring/Source/Types/FormatData.cs +++ b/Assets/Baracuda/Monitoring/Source/Types/FormatData.cs @@ -148,7 +148,7 @@ internal static IFormatData CreateFormatData(IMonitorProfile profile, IMonitorin string MakeGroup() { return profile.DeclaringType.IsGenericType - ? profile.DeclaringType.ToReadableTypeString() + ? profile.DeclaringType.HumanizedName() : (settings.HumanizeNames ? Humanize(profile.DeclaringType.Name) : profile.DeclaringType.Name); diff --git a/Assets/Baracuda/Monitoring/Source/Units/MonitorUnit.cs b/Assets/Baracuda/Monitoring/Source/Units/MonitorUnit.cs index 526dfc1e..f2b53b80 100644 --- a/Assets/Baracuda/Monitoring/Source/Units/MonitorUnit.cs +++ b/Assets/Baracuda/Monitoring/Source/Units/MonitorUnit.cs @@ -198,7 +198,7 @@ public virtual void Dispose() public override string ToString() { - return GetType().ToReadableTypeString(); + return GetType().HumanizedName(); } #endregion diff --git a/Assets/Baracuda/Utilities/Extensions/ReflectionExtensions.cs b/Assets/Baracuda/Utilities/Extensions/ReflectionExtensions.cs index 7ee87743..379140c6 100644 --- a/Assets/Baracuda/Utilities/Extensions/ReflectionExtensions.cs +++ b/Assets/Baracuda/Utilities/Extensions/ReflectionExtensions.cs @@ -30,7 +30,7 @@ public static bool TryGetCustomAttribute(this MemberInfo memberInfo, out T at attribute = null; return false; } - + public static bool HasAttribute(this ICustomAttributeProvider provider, bool inherited = true) where T : Attribute { try @@ -47,12 +47,12 @@ public static bool HasAttribute(this MemberInfo memberInfo) where T : Attribu { return memberInfo.GetCustomAttribute() != null; } - + public static bool LacksAttribute(this MemberInfo memberInfo) where T : Attribute { return memberInfo.GetCustomAttribute() == null; } - + public static T FindAttributeInMono(this GameObject target, bool inherit = true) where T : Attribute { foreach (var component in target.GetComponents()) @@ -66,7 +66,7 @@ public static T FindAttributeInMono(this GameObject target, bool inherit = tr return null; } - + public static T[] FindAttributesInMono(this GameObject target, bool inherit = true) where T : Attribute { var attributes = new List(3); @@ -102,7 +102,7 @@ public static T[] FindAttributesInComponent(this GameObject target, bool inhe return attributes.ToArray(); } - + public static TAttribute GetAttribute(this Enum value) where TAttribute : Attribute { var enumType = value.GetType(); @@ -113,24 +113,24 @@ public static TAttribute GetAttribute(this Enum value) where TAttrib .OfType() .SingleOrDefault(); } - + #endregion - + #region --- Invoke Method --- [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static MethodInfo GetInvokeMethod(this Type type, BindingFlags flags = - BindingFlags.Static | - BindingFlags.NonPublic | + public static MethodInfo GetInvokeMethod(this Type type, BindingFlags flags = + BindingFlags.Static | + BindingFlags.NonPublic | BindingFlags.Instance | - BindingFlags.Public | + BindingFlags.Public | BindingFlags.FlattenHierarchy) { return type.GetMethod("Invoke", flags); } - + #endregion - + #region --- FieldInfo Getter & Setter --- #if !ENABLE_IL2CPP && UNITY_2021_3_OR_NEWER @@ -140,7 +140,7 @@ public static Func CreateGetter(this FieldIn { return (target) => (TResult)field.GetValue(target);; } - + var methodName = $"{field!.ReflectedType!.FullName}.get_{field.Name}"; var setterMethod = new DynamicMethod(methodName, typeof(TResult), new[] {typeof(TTarget)}, true); var gen = setterMethod.GetILGenerator(); @@ -181,7 +181,7 @@ public static Action CreateSetter(this FieldIn #else public static Func CreateGetter(this FieldInfo field) { - return target => (TResult)field.GetValue(target); + return target => (TResult) field.GetValue(target); } public static Action CreateSetter(this FieldInfo field) @@ -189,30 +189,30 @@ public static Action CreateSetter(this FieldIn return (target, value) => field.SetValue(target, value); } #endif - + public static Func CreateStaticGetter(this FieldInfo field) { - return () => (TResult)field.GetValue(null); + return () => (TResult) field.GetValue(null); } - + #endregion - + #region --- MemberInfo Casting --- private const BindingFlags EVENT_FLAGS = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy; - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static FieldInfo AsFieldInfo(this EventInfo eventInfo) { return eventInfo.DeclaringType?.GetField(eventInfo.Name, EVENT_FLAGS); } - + #endregion - + #region --- Delegate Creation --- - + public static Delegate CreateMatchingDelegate(this MethodInfo methodInfo, object target) { Func getType; @@ -231,11 +231,11 @@ public static Delegate CreateMatchingDelegate(this MethodInfo methodInfo, object types = types.Concat(new[] {methodInfo.ReturnType}); } - return isStatic - ? Delegate.CreateDelegate(getType(types.ToArray()), methodInfo) + return isStatic + ? Delegate.CreateDelegate(getType(types.ToArray()), methodInfo) : Delegate.CreateDelegate(getType(types.ToArray()), target, methodInfo.Name); } - + public static Delegate CreateMatchingDelegate(this MethodInfo methodInfo) { Func getType; @@ -255,13 +255,13 @@ public static Delegate CreateMatchingDelegate(this MethodInfo methodInfo) return Delegate.CreateDelegate(getType(types.ToArray()), methodInfo); } - + #endregion - + #region --- Backing Field Access --- - + #if !ENABLE_IL2CPP - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static FieldInfo GetBackingField(this PropertyInfo propertyInfo, bool strictCheckIsAutoProperty = false) @@ -319,7 +319,7 @@ private static bool StrictCheckIsAutoProperty(PropertyInfo pi) { return null != pi.GetCustomAttribute(); } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool StrictCheckIsAutoPropertyBackingField(PropertyInfo pi, FieldInfo fi) { @@ -359,7 +359,7 @@ private static int GetAutoPropertyBakingFieldMetadataTokenInSetMethodOfInstance( : -1; } #endif - + #endregion #region --- Underlying & Collection Types --- @@ -411,7 +411,7 @@ public static bool IsStatic(this PropertyInfo propertyInfo) { return propertyInfo?.GetMethod?.IsStatic ?? propertyInfo?.SetMethod?.IsStatic ?? throw new InvalidProgramException(); } - + public static bool IsStatic(this EventInfo eventInfo) { return eventInfo.AddMethod?.IsStatic ?? eventInfo.RemoveMethod.IsStatic; @@ -426,7 +426,7 @@ public static int GetSubscriberCount(this TDelegate eventDelegate) wh { return eventDelegate?.GetInvocationList().Length ?? 0; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string GetSubscriberCountString(this TDelegate eventDelegate) where TDelegate : Delegate { @@ -436,7 +436,7 @@ public static string GetSubscriberCountString(this TDelegate eventDel #endregion #region --- Display String Formatting --- - + private static readonly Dictionary typeCache = new Dictionary(); [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -456,9 +456,9 @@ public static string GetEventSignatureString(this EventInfo eventInfo) var sb = ConcurrentStringBuilderPool.Get(); sb.Append(eventType.GetNameWithoutGenericArity()); - - if(eventType.IsGenericType){} - + + if (eventType.IsGenericType){} + if (parameters.Length > 0) { sb.Append(isGeneric ? '<' : '('); @@ -467,7 +467,7 @@ public static string GetEventSignatureString(this EventInfo eventInfo) for (var i = 0; i < parameters.Length; i++) { var parameterInfo = parameters[i]; - sb.Append(parameterInfo.ParameterType.ToReadableTypeString()); + sb.Append(parameterInfo.ParameterType.HumanizedName()); if (!isGeneric) { sb.Append(' '); @@ -479,12 +479,12 @@ public static string GetEventSignatureString(this EventInfo eventInfo) sb.Append(' '); } } - + if (parameters.Length > 0) { sb.Append(isGeneric ? '>' : ')'); } - + return ConcurrentStringBuilderPool.Release(sb); } @@ -497,24 +497,26 @@ public static string GetSignatureString(this MethodInfo methodInfo) stringBuilder.Append(methodInfo.ReturnType.Name); - if (parameters.Any()) + if (!parameters.Any()) + { + return stringBuilder.ToString(); + } + + stringBuilder.Append(' '); + stringBuilder.Append('('); + for (var i = 0; i < parameters.Length; i++) { + stringBuilder.Append(parameters[i].ParameterType.Name); stringBuilder.Append(' '); - stringBuilder.Append('('); - for (var i = 0; i < parameters.Length; i++) + stringBuilder.Append(parameters[i].Name); + if (i != parameters.Length - 1) { - stringBuilder.Append(parameters[i].ParameterType.Name); + stringBuilder.Append(','); stringBuilder.Append(' '); - stringBuilder.Append(parameters[i].Name); - if (i != parameters.Length - 1) - { - stringBuilder.Append(','); - stringBuilder.Append(' '); - } } - stringBuilder.Append(')'); } - + stringBuilder.Append(')'); + return stringBuilder.ToString(); } @@ -573,12 +575,12 @@ public static string ToReadableTypeStringFullName(this Type type) } Debug.Assert(type.FullName != null, $"type.FullName != null | {type.Name}, {type.DeclaringType}"); - + var returnValue = type.FullName.Replace('+', '.'); typeCacheFullName.Add(type, returnValue); return returnValue; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string GetNameWithoutGenericArity(this Type type) { @@ -588,7 +590,7 @@ public static string GetNameWithoutGenericArity(this Type type) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string ToReadableTypeString(this Type type) + public static string HumanizedName(this Type type) { if (typeCache.TryGetValue(type, out var value)) { @@ -604,7 +606,7 @@ public static string ToReadableTypeString(this Type type) foreach (var t in arguments) { - var arg = ToReadableTypeString(t); + var arg = HumanizedName(t); if (argBuilder.Length > 0) { @@ -625,10 +627,10 @@ public static string ToReadableTypeString(this Type type) var retType = builder.ToString().Replace('+', '.'); typeCache.Add(type, retType); - + ConcurrentStringBuilderPool.ReleaseStringBuilder(builder); ConcurrentStringBuilderPool.ReleaseStringBuilder(argBuilder); - + return retType; } @@ -718,15 +720,15 @@ public static string ToFullTypeName(this string typeKeyword) return typeKeyword; } } - + #endregion - + #region --- Base Type Reflection --- - + public static Type[] GetBaseTypes(this Type type, bool includeThis, bool includeInterfaces = false) { var temp = ConcurrentListPool.Get(); - + if (includeThis) { temp.Add(type); @@ -736,12 +738,12 @@ public static Type[] GetBaseTypes(this Type type, bool includeThis, bool include { temp.AddRange(type.GetInterfaces()); } - + while (type.BaseType != null) { temp.Add(type.BaseType); type = type.BaseType; - if(type == typeof(MonoBehaviour) || type == typeof(ScriptableObject)) + if (type == typeof(MonoBehaviour) || type == typeof(ScriptableObject)) { break; } @@ -751,7 +753,7 @@ public static Type[] GetBaseTypes(this Type type, bool includeThis, bool include ConcurrentListPool.Release(temp); return array; } - + public static Type[] GetDeclaringTypes(this Type type, bool includeThis) { var temp = ConcurrentListPool.Get(); @@ -760,7 +762,7 @@ public static Type[] GetDeclaringTypes(this Type type, bool includeThis) { temp.Add(type); } - + while (type.DeclaringType != null) { temp.Add(type.DeclaringType); @@ -771,7 +773,7 @@ public static Type[] GetDeclaringTypes(this Type type, bool includeThis) ConcurrentListPool.Release(temp); return array; } - + public static Type[] GetBaseTypesExcludeUnityTypes(this Type type, bool includeThis) { var temp = ConcurrentListPool.Get(); @@ -780,10 +782,10 @@ public static Type[] GetBaseTypesExcludeUnityTypes(this Type type, bool includeT { temp.Add(type); } - + while (type.BaseType != null) { - if(type.BaseType == typeof(MonoBehaviour) || type.BaseType == typeof(ScriptableObject)) + if (type.BaseType == typeof(MonoBehaviour) || type.BaseType == typeof(ScriptableObject)) { break; } @@ -798,13 +800,13 @@ public static Type[] GetBaseTypesExcludeUnityTypes(this Type type, bool includeT private static readonly Dictionary> memberCache = new Dictionary>(); - - + + public static void SetMemberValue(this Type type, string memberName, object target, BindingFlags flags, TValue value) { GetMemberValue(memberName, type, target, flags); } - + public static void SetMemberValue(string memberName, Type type, object target, BindingFlags flags, TValue value) { if (memberCache.TryGetValue(type, out var dictionary) && @@ -816,11 +818,11 @@ public static void SetMemberValue(string memberName, Type type, object t break; case PropertyInfo pi: pi.SetValue(target, value); break; - case MethodInfo mi: mi.Invoke(target, new object[]{value}); + case MethodInfo mi: mi.Invoke(target, new object[] {value}); break; } } - + var fieldInfo = type.GetFieldIncludeBaseTypes(memberName, flags); if (fieldInfo != null) { @@ -828,12 +830,12 @@ public static void SetMemberValue(string memberName, Type type, object t fieldInfo.SetValue(target, value); return; } - + var methodInfo = type.GetMethodIncludeBaseTypes(memberName, flags); if (methodInfo != null) { Cache(methodInfo); - methodInfo.Invoke(target, new object[]{value}); + methodInfo.Invoke(target, new object[] {value}); return; } @@ -842,7 +844,6 @@ public static void SetMemberValue(string memberName, Type type, object t { Cache(propertyInfo); propertyInfo.SetValue(target, value); - return; } void Cache(MemberInfo member) @@ -853,17 +854,20 @@ void Cache(MemberInfo member) } else { - memberCache.Add(type, new Dictionary(){{memberName, member}}); + memberCache.Add(type, new Dictionary + { + {memberName, member} + }); } } } - - + + public static object GetMemberValue(this Type type, string memberName, object target, BindingFlags flags) { return GetMemberValue(memberName, type, target, flags); } - + public static object GetMemberValue(string memberName, Type type, object target, BindingFlags flags) { if (memberCache.TryGetValue(type, out var dictionary) && @@ -876,14 +880,14 @@ public static object GetMemberValue(string memberName, Type type, object target, case MethodInfo mi: return mi.Invoke(target, Array.Empty()); } } - + var fieldInfo = type.GetFieldIncludeBaseTypes(memberName, flags); if (fieldInfo != null) { Cache(fieldInfo); return fieldInfo.GetValue(target); } - + var methodInfo = type.GetMethodIncludeBaseTypes(memberName, flags); if (methodInfo != null) { @@ -906,18 +910,21 @@ void Cache(MemberInfo member) } else { - memberCache.Add(type, new Dictionary(){{memberName, member}}); + memberCache.Add(type, new Dictionary + { + {memberName, member} + }); } } - + return null; } - - public static FieldInfo GetFieldIncludeBaseTypes(this Type type, string fieldName, BindingFlags flags = - BindingFlags.Static | - BindingFlags.NonPublic | + + public static FieldInfo GetFieldIncludeBaseTypes(this Type type, string fieldName, BindingFlags flags = + BindingFlags.Static | + BindingFlags.NonPublic | BindingFlags.Instance | - BindingFlags.Public | + BindingFlags.Public | BindingFlags.FlattenHierarchy) { FieldInfo fieldInfo = null; @@ -927,7 +934,7 @@ public static FieldInfo GetFieldIncludeBaseTypes(this Type type, string fieldNam { fieldInfo = targetType.GetField(fieldName, flags); targetType = targetType.BaseType; - + if (targetType == null) { return null; @@ -936,12 +943,12 @@ public static FieldInfo GetFieldIncludeBaseTypes(this Type type, string fieldNam return fieldInfo; } - - public static PropertyInfo GetPropertyIncludeBaseTypes(this Type type, string propertyName, BindingFlags flags = - BindingFlags.Static | - BindingFlags.NonPublic | + + public static PropertyInfo GetPropertyIncludeBaseTypes(this Type type, string propertyName, BindingFlags flags = + BindingFlags.Static | + BindingFlags.NonPublic | BindingFlags.Instance | - BindingFlags.Public | + BindingFlags.Public | BindingFlags.FlattenHierarchy) { PropertyInfo propertyInfo = null; @@ -951,7 +958,7 @@ public static PropertyInfo GetPropertyIncludeBaseTypes(this Type type, string pr { propertyInfo = targetType.GetProperty(propertyName, flags); targetType = targetType.BaseType; - + if (targetType == null) { return null; @@ -960,8 +967,8 @@ public static PropertyInfo GetPropertyIncludeBaseTypes(this Type type, string pr return propertyInfo; } - - + + public static MethodInfo GetMethodIncludeBaseTypes(this Type type, string methodName, BindingFlags flags) { MethodInfo methodInfo = null; @@ -972,7 +979,7 @@ public static MethodInfo GetMethodIncludeBaseTypes(this Type type, string method { methodInfo = targetType.GetMethod(methodName, flags); targetType = targetType.BaseType; - + if (targetType == null || value++ > 10) { return null; @@ -981,7 +988,7 @@ public static MethodInfo GetMethodIncludeBaseTypes(this Type type, string method return methodInfo; } - + public static EventInfo GetEventIncludeBaseTypes(this Type type, string eventName, BindingFlags flags) { EventInfo eventInfo = null; @@ -991,7 +998,7 @@ public static EventInfo GetEventIncludeBaseTypes(this Type type, string eventNam { eventInfo = targetType.GetEvent(eventName, flags); targetType = targetType.BaseType; - + if (targetType == null) { return null; @@ -1002,7 +1009,7 @@ public static EventInfo GetEventIncludeBaseTypes(this Type type, string eventNam } /* - * Multiple + * Multiple */ public static FieldInfo[] GetFieldsIncludeBaseTypes(this Type type, BindingFlags flags) @@ -1010,13 +1017,13 @@ public static FieldInfo[] GetFieldsIncludeBaseTypes(this Type type, BindingFlags var fieldInfos = ConcurrentListPool.Get(); var typesToCheck = ConcurrentListPool.Get(); var targetType = type; - + while (targetType.EqualsNone(typeof(MonoBehaviour), typeof(ScriptableObject), typeof(object))) { typesToCheck.Add(targetType); targetType = targetType?.BaseType; } - + for (var i = typesToCheck.Count - 1; i >= 0; i--) { fieldInfos.AddRange(typesToCheck[i].GetFields(flags)); @@ -1027,19 +1034,19 @@ public static FieldInfo[] GetFieldsIncludeBaseTypes(this Type type, BindingFlags ConcurrentListPool.Release(fieldInfos); return array; } - + public static PropertyInfo[] GetPropertiesIncludeBaseTypes(this Type type, BindingFlags flags) { var propertyInfos = ConcurrentListPool.Get(); var typesToCheck = ConcurrentListPool.Get(); var targetType = type; - + while (targetType.EqualsNone(typeof(MonoBehaviour), typeof(ScriptableObject), typeof(object))) { typesToCheck.Add(targetType); targetType = targetType?.BaseType; } - + for (var i = typesToCheck.Count - 1; i >= 0; i--) { propertyInfos.AddRange(typesToCheck[i].GetProperties(flags)); @@ -1050,20 +1057,20 @@ public static PropertyInfo[] GetPropertiesIncludeBaseTypes(this Type type, Bindi ConcurrentListPool.Release(propertyInfos); return array; } - - + + public static MethodInfo[] GetMethodsIncludeBaseTypes(this Type type, BindingFlags flags) { var methodInfos = ConcurrentListPool.Get(); var typesToCheck = ConcurrentListPool.Get(); var targetType = type; - + while (targetType.EqualsNone(typeof(MonoBehaviour), typeof(ScriptableObject), typeof(object))) { typesToCheck.Add(targetType); targetType = targetType?.BaseType; } - + for (var i = typesToCheck.Count - 1; i >= 0; i--) { methodInfos.AddRange(typesToCheck[i].GetMethods(flags)); @@ -1074,19 +1081,19 @@ public static MethodInfo[] GetMethodsIncludeBaseTypes(this Type type, BindingFla ConcurrentListPool.Release(methodInfos); return array; } - + public static MemberInfo[] GetMembersIncludeBaseTypes(this Type type, BindingFlags flags) { var memberInfos = ConcurrentListPool.Get(); var typesToCheck = ConcurrentListPool.Get(); var targetType = type; - + while (targetType.EqualsNone(typeof(MonoBehaviour), typeof(ScriptableObject), typeof(object))) { typesToCheck.Add(targetType); targetType = targetType?.BaseType; } - + for (var i = typesToCheck.Count - 1; i >= 0; i--) { memberInfos.AddRange(typesToCheck[i].GetMembers(flags)); @@ -1097,18 +1104,18 @@ public static MemberInfo[] GetMembersIncludeBaseTypes(this Type type, BindingFla ConcurrentListPool.Release(memberInfos); return array; } - - + + #endregion #region --- Helper --- - + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool EqualsNone(this T target, T otherA, T otherB, T otherC) where T : class { return !(target.Equals(otherA) || target.Equals(otherB) || target.Equals(otherC)); } - + #endregion } } diff --git a/Assets/Baracuda/Utilities/Extensions/TypeExtensions.cs b/Assets/Baracuda/Utilities/Extensions/TypeExtensions.cs index 5a2141e6..ee976448 100644 --- a/Assets/Baracuda/Utilities/Extensions/TypeExtensions.cs +++ b/Assets/Baracuda/Utilities/Extensions/TypeExtensions.cs @@ -11,12 +11,12 @@ namespace Baracuda.Utilities.Extensions public static class TypeExtensions { #region --- Type Data --- - - + + /* - * Number Sets + * Number Sets */ - + private static readonly HashSet numericTypes = new HashSet { typeof(byte), @@ -54,7 +54,7 @@ public static class TypeExtensions #endregion #region --- Type Checks --- - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsNumeric(this Type type) { @@ -78,7 +78,7 @@ public static bool IsInt32(this Type type) { return type == typeof(int); } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsInt64(this Type type) { @@ -96,13 +96,13 @@ public static bool IsDouble(this Type type) { return type == typeof(float); } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsString(this Type type) { return type == typeof(string); } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsStruct(this Type type) { @@ -168,11 +168,11 @@ public static bool IsGenericIEnumerable(this Type type, bool excludeStrings = fa return false; } - if (type.IsInterface && type.GetGenericTypeDefinition() == typeof(IEnumerable<>)) + if (type.IsGenericType && type.IsInterface && type.GetGenericTypeDefinition() == typeof(IEnumerable<>)) { return true; } - + for (var i = 0; i < type.GetInterfaces().Length; i++) { var interfaceType = type.GetInterfaces()[i]; @@ -184,7 +184,7 @@ public static bool IsGenericIEnumerable(this Type type, bool excludeStrings = fa return false; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static object GetDefault(this Type type) { @@ -194,11 +194,11 @@ public static object GetDefault(this Type type) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsGenericIDictionary(this Type type) { - if (type.IsInterface && type.GetGenericTypeDefinition() == typeof(IDictionary<,>)) + if (type.IsInterface && type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IDictionary<,>)) { return true; } - + for (var i = 0; i < type.GetInterfaces().Length; i++) { var interfaceType = type.GetInterfaces()[i]; @@ -215,13 +215,13 @@ public static bool IsGenericIDictionary(this Type type) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsGenericIList(this Type type) { - if (type.IsInterface && type.GetGenericTypeDefinition() == typeof(IList<>)) + if (type.IsInterface && type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IList<>)) { return true; } - + var interfaces = type.GetInterfaces(); - + for (var i = 0; i < interfaces.Length; i++) { var @interface = interfaces[i]; @@ -230,17 +230,17 @@ public static bool IsGenericIList(this Type type) return true; } } - + return false; } - + /// - /// Returns ture if the type and all of its declaring types are public. + /// Returns ture if the type and all of its declaring types are public. /// public static bool IsAccessible(this Type type) { var baseTypes = type.GetDeclaringTypes(true); - + for (var i = 0; i < baseTypes.Length; i++) { var baseType = baseTypes[i]; @@ -252,13 +252,13 @@ public static bool IsAccessible(this Type type) return true; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasReturnValue(this MethodInfo methodInfo) { return methodInfo.ReturnType != typeof(void); } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasReturnValueOrOutParameter(this MethodInfo methodInfo) { @@ -280,9 +280,9 @@ public static Type NotVoid(this Type type, Type replacement) } /* - * Unity Types + * Unity Types */ - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsVector(this Type type) { @@ -302,9 +302,9 @@ public static bool IsColor(this Type type) } /* - * Generics & Delegates + * Generics & Delegates */ - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsDelegate(this Type type) {