Browse Source

Show the token-kind byte in the metadata-table tab header

The tree node's text leads with the table's token-kind byte (e.g.
"02 TypeDef (1234)"), but the opened tab's title dropped it and showed
just "TypeDef (1234)". Lead the tab title with the same byte so the two
match.

Assisted-by: Claude:claude-opus-4-8:Claude Code
pull/3755/head
Siegfried Pammer 1 month ago
parent
commit
a6ad988947
  1. 2
      ILSpy.Tests/Metadata/MetadataTokenNavigationTests.cs
  2. 8
      ILSpy.Tests/Metadata/TypedMetadataTableTreeTests.cs
  3. 4
      ILSpy/Metadata/MetadataTableTreeNode.cs

2
ILSpy.Tests/Metadata/MetadataTokenNavigationTests.cs

@ -75,7 +75,7 @@ public class MetadataTokenNavigationTests
// and a fresh metadata page is showing. // and a fresh metadata page is showing.
var factory = (global::ILSpy.Docking.ILSpyDockFactory)vm.DockWorkspace.Factory; var factory = (global::ILSpy.Docking.ILSpyDockFactory)vm.DockWorkspace.Factory;
var landed = (MetadataTablePageModel)factory.MainTab!.Content!; var landed = (MetadataTablePageModel)factory.MainTab!.Content!;
landed.Title.Should().StartWith(expectedTableIndex.ToString()); landed.Title.Should().Contain(expectedTableIndex.ToString()); // title leads with the kind byte
landed.Items.Should().HaveCountGreaterThan((int)(expectedRowNumber - 1), landed.Items.Should().HaveCountGreaterThan((int)(expectedRowNumber - 1),
"the target row index must be in range for the destination table"); "the target row index must be in range for the destination table");
} }

8
ILSpy.Tests/Metadata/TypedMetadataTableTreeTests.cs

@ -57,7 +57,7 @@ public class TypedMetadataTableTreeTests
var tab = await vm.DockWorkspace.WaitForMetadataTabAsync(); var tab = await vm.DockWorkspace.WaitForMetadataTabAsync();
TestCapture.Step("assemblyref-grid"); TestCapture.Step("assemblyref-grid");
tab.Title.Should().StartWith("AssemblyRef"); tab.Title.Should().Contain("AssemblyRef"); // title now leads with the token-kind byte
tab.Items.Should().HaveCount(assemblyRefNode.RowCount); tab.Items.Should().HaveCount(assemblyRefNode.RowCount);
var names = tab.Items.Cast<AssemblyRefTableTreeNode.AssemblyRefEntry>() var names = tab.Items.Cast<AssemblyRefTableTreeNode.AssemblyRefEntry>()
.Select(e => e.Name) .Select(e => e.Name)
@ -82,7 +82,7 @@ public class TypedMetadataTableTreeTests
var tab = await vm.DockWorkspace.WaitForMetadataTabAsync(); var tab = await vm.DockWorkspace.WaitForMetadataTabAsync();
TestCapture.Step("typedef-grid"); TestCapture.Step("typedef-grid");
tab.Title.Should().StartWith("TypeDef"); tab.Title.Should().Contain("TypeDef"); // title now leads with the token-kind byte
tab.Items.Cast<TypeDefTableTreeNode.TypeDefEntry>() tab.Items.Cast<TypeDefTableTreeNode.TypeDefEntry>()
.Should().Contain(e => e.Name == "Object"); .Should().Contain(e => e.Name == "Object");
} }
@ -112,7 +112,7 @@ public class TypedMetadataTableTreeTests
vm.AssemblyTreeModel.SelectNode(methodNode); vm.AssemblyTreeModel.SelectNode(methodNode);
var tab = await vm.DockWorkspace.WaitForMetadataTabAsync(); var tab = await vm.DockWorkspace.WaitForMetadataTabAsync();
TestCapture.Step("methoddef-grid"); TestCapture.Step("methoddef-grid");
tab.Title.Should().StartWith("MethodDef"); tab.Title.Should().Contain("MethodDef"); // title now leads with the token-kind byte
tab.Columns.Select(c => c.Tag).Should().Contain("RID"); tab.Columns.Select(c => c.Tag).Should().Contain("RID");
} }
@ -132,7 +132,7 @@ public class TypedMetadataTableTreeTests
var tab = await vm.DockWorkspace.WaitForMetadataTabAsync(); var tab = await vm.DockWorkspace.WaitForMetadataTabAsync();
TestCapture.Step("module-grid"); TestCapture.Step("module-grid");
tab.Title.Should().StartWith("Module"); tab.Title.Should().Contain("Module"); // title now leads with the token-kind byte
tab.Items.Should().HaveCount(1); tab.Items.Should().HaveCount(1);
var row = (ModuleTableTreeNode.ModuleEntry)tab.Items[0]; var row = (ModuleTableTreeNode.ModuleEntry)tab.Items[0];
row.Name.Should().EndWith(".dll"); row.Name.Should().EndWith(".dll");

4
ILSpy/Metadata/MetadataTableTreeNode.cs

@ -82,7 +82,9 @@ namespace ILSpy.Metadata
// + ReflectionHelper.GetNestedPropertyValue, which return null for every row when // + ReflectionHelper.GetNestedPropertyValue, which return null for every row when
// the source's element type is object. // the source's element type is object.
var page = new MetadataTablePageModel { var page = new MetadataTablePageModel {
Title = $"{Kind} ({RowCount})", // Lead with the token-kind byte, mirroring the tree node's Text so the tab header
// reads e.g. "02 TypeDef (1234)".
Title = $"{(byte)Kind:X2} {Kind} ({RowCount})",
Items = cached ??= LoadTable(), Items = cached ??= LoadTable(),
}; };
MetadataColumnBuilder.Populate<TEntry>(page); MetadataColumnBuilder.Populate<TEntry>(page);

Loading…
Cancel
Save