Skip to content

Commit a19f26a

Browse files
committed
Use GetSourceCodeRepresentation instead of FullName
1 parent 26f5114 commit a19f26a

File tree

10 files changed

+18
-17
lines changed

10 files changed

+18
-17
lines changed

RuntimeUnityEditor.Bepin5/LogViewer/LogViewerEntry.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private LogViewerEntry(object sender, LogEventArgs logEventArgs, StackFrame[] fi
4545

4646
public string GetClipboardString()
4747
{
48-
return $"{_timeString} {_logLevelString} {_sourceNameString} {_dataString}\n{FilteredStackTraceString}\nSender: {Sender} ({Sender?.GetType().FullName ?? "NULL"})";
48+
return $"{_timeString} {_logLevelString} {_sourceNameString} {_dataString}\n{FilteredStackTraceString}\nSender: {Sender} ({Sender?.GetType().GetSourceCodeRepresentation() ?? "NULL"})";
4949
}
5050

5151
public bool DrawEntry()
@@ -139,7 +139,7 @@ private static string ParseStackTrace(StackTrace st, out StackFrame[] filteredFr
139139
var frame = frames[i];
140140
var m = frame.GetMethod();
141141
var mName = m.Name;
142-
var typeName = (m.DeclaringType ?? m.ReflectedType)?.FullName ?? "???";
142+
var typeName = (m.DeclaringType ?? m.ReflectedType)?.GetSourceCodeRepresentation() ?? "???";
143143

144144
var first = false;
145145
if (!realEncountered)

RuntimeUnityEditor.Bepin5/LogViewer/LogViewerWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected override void Initialize(InitSettings initSettings)
126126

127127
string GetTrimmedTypeName(ILogSource obj)
128128
{
129-
var fullName = obj?.GetType().FullName ?? "NULL";
129+
var fullName = obj?.GetType().GetSourceCodeRepresentation() ?? "NULL";
130130
if (fullName.StartsWith("BepInEx.Logging.", StringComparison.Ordinal))
131131
fullName = fullName.Substring("BepInEx.Logging.".Length);
132132
return fullName;

RuntimeUnityEditor/Utils/ObjectDumper/Dumper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private static void InternalDump(int indentationLevel, string name, object value
7777
}
7878

7979
var isString = value is string;
80-
var typeName = value.GetType().FullName;
80+
var typeName = value.GetType().GetSourceCodeRepresentation();
8181
var stringValue = value.ToString();
8282
if (value is Exception ex)
8383
stringValue = ex.GetType().Name + ": " + ex.Message;

RuntimeUnityEditor/Utils/ReflectionUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static string GetEventDetails(UnityEventBase eventObj)
6363

6464
foreach (var kvp in mList)
6565
{
66-
sb.Append(kvp.Key.GetType().FullName);
66+
sb.Append(kvp.Key.GetType().GetSourceCodeRepresentation());
6767
// todo make this more powerful somehow, still doesn't show much, maybe with cecil?
6868
var locals = kvp.Value.GetMethodBody()?.LocalVariables.Select(x => x.ToString());
6969
if (locals != null) sb.Append(" - " + string.Join("; ", locals.ToArray()));

RuntimeUnityEditor/Utils/SceneDumper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private static void PrintRecursive(TextWriter sw, GameObject obj, int d = 0)
3232
var pad1 = new string(' ', 3 * d);
3333
var pad2 = new string(' ', 3 * (d + 1));
3434
var pad3 = new string(' ', 3 * (d + 2));
35-
sw.WriteLine(pad1 + obj.name + "--" + obj.GetType().FullName);
35+
sw.WriteLine(pad1 + obj.name + "--" + obj.GetType().GetSourceCodeRepresentation());
3636

3737
foreach (var c in obj.GetComponents<Component>())
3838
{

RuntimeUnityEditor/Utils/TomlTypeConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public static bool AddConverter(Type type, TypeConverter converter)
173173
if (converter == null) throw new ArgumentNullException(nameof(converter));
174174
if (CanConvert(type))
175175
{
176-
RuntimeUnityEditorCore.Logger.Log(LogLevel.Warning, "Tried to add a TomlConverter when one already exists for type " + type.FullName);
176+
RuntimeUnityEditorCore.Logger.Log(LogLevel.Warning, "Tried to add a TomlConverter when one already exists for type " + type.GetSourceCodeRepresentation());
177177
return false;
178178
}
179179

RuntimeUnityEditor/Windows/ChangeHistory/Change.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public static IChange Report(string actionName, Action undoAction = null)
172172
internal static string GetTargetDisplayString(object target)
173173
{
174174
if (target is UnityEngine.Object uObj && !uObj)
175-
return uObj.GetType().FullName + "(Destroyed)";
175+
return uObj.GetType().GetSourceCodeRepresentation() + "(Destroyed)";
176176

177177
switch (target)
178178
{
@@ -181,7 +181,7 @@ internal static string GetTargetDisplayString(object target)
181181
case GameObject go:
182182
return $"({go.transform.GetFullTransfromPath()})::GameObject";
183183
case Component c:
184-
return $"({c.transform.GetFullTransfromPath()})::{c.GetType().FullName}";
184+
return $"({c.transform.GetFullTransfromPath()})::{c.GetType().GetSourceCodeRepresentation()}";
185185
case string str:
186186
return str;
187187
default:

RuntimeUnityEditor/Windows/Inspector/ToStringConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private static string DelegateToString(Delegate unityAction)
9090
string str;
9191
var isNull = unityAction.Target.IsNullOrDestroyedStr();
9292
if (isNull != null) str = "[" + isNull + "]";
93-
else str = unityAction.Target.GetType().FullName;
93+
else str = unityAction.Target.GetType().GetSourceCodeRepresentation();
9494
var actionString = $"{str}.{unityAction.Method.Name}";
9595
return actionString;
9696
}
@@ -100,7 +100,7 @@ internal static string EventEntryToString(UnityEventBase eventObj, int i)
100100
if (eventObj == null) return "[NULL]";
101101
if (i < 0 || i >= eventObj.GetPersistentEventCount()) return "[Event index out of range]";
102102
// It's fine to use ? here because GetType works fine on disposed objects and we want to know the type name
103-
return $"{eventObj.GetPersistentTarget(i)?.GetType().FullName ?? "[NULL]"}.{eventObj.GetPersistentMethodName(i)}";
103+
return $"{eventObj.GetPersistentTarget(i)?.GetType().GetSourceCodeRepresentation() ?? "[NULL]"}.{eventObj.GetPersistentMethodName(i)}";
104104
}
105105

106106
private static readonly Dictionary<Type, bool> _canCovertCache = new Dictionary<Type, bool>();

RuntimeUnityEditor/Windows/ObjectTree/ObjectTreeViewer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ private void DrawSingleComponent(Component component)
376376
{
377377
var transform = component.transform;
378378
OnInspectorOpen(new InstanceStackEntry(transform, transform.name),
379-
new InstanceStackEntry(component, type.FullName));
379+
new InstanceStackEntry(component, type.GetSourceCodeRepresentation()));
380380
}
381381
}
382382

@@ -608,7 +608,7 @@ private void DisplayTreeSearchBox()
608608
.SelectMany(Extensions.GetTypesSafe)
609609
.Where(x => x.GetSourceCodeRepresentation().Contains(_searchText, StringComparison.OrdinalIgnoreCase));
610610

611-
var stackEntries = matchedTypes.Select(t => new StaticStackEntry(t, t.FullName)).ToList();
611+
var stackEntries = matchedTypes.Select(t => new StaticStackEntry(t, t.GetSourceCodeRepresentation())).ToList();
612612

613613
if (stackEntries.Count == 0)
614614
{

RuntimeUnityEditor/Windows/REPL/TypeHelper.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using RuntimeUnityEditor.Core.Utils;
2+
using System;
23
using System.Reflection;
34
using System.Text;
45

@@ -95,7 +96,7 @@ public string info()
9596
{
9697
var sb = new StringBuilder();
9798

98-
sb.AppendLine($"Info about {type.FullName}");
99+
sb.AppendLine($"Info about {type.GetSourceCodeRepresentation()}");
99100
sb.AppendLine("Methods");
100101

101102
foreach (var methodInfo in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static
@@ -110,7 +111,7 @@ public string info()
110111
{
111112
if (putComma)
112113
sb.Append(", ");
113-
sb.Append(genericArgument.FullName);
114+
sb.Append(genericArgument.GetSourceCodeRepresentation());
114115
putComma = true;
115116
}
116117

@@ -124,7 +125,7 @@ public string info()
124125
{
125126
if (putComma)
126127
sb.Append(", ");
127-
sb.Append(parameterInfo.ParameterType.FullName);
128+
sb.Append(parameterInfo.ParameterType.GetSourceCodeRepresentation());
128129
if (parameterInfo.DefaultValue != DBNull.Value)
129130
sb.Append($"= {parameterInfo.DefaultValue}");
130131
putComma = true;

0 commit comments

Comments
 (0)