Skip to content

Commit c7b2be6

Browse files
committed
Refactor for cross platform port (#3641)
1 parent 3a27cbe commit c7b2be6

File tree

73 files changed

+1045
-638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1045
-638
lines changed

ILSpy.BamlDecompiler/BamlResourceEntryNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
using ICSharpCode.AvalonEdit.Highlighting;
2626
using ICSharpCode.BamlDecompiler;
2727
using ICSharpCode.ILSpy;
28-
using ICSharpCode.ILSpy.TextView;
28+
using ICSharpCode.ILSpy.TextViewControl;
2929
using ICSharpCode.ILSpy.TreeNodes;
3030
using ICSharpCode.ILSpy.ViewModels;
3131

ILSpy/AboutPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
using ICSharpCode.AvalonEdit.Rendering;
3232
using ICSharpCode.Decompiler;
3333
using ICSharpCode.ILSpy.Properties;
34-
using ICSharpCode.ILSpy.TextView;
34+
using ICSharpCode.ILSpy.TextViewControl;
3535
using ICSharpCode.ILSpy.Themes;
3636
using ICSharpCode.ILSpy.Updates;
3737
using ICSharpCode.ILSpy.ViewModels;

ILSpy/AssemblyTree/AssemblyTreeModel.cs

Lines changed: 21 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
using System.Reflection.Metadata.Ecma335;
3030
using System.Threading.Tasks;
3131
using System.Windows;
32-
using System.Windows.Documents;
3332
using System.Windows.Input;
3433
using System.Windows.Navigation;
3534
using System.Windows.Threading;
@@ -40,7 +39,7 @@
4039
using ICSharpCode.Decompiler.TypeSystem.Implementation;
4140
using ICSharpCode.ILSpy.AppEnv;
4241
using ICSharpCode.ILSpy.Properties;
43-
using ICSharpCode.ILSpy.TextView;
42+
using ICSharpCode.ILSpy.TextViewControl;
4443
using ICSharpCode.ILSpy.TreeNodes;
4544
using ICSharpCode.ILSpy.Updates;
4645
using ICSharpCode.ILSpy.ViewModels;
@@ -57,7 +56,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree
5756
{
5857
[ExportToolPane]
5958
[Shared]
60-
public class AssemblyTreeModel : ToolPaneModel
59+
public partial class AssemblyTreeModel : ToolPaneModel
6160
{
6261
public const string PaneContentId = "assemblyListPane";
6362

@@ -72,36 +71,6 @@ public class AssemblyTreeModel : ToolPaneModel
7271
private readonly LanguageService languageService;
7372
private readonly IExportProvider exportProvider;
7473

75-
public AssemblyTreeModel(SettingsService settingsService, LanguageService languageService, IExportProvider exportProvider)
76-
{
77-
this.settingsService = settingsService;
78-
this.languageService = languageService;
79-
this.exportProvider = exportProvider;
80-
81-
Title = Resources.Assemblies;
82-
ContentId = PaneContentId;
83-
IsCloseable = false;
84-
ShortcutKey = new KeyGesture(Key.F6);
85-
86-
MessageBus<NavigateToReferenceEventArgs>.Subscribers += JumpToReference;
87-
MessageBus<SettingsChangedEventArgs>.Subscribers += (sender, e) => Settings_PropertyChanged(sender, e);
88-
MessageBus<ApplySessionSettingsEventArgs>.Subscribers += ApplySessionSettings;
89-
MessageBus<ActiveTabPageChangedEventArgs>.Subscribers += ActiveTabPageChanged;
90-
MessageBus<TabPagesCollectionChangedEventArgs>.Subscribers += (_, e) => history.RemoveAll(s => !DockWorkspace.TabPages.Contains(s.TabPage));
91-
MessageBus<ResetLayoutEventArgs>.Subscribers += ResetLayout;
92-
MessageBus<NavigateToEventArgs>.Subscribers += (_, e) => NavigateTo(e.Request, e.InNewTabPage);
93-
MessageBus<MainWindowLoadedEventArgs>.Subscribers += (_, _) => {
94-
Initialize();
95-
Show();
96-
};
97-
98-
EventManager.RegisterClassHandler(typeof(Window), Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler((_, e) => NavigateTo(e)));
99-
100-
refreshThrottle = new(DispatcherPriority.Background, RefreshInternal);
101-
102-
AssemblyList = settingsService.CreateEmptyAssemblyList();
103-
}
104-
10574
private void Settings_PropertyChanged(object? sender, PropertyChangedEventArgs e)
10675
{
10776
if (sender is SessionSettings sessionSettings)
@@ -159,6 +128,7 @@ public SharpTreeNode[] SelectedItems {
159128
var oldSelection = selectedItems;
160129
selectedItems = value;
161130
OnPropertyChanged();
131+
// TODO: OnPropertyChanged(nameof(SelectedItem));
162132
TreeView_SelectionChanged(oldSelection, selectedItems);
163133
}
164134
}
@@ -492,24 +462,6 @@ private void assemblyList_CollectionChanged(object? sender, NotifyCollectionChan
492462
MessageBus.Send(this, new CurrentAssemblyListChangedEventArgs(e));
493463
}
494464

495-
private static void LoadInitialAssemblies(AssemblyList assemblyList)
496-
{
497-
// Called when loading an empty assembly list; so that
498-
// the user can see something initially.
499-
System.Reflection.Assembly[] initialAssemblies = {
500-
typeof(object).Assembly,
501-
typeof(Uri).Assembly,
502-
typeof(System.Linq.Enumerable).Assembly,
503-
typeof(System.Xml.XmlDocument).Assembly,
504-
typeof(System.Windows.Markup.MarkupExtension).Assembly,
505-
typeof(System.Windows.Rect).Assembly,
506-
typeof(System.Windows.UIElement).Assembly,
507-
typeof(System.Windows.FrameworkElement).Assembly
508-
};
509-
foreach (System.Reflection.Assembly asm in initialAssemblies)
510-
assemblyList.OpenAssembly(asm.Location);
511-
}
512-
513465
public AssemblyTreeNode? FindAssemblyNode(LoadedAssembly asm)
514466
{
515467
return assemblyListTreeNode?.FindAssemblyNode(asm);
@@ -540,6 +492,7 @@ public void SelectNode(SharpTreeNode? node, bool inNewTabPage = false)
540492
}
541493
else
542494
{
495+
// TODO: ExpandAncestors(node);
543496
activeView?.ScrollIntoView(node);
544497
SelectedItem = node;
545498

@@ -838,7 +791,7 @@ public void DecompileSelectedNodes(ViewState? newState = null)
838791
activeTabPage.ShowTextViewAsync(textView => {
839792
return textView.DecompileAsync(this.CurrentLanguage, this.SelectedNodes, source, options);
840793
});
841-
}
794+
}
842795

843796
public void RefreshDecompiledView()
844797
{
@@ -978,12 +931,13 @@ private void RefreshInternal()
978931
{
979932
var path = GetPathForNode(SelectedItem);
980933

934+
// TODO: (settingsService.AssemblyListManager.LoadList(AssemblyList.ListName));
981935
ShowAssemblyList(settingsService.AssemblyListManager.LoadList(AssemblyList.ListName));
982936
SelectNode(FindNodeByPath(path, true), inNewTabPage: false);
983937

984938
RefreshDecompiledView();
985939
}
986-
}
940+
}
987941

988942
private void UnselectAll()
989943
{
@@ -996,13 +950,22 @@ private IEnumerable<SharpTreeNode> GetTopLevelSelection()
996950
var selectionHash = new HashSet<SharpTreeNode>(selection);
997951

998952
return selection.Where(item => item.Ancestors().All(a => !selectionHash.Contains(a)));
999-
}
1000-
1001-
public void SetActiveView(AssemblyListPane activeView)
953+
}
954+
955+
// TODO: void ExpandAncestors(SharpTreeNode node)
956+
// {
957+
// foreach (var ancestor in node.Ancestors().Reverse())
958+
// {
959+
// ancestor.EnsureLazyChildren();
960+
// ancestor.IsExpanded = true;
961+
// }
962+
// }
963+
964+
public void SetActiveView(AssemblyListPane activeView)
1002965
{
1003966
this.activeView = activeView;
1004967
}
1005-
968+
1006969
public void SortAssemblyList()
1007970
{
1008971
using (activeView?.LockUpdates())
@@ -1095,6 +1058,6 @@ private void ActiveTabPageChanged(object? sender, ActiveTabPageChangedEventArgs
10951058
private void ResetLayout(object? sender, ResetLayoutEventArgs e)
10961059
{
10971060
RefreshDecompiledView();
1098-
}
1061+
}
10991062
}
11001063
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright (c) 2019 AlphaSierraPapa for the SharpDevelop Team
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4+
// software and associated documentation files (the "Software"), to deal in the Software
5+
// without restriction, including without limitation the rights to use, copy, modify, merge,
6+
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7+
// to whom the Software is furnished to do so, subject to the following conditions:
8+
//
9+
// The above copyright notice and this permission notice shall be included in all copies or
10+
// substantial portions of the Software.
11+
//
12+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14+
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15+
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
// DEALINGS IN THE SOFTWARE.
18+
19+
using System;
20+
using System.Windows;
21+
using System.Windows.Documents;
22+
using System.Windows.Input;
23+
using System.Windows.Navigation;
24+
using System.Windows.Threading;
25+
26+
using ICSharpCode.ILSpy.Properties;
27+
using ICSharpCode.ILSpyX;
28+
29+
using TomsToolbox.Composition;
30+
31+
namespace ICSharpCode.ILSpy.AssemblyTree
32+
{
33+
public partial class AssemblyTreeModel
34+
{
35+
public AssemblyTreeModel(SettingsService settingsService, LanguageService languageService, IExportProvider exportProvider)
36+
{
37+
this.settingsService = settingsService;
38+
this.languageService = languageService;
39+
this.exportProvider = exportProvider;
40+
41+
Title = Resources.Assemblies;
42+
ContentId = PaneContentId;
43+
IsCloseable = false;
44+
ShortcutKey = new KeyGesture(Key.F6);
45+
46+
MessageBus<NavigateToReferenceEventArgs>.Subscribers += JumpToReference;
47+
MessageBus<SettingsChangedEventArgs>.Subscribers += (sender, e) => Settings_PropertyChanged(sender, e);
48+
MessageBus<ApplySessionSettingsEventArgs>.Subscribers += ApplySessionSettings;
49+
MessageBus<ActiveTabPageChangedEventArgs>.Subscribers += ActiveTabPageChanged;
50+
MessageBus<TabPagesCollectionChangedEventArgs>.Subscribers += (_, e) => history.RemoveAll(s => !DockWorkspace.TabPages.Contains(s.TabPage));
51+
MessageBus<ResetLayoutEventArgs>.Subscribers += ResetLayout;
52+
MessageBus<NavigateToEventArgs>.Subscribers += (_, e) => NavigateTo(e.Request, e.InNewTabPage);
53+
MessageBus<MainWindowLoadedEventArgs>.Subscribers += (_, _) => {
54+
Initialize();
55+
Show();
56+
};
57+
58+
EventManager.RegisterClassHandler(typeof(Window), Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler((_, e) => NavigateTo(e)));
59+
60+
refreshThrottle = new(DispatcherPriority.Background, RefreshInternal);
61+
62+
AssemblyList = settingsService.CreateEmptyAssemblyList();
63+
}
64+
65+
private static void LoadInitialAssemblies(AssemblyList assemblyList)
66+
{
67+
// Called when loading an empty assembly list; so that
68+
// the user can see something initially.
69+
System.Reflection.Assembly[] initialAssemblies = {
70+
typeof(object).Assembly,
71+
typeof(Uri).Assembly,
72+
typeof(System.Linq.Enumerable).Assembly,
73+
typeof(System.Xml.XmlDocument).Assembly,
74+
typeof(System.Windows.Markup.MarkupExtension).Assembly,
75+
typeof(System.Windows.Rect).Assembly,
76+
typeof(System.Windows.UIElement).Assembly,
77+
typeof(System.Windows.FrameworkElement).Assembly
78+
};
79+
foreach (System.Reflection.Assembly asm in initialAssemblies)
80+
assemblyList.OpenAssembly(asm.Location);
81+
}
82+
}
83+
}

