Skip to content

Commit

Permalink
Merge branch 'slneditor-upgrade' into main
Browse files Browse the repository at this point in the history
* slneditor-upgrade:
  Update tests to match v6 SlnEditor behaviour
  Update use of SlnEditor for v6 API
  Upgrade SlnEditor to v6
  test: Add debug expected.sln output
  Attempt to add missing nested folder
  • Loading branch information
timabell committed Dec 27, 2023
2 parents aad093f + d22ec5a commit c4e7c6b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/CLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public string SyncSlnText(string contents, string slnFolder, IEnumerable<string>
{
var solution = new Solution(contents);

var solutionItems = FindOrCreateSolutionFolder(solution.Projects, slnFolder, slnFolder);
var solutionItems = FindOrCreateSolutionFolder(solution.RootProjects, slnFolder, slnFolder);

foreach (var path in paths)
{
Expand Down Expand Up @@ -115,8 +115,7 @@ private SolutionFolder FindOrCreateSolutionFolder(ICollection<IProject> 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);
solutionProjects.Add(solutionItems);

return solutionItems;
Expand Down
2 changes: 1 addition & 1 deletion src/sln-items-sync.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="SlnEditor" Version="4.0.0" />
<PackageReference Include="SlnEditor" Version="6.0.0" />
</ItemGroup>
</Project>
23 changes: 11 additions & 12 deletions tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ public void AddsToBlankSln()
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

ModifiedSln().Should().Be(expected);
}

Expand Down Expand Up @@ -168,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}
Expand All @@ -180,6 +178,8 @@ public void IgnoresExistingItems()
EndGlobal
";

File.WriteAllText(Path.Combine(_testFolder, "expected.sln"), expected); // for kdiff debugging

ModifiedSln().Should().Be(expected);
}

Expand Down Expand Up @@ -254,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}
Expand All @@ -266,6 +264,8 @@ public void RemovesMissingFiles()
EndGlobal
";

File.WriteAllText(Path.Combine(_testFolder, "expected.sln"), expected); // for kdiff debugging

ModifiedSln().Should().Be(expected);
}

Expand Down Expand Up @@ -323,17 +323,16 @@ 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

ModifiedSln().Should().Be(expected);
}
Expand Down

0 comments on commit c4e7c6b

Please sign in to comment.