Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 4f0553d

Browse files
committed
Remove formatting from ToStringUtility
1 parent 9f0f7f9 commit 4f0553d

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/Core/Utility/ToStringUtility.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace UnityExplorer
1313
public static class ToStringUtility
1414
{
1515
internal static Dictionary<string, MethodInfo> toStringMethods = new Dictionary<string, MethodInfo>();
16-
internal static Dictionary<string, MethodInfo> toStringFormattedMethods = new Dictionary<string, MethodInfo>();
1716

1817
private const string nullString = "<color=grey>null</color>";
1918
private const string nullUnknown = nullString + " (?)";
@@ -132,22 +131,12 @@ private static string ToString(object value)
132131

133132
var type = value.GetActualType();
134133

135-
// Find and cache the relevant ToString method for this Type, if haven't already.
134+
// Find and cache the ToString method for this Type, if haven't already.
136135

137136
if (!toStringMethods.ContainsKey(type.AssemblyQualifiedName))
138137
{
139-
try
140-
{
141-
var formatMethod = type.GetMethod("ToString", ArgumentUtility.ParseArgs);
142-
formatMethod.Invoke(value, new object[] { ParseUtility.NUMBER_FORMAT });
143-
toStringFormattedMethods.Add(type.AssemblyQualifiedName, formatMethod);
144-
toStringMethods.Add(type.AssemblyQualifiedName, null);
145-
}
146-
catch
147-
{
148-
var toStringMethod = type.GetMethod("ToString", ArgumentUtility.EmptyTypes);
149-
toStringMethods.Add(type.AssemblyQualifiedName, toStringMethod);
150-
}
138+
var toStringMethod = type.GetMethod("ToString", ArgumentUtility.EmptyTypes);
139+
toStringMethods.Add(type.AssemblyQualifiedName, toStringMethod);
151140
}
152141

153142
// Invoke the ToString method on the object
@@ -157,10 +146,7 @@ private static string ToString(object value)
157146
string toString;
158147
try
159148
{
160-
if (toStringFormattedMethods.TryGetValue(type.AssemblyQualifiedName, out MethodInfo formatMethod))
161-
toString = (string)formatMethod.Invoke(value, new object[] { ParseUtility.NUMBER_FORMAT });
162-
else
163-
toString = (string)toStringMethods[type.AssemblyQualifiedName].Invoke(value, ArgumentUtility.EmptyArgs);
149+
toString = (string)toStringMethods[type.AssemblyQualifiedName].Invoke(value, ArgumentUtility.EmptyArgs);
164150
}
165151
catch (Exception ex)
166152
{

0 commit comments

Comments
 (0)