Skip to content

Commit 2b99340

Browse files
committed
Actually fixed duplicate entries in VS2017
Switched to a hash collection to collect the file list so that we can have constant-time lookup for duplicate checking. Previous solutions were failing for various reasons.
1 parent 47dd40a commit 2b99340

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

OpenFileInSolutionPackage.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ public bool Equals(ProjectItemWrapper other)
3232
}
3333
}
3434

35+
public class ProjectItemComparer : IEqualityComparer<ProjectItemWrapper>
36+
{
37+
public bool Equals(ProjectItemWrapper x, ProjectItemWrapper y)
38+
{
39+
return x.Equals(y);
40+
}
41+
42+
public int GetHashCode(ProjectItemWrapper obj)
43+
{
44+
return obj.Filename.GetHashCode();
45+
}
46+
}
47+
3548
/// <summary>
3649
/// This is the class that implements the package exposed by this assembly.
3750
///
@@ -199,13 +212,19 @@ private IEnumerable<ProjectItemWrapper> EnumerateProjectItems(ProjectItems items
199212

200213
private void MenuItemCallback(object sender, EventArgs e)
201214
{
202-
var projItems = new List<ProjectItemWrapper>();
215+
var projItems = new Dictionary<string, ProjectItemWrapper>(StringComparer.Ordinal);
203216
foreach (var proj in GetProjects())
204217
{
205-
projItems.AddRange(EnumerateProjectItems(proj.ProjectItems));
218+
foreach (var item in EnumerateProjectItems(proj.ProjectItems))
219+
{
220+
if (!projItems.ContainsKey(item.Filename))
221+
{
222+
projItems.Add(item.Filename, item);
223+
}
224+
}
206225
}
207226

208-
var wnd = new ListFiles(projItems);
227+
var wnd = new ListFiles(projItems.Values);
209228
wnd.Owner = HwndSource.FromHwnd(new IntPtr(GetActiveIDE().MainWindow.HWnd)).RootVisual as System.Windows.Window;
210229
wnd.Width = wnd.Owner.Width / 2;
211230
wnd.Height = wnd.Owner.Height / 3;

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
// You can specify all the values or you can default the Revision and Build Numbers
3030
// by using the '*' as shown below:
3131

32-
[assembly: AssemblyVersion("1.11.3.0")]
33-
[assembly: AssemblyFileVersion("1.11.3.0")]
32+
[assembly: AssemblyVersion("1.11.4.0")]
33+
[assembly: AssemblyFileVersion("1.11.4.0")]
3434

3535

3636

source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="6bb18fff-9e74-4deb-97df-6a94ddafb74e" Version="1.11.3" Language="en-US" Publisher="Pernicious Games" />
4+
<Identity Id="6bb18fff-9e74-4deb-97df-6a94ddafb74e" Version="1.11.4" Language="en-US" Publisher="Pernicious Games" />
55
<DisplayName>OpenFileInSolution</DisplayName>
66
<Description>Shows a list of all files in the current solution and allows quickly filtering and opening them.</Description>
77
<License>LICENSE</License>

0 commit comments

Comments
 (0)