Skip to content

Commit 84c5e63

Browse files
Fix #3118: Add "Clear assembly list" menu item.
1 parent 1ab0350 commit 84c5e63

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

ICSharpCode.ILSpyX/AssemblyList.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
using System.Collections.ObjectModel;
2424
using System.Collections.Specialized;
2525
using System.Diagnostics;
26-
using System.Diagnostics.CodeAnalysis;
2726
using System.IO;
2827
using System.Linq;
2928
using System.Threading;
@@ -395,6 +394,16 @@ public void Unload(LoadedAssembly assembly)
395394
}
396395
}
397396

397+
public void Clear()
398+
{
399+
VerifyAccess();
400+
lock (lockObj)
401+
{
402+
dirty = true;
403+
assemblies.Clear();
404+
byFilename.Clear();
405+
}
406+
}
398407
public void Sort(IComparer<LoadedAssembly> comparer)
399408
{
400409
Sort(0, int.MaxValue, comparer);

ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1717
// DEALINGS IN THE SOFTWARE.
1818

19-
using System;
20-
using System.Collections.Generic;
2119
using System.Linq;
2220

2321
using ICSharpCode.ILSpy.Properties;
@@ -44,4 +42,18 @@ public override void Execute(object parameter)
4442
}
4543
}
4644
}
45+
46+
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.ClearAssemblyList), MenuCategory = nameof(Resources.Remove), MenuOrder = 2.6)]
47+
class ClearAssemblyList : SimpleCommand
48+
{
49+
public override bool CanExecute(object parameter)
50+
{
51+
return MainWindow.Instance.CurrentAssemblyList?.Count > 0;
52+
}
53+
54+
public override void Execute(object parameter)
55+
{
56+
MainWindow.Instance.CurrentAssemblyList?.Clear();
57+
}
58+
}
4759
}

ILSpy/Properties/Resources.Designer.cs

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ILSpy/Properties/Resources.resx

+3
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ Are you sure you want to continue?</value>
186186
<data name="Checking" xml:space="preserve">
187187
<value>Checking...</value>
188188
</data>
189+
<data name="ClearAssemblyList" xml:space="preserve">
190+
<value>Clear assembly list</value>
191+
</data>
189192
<data name="Close" xml:space="preserve">
190193
<value>Close</value>
191194
</data>

0 commit comments

Comments
 (0)