Update JsonDebugger.cs

This commit is contained in:
Mikhail 2026-04-08 15:01:46 +08:00
parent 04ba0a3549
commit 8042256c61

View File

@ -130,8 +130,14 @@ namespace DCFApixels.DragonECS.Core.Internal
sb.Append('"'); sb.Append('"');
return; return;
} }
if (value is Type || if (value is Type t)
type.Namespace == typeof(FieldInfo).Namespace || {
sb.Append('"');
sb.Append(t.GetMeta().TypeName);
sb.Append('"');
return;
}
if (type.Namespace == typeof(FieldInfo).Namespace ||
type.IsPointer || type.IsPointer ||
type.IsFunctionPointer || type.IsFunctionPointer ||
type.IsUnmanagedFunctionPointer) type.IsUnmanagedFunctionPointer)
@ -198,8 +204,6 @@ namespace DCFApixels.DragonECS.Core.Internal
foreach (object item in enumerable) foreach (object item in enumerable)
{ {
if (!first) { sb.Append(','); } else { first = false; } if (!first) { sb.Append(','); } else { first = false; }
// Перенос строки и отступ перед элементом
NewLine(ref linesCounter, sb, indent + 1, indentStep); NewLine(ref linesCounter, sb, indent + 1, indentStep);
ToJsonLog(ref linesCounter, item, sb, visited, indent + 1, indentStep); ToJsonLog(ref linesCounter, item, sb, visited, indent + 1, indentStep);
} }
@ -214,18 +218,18 @@ namespace DCFApixels.DragonECS.Core.Internal
else // Object else // Object
{ {
sb.Append('{'); sb.Append('{');
bool first = true; {
NewLine(ref linesCounter, sb, indent + 1, indentStep);
sb.Append("\"Type\": ");
ToJsonLog(ref linesCounter, type, sb, visited, indent + 1, indentStep);
}
// Fields // Fields
var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (var field in fields) foreach (var field in fields)
{ {
if (field.IsStatic) if (field.IsStatic) { continue; }
{
continue;
}
if (!first) { sb.Append(','); } else { first = false; }
NewLine(ref linesCounter, sb, indent + 1, indentStep); NewLine(ref linesCounter, sb, indent + 1, indentStep);
sb.Append('"'); sb.Append('"');
@ -248,8 +252,6 @@ namespace DCFApixels.DragonECS.Core.Internal
continue; continue;
} }
if (!first) { sb.Append(','); } else { first = false; }
NewLine(ref linesCounter, sb, indent + 1, indentStep); NewLine(ref linesCounter, sb, indent + 1, indentStep);
sb.Append('"'); sb.Append('"');
sb.Append(prop.Name); sb.Append(prop.Name);
@ -268,11 +270,7 @@ namespace DCFApixels.DragonECS.Core.Internal
ToJsonLog(ref linesCounter, propValue, sb, visited, indent + 1, indentStep); ToJsonLog(ref linesCounter, propValue, sb, visited, indent + 1, indentStep);
} }
// перенос строки если были элементы NewLine(ref linesCounter, sb, indent, indentStep);
if (!first)
{
NewLine(ref linesCounter, sb, indent, indentStep);
}
sb.Append('}'); sb.Append('}');
} }