diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index 12cdd08ad..61969f366 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -348,7 +348,14 @@ namespace ICSharpCode.ILSpy HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments); if (App.CommandLineArguments.NavigateTo == null && App.CommandLineArguments.AssembliesToLoad.Count != 1) { - SharpTreeNode node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true); + SharpTreeNode node = null; + if (sessionSettings.ActiveTreeViewPath != null) { + node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true); + if (node == this.assemblyListTreeNode & sessionSettings.ActiveAutoLoadedAssembly != null) { + this.assemblyList.OpenAssembly(sessionSettings.ActiveAutoLoadedAssembly, true); + node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true); + } + } if (node != null) { SelectNode(node); @@ -793,6 +800,7 @@ namespace ICSharpCode.ILSpy base.OnClosing(e); sessionSettings.ActiveAssemblyList = assemblyList.ListName; sessionSettings.ActiveTreeViewPath = GetPathForNode(treeView.SelectedItem as SharpTreeNode); + sessionSettings.ActiveAutoLoadedAssembly = GetAutoLoadedAssemblyNode(treeView.SelectedItem as SharpTreeNode); sessionSettings.WindowBounds = this.RestoreBounds; sessionSettings.SplitterPosition = leftColumn.Width.Value / (leftColumn.Width.Value + rightColumn.Width.Value); if (topPane.Visibility == Visibility.Visible) @@ -801,6 +809,22 @@ namespace ICSharpCode.ILSpy sessionSettings.BottomPaneSplitterPosition = bottomPaneRow.Height.Value / (bottomPaneRow.Height.Value + textViewRow.Height.Value); sessionSettings.Save(); } + + private string GetAutoLoadedAssemblyNode(SharpTreeNode node) + { + if (node == null) + return null; + while (!(node is TreeNodes.AssemblyTreeNode) && node.Parent != null) { + node = node.Parent; + } + //this should be an assembly node + var assyNode = node as TreeNodes.AssemblyTreeNode; + var loadedAssy = assyNode.LoadedAssembly; + if (!(loadedAssy.IsLoaded && loadedAssy.IsAutoLoaded)) + return null; + + return loadedAssy.FileName; + } #region Top/Bottom Pane management public void ShowInTopPane(string title, object content) diff --git a/ILSpy/SessionSettings.cs b/ILSpy/SessionSettings.cs index 9c9167114..56a4490dd 100644 --- a/ILSpy/SessionSettings.cs +++ b/ILSpy/SessionSettings.cs @@ -48,6 +48,7 @@ namespace ICSharpCode.ILSpy if (activeTreeViewPath != null) { this.ActiveTreeViewPath = activeTreeViewPath.Elements().Select(e => Unescape((string)e)).ToArray(); } + this.ActiveAutoLoadedAssembly = (string)doc.Element("ActiveAutoLoadedAssembly"); this.WindowState = FromString((string)doc.Element("WindowState"), WindowState.Normal); this.WindowBounds = FromString((string)doc.Element("WindowBounds"), DefaultWindowBounds); @@ -67,6 +68,7 @@ namespace ICSharpCode.ILSpy public FilterSettings FilterSettings { get; private set; } public string[] ActiveTreeViewPath; + public string ActiveAutoLoadedAssembly; public string ActiveAssemblyList; @@ -89,6 +91,9 @@ namespace ICSharpCode.ILSpy if (this.ActiveTreeViewPath != null) { doc.Add(new XElement("ActiveTreeViewPath", ActiveTreeViewPath.Select(p => new XElement("Node", Escape(p))))); } + if (this.ActiveAutoLoadedAssembly != null) { + doc.Add(new XElement("ActiveAutoLoadedAssembly", this.ActiveAutoLoadedAssembly)); + } doc.Add(new XElement("WindowState", ToString(this.WindowState))); doc.Add(new XElement("WindowBounds", ToString(this.WindowBounds))); doc.Add(new XElement("SplitterPosition", ToString(this.SplitterPosition)));