-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Refactor for cross platform port (#3641) #3642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
a0f38ad
c1178a2
a1a89b1
da9b0ef
2ce2851
168eebe
62dc40b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |||||||||||||||||||
| // DEALINGS IN THE SOFTWARE. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| using System; | ||||||||||||||||||||
| using System.Collections; | ||||||||||||||||||||
| using System.Collections.Generic; | ||||||||||||||||||||
| using System.Collections.Specialized; | ||||||||||||||||||||
| using System.Diagnostics; | ||||||||||||||||||||
|
|
@@ -29,7 +30,7 @@ namespace ICSharpCode.ILSpyX.TreeView | |||||||||||||||||||
| /// <summary> | ||||||||||||||||||||
| /// Collection that validates that inserted nodes do not have another parent. | ||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||
| public sealed class SharpTreeNodeCollection : IList<SharpTreeNode>, INotifyCollectionChanged | ||||||||||||||||||||
| public sealed class SharpTreeNodeCollection : IList<SharpTreeNode>, IList, INotifyCollectionChanged | ||||||||||||||||||||
| { | ||||||||||||||||||||
| readonly SharpTreeNode parent; | ||||||||||||||||||||
| List<SharpTreeNode> list = new List<SharpTreeNode>(); | ||||||||||||||||||||
|
|
@@ -94,6 +95,20 @@ bool ICollection<SharpTreeNode>.IsReadOnly { | |||||||||||||||||||
| get { return false; } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #region IList Members | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public bool IsFixedSize => ((IList)list).IsFixedSize; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public bool IsReadOnly => ((IList)list).IsReadOnly; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public bool IsSynchronized => ((ICollection)list).IsSynchronized; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public object SyncRoot => ((ICollection)list).SyncRoot; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| object IList.this[int index] { get => ((IList)list)[index]; set => ((IList)list)[index] = value; } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #endregion | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public int IndexOf(SharpTreeNode node) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if (node == null || node.modelParent != parent) | ||||||||||||||||||||
|
|
@@ -236,5 +251,35 @@ public void RemoveAll(Predicate<SharpTreeNode> match) | |||||||||||||||||||
| RemoveRange(firstToRemove, list.Count - firstToRemove); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public int Add(object value) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return ((IList)list).Add(value); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+255
to
+258
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| public bool Contains(object value) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return ((IList)list).Contains(value); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public int IndexOf(object value) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return ((IList)list).IndexOf(value); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public void Insert(int index, object value) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| ((IList)list).Insert(index, value); | ||||||||||||||||||||
|
||||||||||||||||||||
| ((IList)list).Insert(index, value); | |
| if (value is SharpTreeNode node) | |
| { | |
| Insert(index, node); | |
| } | |
| else | |
| { | |
| throw new ArgumentException("Value must be a SharpTreeNode.", nameof(value)); | |
| } |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IList.Remove implementation directly delegates to the underlying list without using the CollectionChanged event mechanism. This bypasses the notification logic that exists in the generic Remove method. Consider using the generic Remove method or ensuring proper event notification.
| ((IList)list).Remove(value); | |
| // Route through the generic Remove to ensure proper notification and validation. | |
| if (value == null || value is SharpTreeNode) | |
| { | |
| Remove((SharpTreeNode)value); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,7 +29,6 @@ | |||||
| using System.Reflection.Metadata.Ecma335; | ||||||
| using System.Threading.Tasks; | ||||||
| using System.Windows; | ||||||
| using System.Windows.Documents; | ||||||
| using System.Windows.Input; | ||||||
| using System.Windows.Navigation; | ||||||
| using System.Windows.Threading; | ||||||
|
|
@@ -57,7 +56,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree | |||||
| { | ||||||
| [ExportToolPane] | ||||||
| [Shared] | ||||||
| public class AssemblyTreeModel : ToolPaneModel | ||||||
| public partial class AssemblyTreeModel : ToolPaneModel | ||||||
| { | ||||||
| public const string PaneContentId = "assemblyListPane"; | ||||||
|
|
||||||
|
|
@@ -72,36 +71,6 @@ public class AssemblyTreeModel : ToolPaneModel | |||||
| private readonly LanguageService languageService; | ||||||
| private readonly IExportProvider exportProvider; | ||||||
|
|
||||||
| public AssemblyTreeModel(SettingsService settingsService, LanguageService languageService, IExportProvider exportProvider) | ||||||
| { | ||||||
| this.settingsService = settingsService; | ||||||
| this.languageService = languageService; | ||||||
| this.exportProvider = exportProvider; | ||||||
|
|
||||||
| Title = Resources.Assemblies; | ||||||
| ContentId = PaneContentId; | ||||||
| IsCloseable = false; | ||||||
| ShortcutKey = new KeyGesture(Key.F6); | ||||||
|
|
||||||
| MessageBus<NavigateToReferenceEventArgs>.Subscribers += JumpToReference; | ||||||
| MessageBus<SettingsChangedEventArgs>.Subscribers += (sender, e) => Settings_PropertyChanged(sender, e); | ||||||
| MessageBus<ApplySessionSettingsEventArgs>.Subscribers += ApplySessionSettings; | ||||||
| MessageBus<ActiveTabPageChangedEventArgs>.Subscribers += ActiveTabPageChanged; | ||||||
| MessageBus<TabPagesCollectionChangedEventArgs>.Subscribers += (_, e) => history.RemoveAll(s => !DockWorkspace.TabPages.Contains(s.TabPage)); | ||||||
| MessageBus<ResetLayoutEventArgs>.Subscribers += ResetLayout; | ||||||
| MessageBus<NavigateToEventArgs>.Subscribers += (_, e) => NavigateTo(e.Request, e.InNewTabPage); | ||||||
| MessageBus<MainWindowLoadedEventArgs>.Subscribers += (_, _) => { | ||||||
| Initialize(); | ||||||
| Show(); | ||||||
| }; | ||||||
|
|
||||||
| EventManager.RegisterClassHandler(typeof(Window), Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler((_, e) => NavigateTo(e))); | ||||||
|
|
||||||
| refreshThrottle = new(DispatcherPriority.Background, RefreshInternal); | ||||||
|
|
||||||
| AssemblyList = settingsService.CreateEmptyAssemblyList(); | ||||||
| } | ||||||
|
|
||||||
| private void Settings_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||||||
| { | ||||||
| if (sender is SessionSettings sessionSettings) | ||||||
|
|
@@ -159,6 +128,7 @@ public SharpTreeNode[] SelectedItems { | |||||
| var oldSelection = selectedItems; | ||||||
| selectedItems = value; | ||||||
| OnPropertyChanged(); | ||||||
| // TODO: OnPropertyChanged(nameof(SelectedItem)); | ||||||
|
||||||
| // TODO: OnPropertyChanged(nameof(SelectedItem)); |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO comment should be addressed or removed. If this is intentional work-in-progress, it should be tracked in an issue rather than left as an inline comment.
| // TODO: ExpandAncestors(node); | |
| // Ancestors are intentionally not expanded automatically when selecting a node. |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO comment should be addressed or removed. If this is intentional work-in-progress, it should be tracked in an issue rather than left as an inline comment.
| // TODO: (settingsService.AssemblyListManager.LoadList(AssemblyList.ListName)); |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO comment should be addressed or removed. If this represents incomplete functionality, it should be tracked in an issue or completed before merging.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // Copyright (c) 2019 AlphaSierraPapa for the SharpDevelop Team | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
| // software and associated documentation files (the "Software"), to deal in the Software | ||
| // without restriction, including without limitation the rights to use, copy, modify, merge, | ||
| // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons | ||
| // to whom the Software is furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in all copies or | ||
| // substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
| // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
| // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| // DEALINGS IN THE SOFTWARE. | ||
|
|
||
| using System; | ||
| using System.Windows; | ||
| using System.Windows.Documents; | ||
| using System.Windows.Input; | ||
| using System.Windows.Navigation; | ||
| using System.Windows.Threading; | ||
|
|
||
| using ICSharpCode.ILSpy.Properties; | ||
| using ICSharpCode.ILSpyX; | ||
|
|
||
| using TomsToolbox.Composition; | ||
|
|
||
| namespace ICSharpCode.ILSpy.AssemblyTree | ||
| { | ||
| public partial class AssemblyTreeModel | ||
| { | ||
| public AssemblyTreeModel(SettingsService settingsService, LanguageService languageService, IExportProvider exportProvider) | ||
| { | ||
| this.settingsService = settingsService; | ||
| this.languageService = languageService; | ||
| this.exportProvider = exportProvider; | ||
|
|
||
| Title = Resources.Assemblies; | ||
| ContentId = PaneContentId; | ||
| IsCloseable = false; | ||
| ShortcutKey = new KeyGesture(Key.F6); | ||
|
|
||
| MessageBus<NavigateToReferenceEventArgs>.Subscribers += JumpToReference; | ||
| MessageBus<SettingsChangedEventArgs>.Subscribers += (sender, e) => Settings_PropertyChanged(sender, e); | ||
| MessageBus<ApplySessionSettingsEventArgs>.Subscribers += ApplySessionSettings; | ||
| MessageBus<ActiveTabPageChangedEventArgs>.Subscribers += ActiveTabPageChanged; | ||
| MessageBus<TabPagesCollectionChangedEventArgs>.Subscribers += (_, e) => history.RemoveAll(s => !DockWorkspace.TabPages.Contains(s.TabPage)); | ||
| MessageBus<ResetLayoutEventArgs>.Subscribers += ResetLayout; | ||
| MessageBus<NavigateToEventArgs>.Subscribers += (_, e) => NavigateTo(e.Request, e.InNewTabPage); | ||
| MessageBus<MainWindowLoadedEventArgs>.Subscribers += (_, _) => { | ||
| Initialize(); | ||
| Show(); | ||
| }; | ||
|
|
||
| EventManager.RegisterClassHandler(typeof(Window), Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler((_, e) => NavigateTo(e))); | ||
|
|
||
| refreshThrottle = new(DispatcherPriority.Background, RefreshInternal); | ||
|
|
||
| AssemblyList = settingsService.CreateEmptyAssemblyList(); | ||
| } | ||
|
|
||
| private static void LoadInitialAssemblies(AssemblyList assemblyList) | ||
| { | ||
| // Called when loading an empty assembly list; so that | ||
| // the user can see something initially. | ||
| System.Reflection.Assembly[] initialAssemblies = { | ||
| typeof(object).Assembly, | ||
| typeof(Uri).Assembly, | ||
| typeof(System.Linq.Enumerable).Assembly, | ||
| typeof(System.Xml.XmlDocument).Assembly, | ||
| typeof(System.Windows.Markup.MarkupExtension).Assembly, | ||
| typeof(System.Windows.Rect).Assembly, | ||
| typeof(System.Windows.UIElement).Assembly, | ||
| typeof(System.Windows.FrameworkElement).Assembly | ||
| }; | ||
| foreach (System.Reflection.Assembly asm in initialAssemblies) | ||
| assemblyList.OpenAssembly(asm.Location); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IList indexer setter directly delegates to the underlying list without validation. This bypasses the parent node validation logic that exists in the typed indexer. Consider validating the node's parent before setting, similar to the generic indexer setter.