ILSpy/Commands/CreateDiagramContextMenuEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
using Microsoft.Win32;
3434

35-
namespace ICSharpCode.ILSpy.TextView
35+
namespace ICSharpCode.ILSpy.TextViewControl
3636
{
3737
[ExportContextMenuEntry(Header = nameof(Resources._CreateDiagram), Category = nameof(Resources.Save), Icon = "Images/Save")]
3838
[Shared]

ILSpy/Commands/DecompileAllCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
using ICSharpCode.ILSpy.AssemblyTree;
3131
using ICSharpCode.ILSpy.Docking;
3232
using ICSharpCode.ILSpy.Properties;
33-
using ICSharpCode.ILSpy.TextView;
33+
using ICSharpCode.ILSpy.TextViewControl;
3434
using ICSharpCode.ILSpy.ViewModels;
3535
using ICSharpCode.ILSpyX;
3636

ILSpy/Commands/DisassembleAllCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
using ICSharpCode.ILSpy.AssemblyTree;
2828
using ICSharpCode.ILSpy.Docking;
2929
using ICSharpCode.ILSpy.Properties;
30-
using ICSharpCode.ILSpy.TextView;
30+
using ICSharpCode.ILSpy.TextViewControl;
3131
using ICSharpCode.ILSpy.ViewModels;
3232

3333
namespace ICSharpCode.ILSpy

ILSpy/Commands/ExtractPackageEntryContextMenuEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
using ICSharpCode.Decompiler.CSharp.ProjectDecompiler;
3030
using ICSharpCode.ILSpy.Docking;
3131
using ICSharpCode.ILSpy.Properties;
32-
using ICSharpCode.ILSpy.TextView;
32+
using ICSharpCode.ILSpy.TextViewControl;
3333
using ICSharpCode.ILSpy.TreeNodes;
3434
using ICSharpCode.ILSpyX;
3535
using ICSharpCode.ILSpyX.TreeView;

ILSpy/Commands/GeneratePdbContextMenuEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
using ICSharpCode.ILSpy.AssemblyTree;
3434
using ICSharpCode.ILSpy.Docking;
3535
using ICSharpCode.ILSpy.Properties;
36-
using ICSharpCode.ILSpy.TextView;
36+
using ICSharpCode.ILSpy.TextViewControl;
3737
using ICSharpCode.ILSpy.TreeNodes;
3838
using ICSharpCode.ILSpy.ViewModels;
3939
using ICSharpCode.ILSpyX;

ILSpy/Commands/Pdb2XmlCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
using ICSharpCode.ILSpy.AssemblyTree;
3030
using ICSharpCode.ILSpy.Docking;
3131
using ICSharpCode.ILSpy.Properties;
32-
using ICSharpCode.ILSpy.TextView;
32+
using ICSharpCode.ILSpy.TextViewControl;
3333
using ICSharpCode.ILSpy.TreeNodes;
3434

3535
using Microsoft.DiaSymReader.Tools;

0 commit comments

Comments
 (0)