From cb12ab93723109ecc3c7da5cc5e58e78da1e7dab Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 26 Apr 2026 17:06:46 +0200 Subject: [PATCH] Persist + restore the selected tree node across launches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SessionSettings gains an ActiveTreeViewPath (string array) saved every time AssemblyTreeModel.SelectedItem changes and consulted on the next launch when the assembly list root is built. To make the path stable across language switches, each tree node overrides ToString to return a language-independent identifier — file path for assemblies, ITypeDefinition. ReflectionName for types, and IL-formatted entity strings for members, matching the WPF host's scheme. Assisted-by: Claude:claude-opus-4-7:Claude Code --- ILSpy.Tests/SessionSettingsTests.cs | 15 ++++ ILSpy/AssemblyTree/AssemblyListPane.axaml | 3 +- ILSpy/AssemblyTree/AssemblyListPane.axaml.cs | 77 +++++++++++++++++++- ILSpy/AssemblyTree/AssemblyTreeModel.cs | 55 ++++++++++++++ ILSpy/SessionSettings.cs | 10 +++ ILSpy/TreeNodes/AssemblyTreeNode.cs | 4 + ILSpy/TreeNodes/EventTreeNode.cs | 2 + ILSpy/TreeNodes/FieldTreeNode.cs | 2 + ILSpy/TreeNodes/MethodTreeNode.cs | 10 +++ ILSpy/TreeNodes/PropertyTreeNode.cs | 9 +++ ILSpy/TreeNodes/TypeTreeNode.cs | 8 ++ 11 files changed, 193 insertions(+), 2 deletions(-) diff --git a/ILSpy.Tests/SessionSettingsTests.cs b/ILSpy.Tests/SessionSettingsTests.cs index 45f7a26b6..94ee26235 100644 --- a/ILSpy.Tests/SessionSettingsTests.cs +++ b/ILSpy.Tests/SessionSettingsTests.cs @@ -54,4 +54,19 @@ public class SessionSettingsTests loaded.WindowPosition.Should().Be(new PixelPoint(200, 300)); loaded.WindowSize.Should().Be(new Size(1024, 768)); } + + [Test] + public void Save_then_Load_round_trips_ActiveTreeViewPath() + { + var original = new SessionSettings { + ActiveTreeViewPath = ["My.Assembly.dll", "MyNamespace.MyType", "M:MyMethod"], + }; + + var xml = original.SaveToXml(); + + var loaded = new SessionSettings(); + loaded.LoadFromXml(xml); + + loaded.ActiveTreeViewPath.Should().Equal("My.Assembly.dll", "MyNamespace.MyType", "M:MyMethod"); + } } diff --git a/ILSpy/AssemblyTree/AssemblyListPane.axaml b/ILSpy/AssemblyTree/AssemblyListPane.axaml index 64c9e6fd8..c0788f71c 100644 --- a/ILSpy/AssemblyTree/AssemblyListPane.axaml +++ b/ILSpy/AssemblyTree/AssemblyListPane.axaml @@ -15,7 +15,8 @@ GridLinesVisibility="None" IsReadOnly="True" CanUserResizeColumns="False" - SelectionMode="Single"> + SelectionMode="Single" + SelectionChanged="OnTreeGridSelectionChanged">