update debug utils

This commit is contained in:
Mikhail 2024-09-13 11:03:51 +08:00
parent de2a0d43ac
commit 12e58ef273
2 changed files with 17 additions and 3 deletions

View File

@ -1,5 +1,6 @@
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
@ -134,6 +135,19 @@ namespace DCFApixels.DragonECS
}
}
protected static string AutoConvertObjectToString(object o)
{
if (o is string str)
{
return str;
}
if (o is IEnumerable enumerable)
{
return string.Join(", ", enumerable.Cast<object>());
}
return o.ToString();
}
public readonly struct MarkerInfo
{
public readonly string Name;
@ -281,7 +295,7 @@ namespace DCFApixels.DragonECS
{
if (string.IsNullOrEmpty(tag))
{
Console.WriteLine(v);
Console.WriteLine(AutoConvertObjectToString(v));
}
else
{
@ -298,7 +312,7 @@ namespace DCFApixels.DragonECS
Console.ForegroundColor = ConsoleColor.Green;
break;
}
Console.WriteLine($"[{tag}] {v}");
Console.WriteLine($"[{tag}] {AutoConvertObjectToString(v)}");
Console.ForegroundColor = color;
}
}

View File

@ -66,7 +66,7 @@ namespace DCFApixels.DragonECS
return AutoToString(self, typeof(T), isWriteName);
}
private static string AutoToString(object target, Type type, bool isWriteName)
internal static string AutoToString(object target, Type type, bool isWriteName)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#pragma warning disable IL2070 // 'this' argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The parameter of method does not have matching annotations.