From 7bb6a70c61cc61a47a61066e5cc5f992347e54a1 Mon Sep 17 00:00:00 2001 From: Sergey M Date: Sat, 23 Sep 2023 21:16:21 -0400 Subject: [PATCH 1/4] Fixed an issue with File Browser showing duplicate files --- DPackRx/CodeModel/SolutionProcessor.cs | 7 +++++++ DPackRx/Package/Beta.cs | 2 +- DPackRx/Package/LanguageConsts.cs | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/DPackRx/CodeModel/SolutionProcessor.cs b/DPackRx/CodeModel/SolutionProcessor.cs index 6d7c116..a21e5db 100644 --- a/DPackRx/CodeModel/SolutionProcessor.cs +++ b/DPackRx/CodeModel/SolutionProcessor.cs @@ -190,6 +190,13 @@ private bool ProcessProject(Project project, ICollection model, Pr } } + // Duplicate project check + if (process) + { + if (model.FirstOrDefault(p => p.FileName.Equals(projectFullName, StringComparison.OrdinalIgnoreCase)) != null) + process = false; + } + if (process) { var projectModel = new ProjectModel diff --git a/DPackRx/Package/Beta.cs b/DPackRx/Package/Beta.cs index d32dcf4..235f2c8 100644 --- a/DPackRx/Package/Beta.cs +++ b/DPackRx/Package/Beta.cs @@ -8,7 +8,7 @@ namespace DPackRx.Package /// internal static class Beta { - public static readonly DateTime ExpirationDate = new DateTime(2023, 7, 3).AddHours(12); + public static readonly DateTime ExpirationDate = new DateTime(2023, 10, 30).AddHours(12); } #endif } \ No newline at end of file diff --git a/DPackRx/Package/LanguageConsts.cs b/DPackRx/Package/LanguageConsts.cs index a787df8..7768c4a 100644 --- a/DPackRx/Package/LanguageConsts.cs +++ b/DPackRx/Package/LanguageConsts.cs @@ -39,5 +39,10 @@ public static class LanguageConsts /// VS Sql project language Guid. /// public const string VS_LANGUAGE_SQL = "{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}"; + + /// + /// Solution folder language Guid. + /// + public const string VS_MISC_FOLDER = "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}"; } } \ No newline at end of file From d533d0f18cfc96c6947b82193ad22a944cd42d5d Mon Sep 17 00:00:00 2001 From: Sergey M Date: Sat, 23 Sep 2023 22:13:24 -0400 Subject: [PATCH 2/4] Version bump --- DPackRx/source.extension.vsixmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DPackRx/source.extension.vsixmanifest b/DPackRx/source.extension.vsixmanifest index 1eaab1b..b4d055f 100644 --- a/DPackRx/source.extension.vsixmanifest +++ b/DPackRx/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + DPack Rx 2022 FREE tools collection designed to greatly increase developer's productivity, automate repetitive processes and expand upon some of Microsoft Visual Studio features. https://github.com/sergey-visual-studio/dpack From 6d72a248023b00661c1176e46dfb4eb742a38957 Mon Sep 17 00:00:00 2001 From: Sergey M Date: Sat, 21 Oct 2023 20:45:58 -0400 Subject: [PATCH 3/4] Another case of duplicate files fix. --- .../Features/FileBrowserViewModelTests.cs | 14 +++++++------- DPackRx.Tests/Services/SearchMatchServiceTests.cs | 6 +++--- DPackRx/CodeModel/FileTypeResolver.cs | 5 +++-- DPackRx/CodeModel/IFileTypeResolver.cs | 3 +-- DPackRx/CodeModel/ProjectProcessor.cs | 10 ++++++++++ 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/DPackRx.Tests/Features/FileBrowserViewModelTests.cs b/DPackRx.Tests/Features/FileBrowserViewModelTests.cs index 5edbefb..b7034cb 100644 --- a/DPackRx.Tests/Features/FileBrowserViewModelTests.cs +++ b/DPackRx.Tests/Features/FileBrowserViewModelTests.cs @@ -149,9 +149,9 @@ public void OnInitialize(string search, bool allFiles, string ignoreFiles, strin _optionsServiceMock.Setup(o => o.GetStringOption(viewModel.Feature, "ShowFiles", null)).Returns(showFiles).Verifiable(); _optionsServiceMock.Setup(o => o.GetStringOption(viewModel.Feature, "IgnoreFolders", null)).Returns(ignoreFolders).Verifiable(); - _fileTypeResolverMock.Setup(r => r.IsCodeSubType(FileSubType.Code, true)).Returns(true).Verifiable(); - _fileTypeResolverMock.Setup(r => r.IsCodeSubType(FileSubType.None, true)).Returns(false).Verifiable(); - _fileTypeResolverMock.Setup(r => r.IsCodeSubType(FileSubType.ImageFile, true)).Returns(false).Verifiable(); + _fileTypeResolverMock.Setup(r => r.IsCodeSubType(FileSubType.Code)).Returns(true).Verifiable(); + _fileTypeResolverMock.Setup(r => r.IsCodeSubType(FileSubType.None)).Returns(false).Verifiable(); + _fileTypeResolverMock.Setup(r => r.IsCodeSubType(FileSubType.ImageFile)).Returns(false).Verifiable(); viewModel.OnInitialize(null); @@ -170,15 +170,15 @@ public void OnInitialize(string search, bool allFiles, string ignoreFiles, strin _optionsServiceMock.Verify(o => o.GetStringOption(viewModel.Feature, "IgnoreFolders", null), Times.Once); if (allFiles) { - _fileTypeResolverMock.Verify(r => r.IsCodeSubType(FileSubType.Code, true), Times.Never); - _fileTypeResolverMock.Verify(r => r.IsCodeSubType(FileSubType.None, true), Times.Never); + _fileTypeResolverMock.Verify(r => r.IsCodeSubType(FileSubType.Code), Times.Never); + _fileTypeResolverMock.Verify(r => r.IsCodeSubType(FileSubType.None), Times.Never); } else { if (expectedCodeFileCount > 0) - _fileTypeResolverMock.Verify(r => r.IsCodeSubType(FileSubType.Code, true), Times.AtLeast(expectedCodeFileCount)); + _fileTypeResolverMock.Verify(r => r.IsCodeSubType(FileSubType.Code), Times.AtLeast(expectedCodeFileCount)); if (expectedNoneCodeFileCount > 0) - _fileTypeResolverMock.Verify(r => r.IsCodeSubType(It.IsNotIn(FileSubType.Code), true), Times.AtLeast(expectedNoneCodeFileCount)); + _fileTypeResolverMock.Verify(r => r.IsCodeSubType(It.IsNotIn(FileSubType.Code)), Times.AtLeast(expectedNoneCodeFileCount)); } _searchMatchServiceMock.Verify(s => s.MatchItems(search, It.IsAny>()), Times.Once); } diff --git a/DPackRx.Tests/Services/SearchMatchServiceTests.cs b/DPackRx.Tests/Services/SearchMatchServiceTests.cs index 0d1957e..20579dd 100644 --- a/DPackRx.Tests/Services/SearchMatchServiceTests.cs +++ b/DPackRx.Tests/Services/SearchMatchServiceTests.cs @@ -59,8 +59,8 @@ public int CompareTo(object obj) public void Setup() { _fileTypeResolverMock = new Mock(); - _fileTypeResolverMock.Setup(r => r.IsCodeSubType(It.IsAny(), true)).Returns(false).Verifiable(); - _fileTypeResolverMock.Setup(r => r.IsCodeSubType(FileSubType.Code, true)).Returns(true).Verifiable(); + _fileTypeResolverMock.Setup(r => r.IsCodeSubType(It.IsAny())).Returns(false).Verifiable(); + _fileTypeResolverMock.Setup(r => r.IsCodeSubType(FileSubType.Code)).Returns(true).Verifiable(); _wildcardMatchMock = new Mock(); } @@ -136,7 +136,7 @@ public void MatchItems(string filter, int codeRank, int nonCodeRank, string erro Assert.That(codeItem.Rank, Is.EqualTo(codeRank), $"Code item: {error}"); Assert.That(nonCodeItem.Rank, Is.EqualTo(nonCodeRank), $"Non-code item: {error}"); - _fileTypeResolverMock.Verify(r => r.IsCodeSubType(It.IsAny(), true), Times.Exactly(items.Count)); + _fileTypeResolverMock.Verify(r => r.IsCodeSubType(It.IsAny()), Times.Exactly(items.Count)); } [TestCase("test", false)] diff --git a/DPackRx/CodeModel/FileTypeResolver.cs b/DPackRx/CodeModel/FileTypeResolver.cs index 1497de8..d95b895 100644 --- a/DPackRx/CodeModel/FileTypeResolver.cs +++ b/DPackRx/CodeModel/FileTypeResolver.cs @@ -156,7 +156,7 @@ public FileSubType GetExtensionSubType(object projectItem, LanguageSettings lang /// File sub-type. /// Treat miscellaneous files as code ones. /// File sub-type status. - public bool IsCodeSubType(FileSubType itemSubType, bool miscFilesAsCode = true) + public bool IsCodeSubType(FileSubType itemSubType) { switch (itemSubType) { @@ -173,8 +173,9 @@ public bool IsCodeSubType(FileSubType itemSubType, bool miscFilesAsCode = true) return true; case FileSubType.JScript: case FileSubType.XmlFile: + return true; case FileSubType.ConfigFile: - return miscFilesAsCode; + return false; default: return false; } diff --git a/DPackRx/CodeModel/IFileTypeResolver.cs b/DPackRx/CodeModel/IFileTypeResolver.cs index 5d7fb4b..1ba0bce 100644 --- a/DPackRx/CodeModel/IFileTypeResolver.cs +++ b/DPackRx/CodeModel/IFileTypeResolver.cs @@ -37,9 +37,8 @@ public interface IFileTypeResolver /// Checks whether a given file sub-type is a code one. /// /// File sub-type. - /// Treat miscellaneous files as code ones. /// File sub-type status. - bool IsCodeSubType(FileSubType itemSubType, bool miscFilesAsCode = true); + bool IsCodeSubType(FileSubType itemSubType); /// /// Checks whether a given file sub-type is a web one with both design and code views. diff --git a/DPackRx/CodeModel/ProjectProcessor.cs b/DPackRx/CodeModel/ProjectProcessor.cs index 4e55b91..4985f64 100644 --- a/DPackRx/CodeModel/ProjectProcessor.cs +++ b/DPackRx/CodeModel/ProjectProcessor.cs @@ -189,6 +189,16 @@ private void ProcessProjectItems(List model, ProcessorFlags flags, Co add = false; } + // Check for nested duplicate files + if (add) + { + if ((parentItem != null) && + (parentItem.FileCount > 0) && + (projectItem.FileCount > 0) && + parentItem.FileNames[0].Equals(projectItem.FileNames[0], StringComparison.OrdinalIgnoreCase)) + add = false; + } + // Used to collect skipped files here as well... something to keep an eye out out for if (add) { From 5a69b879696a9acd3a68b74ccdd02aee5da3197f Mon Sep 17 00:00:00 2001 From: Sergey M Date: Mon, 30 Oct 2023 18:36:12 -0400 Subject: [PATCH 4/4] Beta version bump. --- DPackRx/Package/Beta.cs | 2 +- DPackRx/source.extension.vsixmanifest | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DPackRx/Package/Beta.cs b/DPackRx/Package/Beta.cs index 235f2c8..0c50706 100644 --- a/DPackRx/Package/Beta.cs +++ b/DPackRx/Package/Beta.cs @@ -8,7 +8,7 @@ namespace DPackRx.Package /// internal static class Beta { - public static readonly DateTime ExpirationDate = new DateTime(2023, 10, 30).AddHours(12); + public static readonly DateTime ExpirationDate = new DateTime(2023, 12, 31).AddHours(12); } #endif } \ No newline at end of file diff --git a/DPackRx/source.extension.vsixmanifest b/DPackRx/source.extension.vsixmanifest index b4d055f..8c483b5 100644 --- a/DPackRx/source.extension.vsixmanifest +++ b/DPackRx/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + DPack Rx 2022 FREE tools collection designed to greatly increase developer's productivity, automate repetitive processes and expand upon some of Microsoft Visual Studio features. https://github.com/sergey-visual-studio/dpack