Skip to content

Commit

Permalink
Fix #3118: Add "Clear assembly list" menu item.
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Dec 12, 2023
1 parent 1ab0350 commit 84c5e63
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
11 changes: 10 additions & 1 deletion ICSharpCode.ILSpyX/AssemblyList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -395,6 +394,16 @@ public void Unload(LoadedAssembly assembly)
}
}

public void Clear()
{
VerifyAccess();
lock (lockObj)
{
dirty = true;
assemblies.Clear();
byFilename.Clear();
}
}
public void Sort(IComparer<LoadedAssembly> comparer)
{
Sort(0, int.MaxValue, comparer);
Expand Down
16 changes: 14 additions & 2 deletions ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Linq;

using ICSharpCode.ILSpy.Properties;
Expand All @@ -44,4 +42,18 @@ public override void Execute(object parameter)
}
}
}

[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.ClearAssemblyList), MenuCategory = nameof(Resources.Remove), MenuOrder = 2.6)]
class ClearAssemblyList : SimpleCommand
{
public override bool CanExecute(object parameter)
{
return MainWindow.Instance.CurrentAssemblyList?.Count > 0;
}

public override void Execute(object parameter)
{
MainWindow.Instance.CurrentAssemblyList?.Clear();
}
}
}
9 changes: 9 additions & 0 deletions ILSpy/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ILSpy/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ Are you sure you want to continue?</value>
<data name="Checking" xml:space="preserve">
<value>Checking...</value>
</data>
<data name="ClearAssemblyList" xml:space="preserve">
<value>Clear assembly list</value>
</data>
<data name="Close" xml:space="preserve">
<value>Close</value>
</data>
Expand Down

0 comments on commit 84c5e63

Please sign in to comment.