From df2474bc87a8c3ce2ce198c77b501e90b74c0cb2 Mon Sep 17 00:00:00 2001 From: srkizer Date: Tue, 10 Oct 2023 00:37:16 +0900 Subject: [PATCH] Disable Utils.Show... from attempting to display Spans (#1467) --- Dalamud/Utility/Util.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Dalamud/Utility/Util.cs b/Dalamud/Utility/Util.cs index d5f59a06e..fb6c854a1 100644 --- a/Dalamud/Utility/Util.cs +++ b/Dalamud/Utility/Util.cs @@ -29,6 +29,7 @@ namespace Dalamud.Utility; /// public static class Util { + private static readonly Type GenericSpanType = typeof(Span<>); private static string? gitHashInternal; private static int? gitCommitCountInternal; private static string? gitHashClientStructsInternal; @@ -296,7 +297,10 @@ public static class Util ImGui.TextColored(new Vector4(0.2f, 0.9f, 0.4f, 1), $"{f.Name}: "); ImGui.SameLine(); - ShowValue(addr, new List(path) {f.Name}, f.FieldType, f.GetValue(obj)); + if (f.FieldType.IsGenericType && f.FieldType.GetGenericTypeDefinition() == GenericSpanType) + ImGui.Text("Span preview is currently not supported."); + else + ShowValue(addr, new List(path) {f.Name}, f.FieldType, f.GetValue(obj)); } foreach (var p in obj.GetType().GetProperties().Where(p => p.GetGetMethod()?.GetParameters().Length == 0)) @@ -306,7 +310,10 @@ public static class Util ImGui.TextColored(new Vector4(0.2f, 0.6f, 0.4f, 1), $"{p.Name}: "); ImGui.SameLine(); - ShowValue(addr, new List(path) {p.Name}, p.PropertyType, p.GetValue(obj)); + if (p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == GenericSpanType) + ImGui.Text("Span preview is currently not supported."); + else + ShowValue(addr, new List(path) {p.Name}, p.PropertyType, p.GetValue(obj)); } ImGui.TreePop(); @@ -369,6 +376,13 @@ public static class Util foreach (var propertyInfo in type.GetProperties().Where(p => p.GetGetMethod()?.GetParameters().Length == 0)) { + if (propertyInfo.PropertyType.IsGenericType && + propertyInfo.PropertyType.GetGenericTypeDefinition() == GenericSpanType) + { + ImGui.TextColored(ImGuiColors.DalamudOrange, $" {propertyInfo.Name}: Span preview is currently not supported."); + continue; + } + var value = propertyInfo.GetValue(obj); var valueType = value?.GetType(); if (valueType == typeof(IntPtr))