From d3ff04a1815ac06f0eacf4847ced713ccbb1ad77 Mon Sep 17 00:00:00 2001 From: Tim Abell Date: Sun, 24 Dec 2023 09:24:18 +0000 Subject: [PATCH 1/5] Attempt to add missing nested folder Turns out to be a bug in SlnEditor - off to fix that.... --- src/CLI.cs | 3 +-- src/sln-items-sync.csproj | 2 +- tests/IntegrationTests.cs | 14 ++------------ 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/CLI.cs b/src/CLI.cs index 8705f9b..1e902af 100644 --- a/src/CLI.cs +++ b/src/CLI.cs @@ -115,8 +115,7 @@ private SolutionFolder FindOrCreateSolutionFolder(ICollection solution return solutionItems; } - solutionItems = new SolutionFolder(id: _guidGenerator.Next(), name: solutionFolderName, path: path, - typeGuid: SolutionFolderTypeGuid, ProjectType.SolutionFolder); + solutionItems = new SolutionFolder(id: _guidGenerator.Next(), name: solutionFolderName, path: path); solutionProjects.Add(solutionItems); return solutionItems; diff --git a/src/sln-items-sync.csproj b/src/sln-items-sync.csproj index faad37c..979bb26 100644 --- a/src/sln-items-sync.csproj +++ b/src/sln-items-sync.csproj @@ -11,6 +11,6 @@ - + diff --git a/tests/IntegrationTests.cs b/tests/IntegrationTests.cs index 6b193d7..4b05005 100644 --- a/tests/IntegrationTests.cs +++ b/tests/IntegrationTests.cs @@ -71,26 +71,16 @@ public void AddsToBlankSln() root-file.txt = root-file.txt EndProjectSection EndProject -Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""subfolder"", ""subfolder"", ""{CF942CDD-19AC-4E52-9C6E-B1381E0406D9}"" -EndProject -Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""nested_folder"", ""nested_folder"", ""{F5636E74-888A-4FBD-A8E2-9718A05D90BD}"" - ProjectSection(SolutionItems) = preProject - subfolder\nested_folder\nested_file.txt = subfolder\nested_folder\nested_file.txt - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} = {17591C35-3F90-4F4A-AA13-45CF8D824066} - {F5636E74-888A-4FBD-A8E2-9718A05D90BD} = {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE EndGlobalSection EndGlobal "; From d9a72393e0da928ec9a0f6f91a128fed72dea40d Mon Sep 17 00:00:00 2001 From: Tim Abell Date: Sun, 24 Dec 2023 15:29:35 +0000 Subject: [PATCH 2/5] test: Add debug expected.sln output --- tests/IntegrationTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/IntegrationTests.cs b/tests/IntegrationTests.cs index 4b05005..44e5fc8 100644 --- a/tests/IntegrationTests.cs +++ b/tests/IntegrationTests.cs @@ -324,6 +324,7 @@ public void CustomFolderName() EndGlobalSection EndGlobal "; + File.WriteAllText(Path.Combine(_testFolder, "expected.sln"), expected); // for kdiff debugging ModifiedSln().Should().Be(expected); } From eeac87df8f370bf7650622cac83db3c0c6fbb0a2 Mon Sep 17 00:00:00 2001 From: Tim Abell Date: Wed, 27 Dec 2023 03:06:13 +0000 Subject: [PATCH 3/5] Upgrade SlnEditor to v6 Fixes nested projects --- src/sln-items-sync.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sln-items-sync.csproj b/src/sln-items-sync.csproj index 979bb26..a1fa692 100644 --- a/src/sln-items-sync.csproj +++ b/src/sln-items-sync.csproj @@ -11,6 +11,6 @@ - + From ff5c52535c07310e563086a33787d486faa32184 Mon Sep 17 00:00:00 2001 From: Tim Abell Date: Wed, 27 Dec 2023 03:03:42 +0000 Subject: [PATCH 4/5] Update use of SlnEditor for v6 API --- src/CLI.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CLI.cs b/src/CLI.cs index 1e902af..ee4ab7d 100644 --- a/src/CLI.cs +++ b/src/CLI.cs @@ -54,7 +54,7 @@ public string SyncSlnText(string contents, string slnFolder, IEnumerable { var solution = new Solution(contents); - var solutionItems = FindOrCreateSolutionFolder(solution.Projects, slnFolder, slnFolder); + var solutionItems = FindOrCreateSolutionFolder(solution.RootProjects, slnFolder, slnFolder); foreach (var path in paths) { @@ -115,7 +115,7 @@ private SolutionFolder FindOrCreateSolutionFolder(ICollection solution return solutionItems; } - solutionItems = new SolutionFolder(id: _guidGenerator.Next(), name: solutionFolderName, path: path); + solutionItems = new SolutionFolder(id: _guidGenerator.Next(), name: solutionFolderName); solutionProjects.Add(solutionItems); return solutionItems; From d22ec5acd58906948e6a686e9412892388ce0117 Mon Sep 17 00:00:00 2001 From: Tim Abell Date: Wed, 27 Dec 2023 03:04:03 +0000 Subject: [PATCH 5/5] Update tests to match v6 SlnEditor behaviour No longer writes empty section. Now correctly creates hierarchy. --- tests/IntegrationTests.cs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/IntegrationTests.cs b/tests/IntegrationTests.cs index 44e5fc8..a40bcd9 100644 --- a/tests/IntegrationTests.cs +++ b/tests/IntegrationTests.cs @@ -71,6 +71,13 @@ public void AddsToBlankSln() root-file.txt = root-file.txt EndProjectSection EndProject +Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""subfolder"", ""subfolder"", ""{CF942CDD-19AC-4E52-9C6E-B1381E0406D9}"" +EndProject +Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""nested_folder"", ""nested_folder"", ""{F5636E74-888A-4FBD-A8E2-9718A05D90BD}"" + ProjectSection(SolutionItems) = preProject + subfolder\nested_folder\nested_file.txt = subfolder\nested_folder\nested_file.txt + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -81,10 +88,13 @@ public void AddsToBlankSln() EndGlobalSection GlobalSection(NestedProjects) = preSolution {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} = {17591C35-3F90-4F4A-AA13-45CF8D824066} + {F5636E74-888A-4FBD-A8E2-9718A05D90BD} = {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} EndGlobalSection EndGlobal "; + File.WriteAllText(Path.Combine(_testFolder, "expected.sln"), expected); // for kdiff debugging + ModifiedSln().Should().Be(expected); } @@ -158,8 +168,6 @@ public void IgnoresExistingItems() Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - EndGlobalSection GlobalSection(NestedProjects) = preSolution {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} = {17591C35-3F90-4F4A-AA13-45CF8D824066} {F5636E74-888A-4FBD-A8E2-9718A05D90BD} = {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} @@ -170,6 +178,8 @@ public void IgnoresExistingItems() EndGlobal "; + File.WriteAllText(Path.Combine(_testFolder, "expected.sln"), expected); // for kdiff debugging + ModifiedSln().Should().Be(expected); } @@ -244,8 +254,6 @@ public void RemovesMissingFiles() Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - EndGlobalSection GlobalSection(NestedProjects) = preSolution {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} = {17591C35-3F90-4F4A-AA13-45CF8D824066} {F5636E74-888A-4FBD-A8E2-9718A05D90BD} = {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} @@ -256,6 +264,8 @@ public void RemovesMissingFiles() EndGlobal "; + File.WriteAllText(Path.Combine(_testFolder, "expected.sln"), expected); // for kdiff debugging + ModifiedSln().Should().Be(expected); } @@ -313,15 +323,13 @@ public void CustomFolderName() Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} = {17591C35-3F90-4F4A-AA13-45CF8D824066} {F5636E74-888A-4FBD-A8E2-9718A05D90BD} = {CF942CDD-19AC-4E52-9C6E-B1381E0406D9} EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection EndGlobal "; File.WriteAllText(Path.Combine(_testFolder, "expected.sln"), expected); // for kdiff debugging