From be39dcf8d87ceda920ad201166e9e90f74eb426c Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:58:57 +0800 Subject: [PATCH] add summary to AutoToString --- src/Debug/EcsDebugUtility.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Debug/EcsDebugUtility.cs b/src/Debug/EcsDebugUtility.cs index 7318e88..473bd72 100644 --- a/src/Debug/EcsDebugUtility.cs +++ b/src/Debug/EcsDebugUtility.cs @@ -40,17 +40,18 @@ namespace DCFApixels.DragonECS #endregion #region AutoToString + /// slow but automatic conversion of ValueType to string in the format "name(field1, field2... fieldn)" public static string AutoToString(this T self, bool isWriteName = true) where T : struct { return AutoToString(self, typeof(T), isWriteName); } - private static string AutoToString(object target, Type type, bool isWriteName) + private static string AutoToString(object target, Type type, bool isWriteName) { var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); string[] values = new string[fields.Length]; for (int i = 0; i < fields.Length; i++) values[i] = fields[i].GetValue(target).ToString(); - if(isWriteName) + if (isWriteName) return $"{type.Name}({string.Join(", ", values)})"; else return $"({string.Join(", ", values)})";