Browse Source

fix #558: Last selected assembly isn't loaded if it's an auto-loaded assembly

pull/569/head
Ed Harvey 10 years ago
parent
commit
c3a4b2a248
  1. 26
      ILSpy/MainWindow.xaml.cs
  2. 5
      ILSpy/SessionSettings.cs

26
ILSpy/MainWindow.xaml.cs

@ -348,7 +348,14 @@ namespace ICSharpCode.ILSpy
HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments); HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments);
if (App.CommandLineArguments.NavigateTo == null && App.CommandLineArguments.AssembliesToLoad.Count != 1) { 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) { if (node != null) {
SelectNode(node); SelectNode(node);
@ -793,6 +800,7 @@ namespace ICSharpCode.ILSpy
base.OnClosing(e); base.OnClosing(e);
sessionSettings.ActiveAssemblyList = assemblyList.ListName; sessionSettings.ActiveAssemblyList = assemblyList.ListName;
sessionSettings.ActiveTreeViewPath = GetPathForNode(treeView.SelectedItem as SharpTreeNode); sessionSettings.ActiveTreeViewPath = GetPathForNode(treeView.SelectedItem as SharpTreeNode);
sessionSettings.ActiveAutoLoadedAssembly = GetAutoLoadedAssemblyNode(treeView.SelectedItem as SharpTreeNode);
sessionSettings.WindowBounds = this.RestoreBounds; sessionSettings.WindowBounds = this.RestoreBounds;
sessionSettings.SplitterPosition = leftColumn.Width.Value / (leftColumn.Width.Value + rightColumn.Width.Value); sessionSettings.SplitterPosition = leftColumn.Width.Value / (leftColumn.Width.Value + rightColumn.Width.Value);
if (topPane.Visibility == Visibility.Visible) if (topPane.Visibility == Visibility.Visible)
@ -802,6 +810,22 @@ namespace ICSharpCode.ILSpy
sessionSettings.Save(); 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 #region Top/Bottom Pane management
public void ShowInTopPane(string title, object content) public void ShowInTopPane(string title, object content)
{ {

5
ILSpy/SessionSettings.cs

@ -48,6 +48,7 @@ namespace ICSharpCode.ILSpy
if (activeTreeViewPath != null) { if (activeTreeViewPath != null) {
this.ActiveTreeViewPath = activeTreeViewPath.Elements().Select(e => Unescape((string)e)).ToArray(); 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.WindowState = FromString((string)doc.Element("WindowState"), WindowState.Normal);
this.WindowBounds = FromString((string)doc.Element("WindowBounds"), DefaultWindowBounds); this.WindowBounds = FromString((string)doc.Element("WindowBounds"), DefaultWindowBounds);
@ -67,6 +68,7 @@ namespace ICSharpCode.ILSpy
public FilterSettings FilterSettings { get; private set; } public FilterSettings FilterSettings { get; private set; }
public string[] ActiveTreeViewPath; public string[] ActiveTreeViewPath;
public string ActiveAutoLoadedAssembly;
public string ActiveAssemblyList; public string ActiveAssemblyList;
@ -89,6 +91,9 @@ namespace ICSharpCode.ILSpy
if (this.ActiveTreeViewPath != null) { if (this.ActiveTreeViewPath != null) {
doc.Add(new XElement("ActiveTreeViewPath", ActiveTreeViewPath.Select(p => new XElement("Node", Escape(p))))); 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("WindowState", ToString(this.WindowState)));
doc.Add(new XElement("WindowBounds", ToString(this.WindowBounds))); doc.Add(new XElement("WindowBounds", ToString(this.WindowBounds)));
doc.Add(new XElement("SplitterPosition", ToString(this.SplitterPosition))); doc.Add(new XElement("SplitterPosition", ToString(this.SplitterPosition)));

Loading…
Cancel
Save