From 4f0553d293bb6723919fed7e7647f316e4128618 Mon Sep 17 00:00:00 2001 From: Sinai Date: Sun, 23 May 2021 19:34:32 +1000 Subject: [PATCH] Remove formatting from ToStringUtility --- src/Core/Utility/ToStringUtility.cs | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Core/Utility/ToStringUtility.cs b/src/Core/Utility/ToStringUtility.cs index 971504d..67be482 100644 --- a/src/Core/Utility/ToStringUtility.cs +++ b/src/Core/Utility/ToStringUtility.cs @@ -13,7 +13,6 @@ namespace UnityExplorer public static class ToStringUtility { internal static Dictionary toStringMethods = new Dictionary(); - internal static Dictionary toStringFormattedMethods = new Dictionary(); private const string nullString = "null"; private const string nullUnknown = nullString + " (?)"; @@ -132,22 +131,12 @@ namespace UnityExplorer var type = value.GetActualType(); - // Find and cache the relevant ToString method for this Type, if haven't already. + // Find and cache the ToString method for this Type, if haven't already. if (!toStringMethods.ContainsKey(type.AssemblyQualifiedName)) { - try - { - var formatMethod = type.GetMethod("ToString", ArgumentUtility.ParseArgs); - formatMethod.Invoke(value, new object[] { ParseUtility.NUMBER_FORMAT }); - toStringFormattedMethods.Add(type.AssemblyQualifiedName, formatMethod); - toStringMethods.Add(type.AssemblyQualifiedName, null); - } - catch - { - var toStringMethod = type.GetMethod("ToString", ArgumentUtility.EmptyTypes); - toStringMethods.Add(type.AssemblyQualifiedName, toStringMethod); - } + var toStringMethod = type.GetMethod("ToString", ArgumentUtility.EmptyTypes); + toStringMethods.Add(type.AssemblyQualifiedName, toStringMethod); } // Invoke the ToString method on the object @@ -157,10 +146,7 @@ namespace UnityExplorer string toString; try { - if (toStringFormattedMethods.TryGetValue(type.AssemblyQualifiedName, out MethodInfo formatMethod)) - toString = (string)formatMethod.Invoke(value, new object[] { ParseUtility.NUMBER_FORMAT }); - else - toString = (string)toStringMethods[type.AssemblyQualifiedName].Invoke(value, ArgumentUtility.EmptyArgs); + toString = (string)toStringMethods[type.AssemblyQualifiedName].Invoke(value, ArgumentUtility.EmptyArgs); } catch (Exception ex) {