From 740b39fd9be10803dc7ef6ed40d4e6cf29096215 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Thu, 18 Dec 2025 16:48:21 +1000 Subject: [PATCH] debugger - trim class namespaces --- ...eadsVariablesSubTab.DebuggerVariableCustomDraw.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs index c757397..c5342c0 100644 --- a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs +++ b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs @@ -65,7 +65,17 @@ public partial class ThreadsVariablesSubTab var variableTypeDrawnSize = font.GetStringSize(variableTypeDisplayString, HorizontalAlignment.Left, -1, fontSize).X; currentX += variableTypeDrawnSize + padding; } - var variableValueDisplayString = isObjectType ? variable.Type : variable.Value; + var variableValueDisplayString = isObjectType ? GetObjectNameWithoutNamespace(variable.Type) : variable.Value; _variablesTree.DrawString(font, new Vector2(currentX, textYPos), variableValueDisplayString, HorizontalAlignment.Left, -1, fontSize, variableValueDisplayColour); } + + private static string GetObjectNameWithoutNamespace(string fullTypeName) + { + // System.Collections.Generic.List => List + var span = fullTypeName.AsSpan(); + var firstGenericBracketIndex = span.IndexOf('<'); // returns -1 if not found + var slice = firstGenericBracketIndex is -1 ? span : span[..firstGenericBracketIndex]; + var lastDotIndex = slice.LastIndexOf('.'); + return lastDotIndex is -1 ? fullTypeName : span[(lastDotIndex + 1)..].ToString(); + } } \ No newline at end of file