Skip to content

Commit

Permalink
Add DumpMetadataInfo in MetadataTreeNode
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Dec 31, 2023
1 parent 12cbf14 commit 5dd4c2c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ILSpy/Metadata/MetadataTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ public override bool View(TabPageModel tabPage)
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, title);

DumpMetadataInfo(language, output, this.metadataFile.Metadata);
}

internal static void DumpMetadataInfo(Language language, ITextOutput output, MetadataReader metadata)
{
language.WriteCommentLine(output, "MetadataKind: " + metadata.MetadataKind);
language.WriteCommentLine(output, "MetadataVersion: " + metadata.MetadataVersion);

if (metadata.DebugMetadataHeader is { } header)
{
output.WriteLine();
language.WriteCommentLine(output, "Header:");
language.WriteCommentLine(output, "Id: " + header.Id.ToHexString(header.Id.Length));
language.WriteCommentLine(output, "EntryPoint: " + MetadataTokens.GetToken(header.EntryPoint).ToString("X8"));
}

output.WriteLine();
language.WriteCommentLine(output, "Tables:");

foreach (var table in Enum.GetValues<TableIndex>())
{
int count = metadata.GetTableRowCount(table);
if (count > 0)
{
language.WriteCommentLine(output, $"{(byte)table:X2} {table}: {count} rows");
}
}
}

protected override void LoadChildren()
Expand Down

0 comments on commit 5dd4c2c

Please sign in to comment.