Skip to content

Commit

Permalink
Fixed parent linking and root parent linking (#72)
Browse files Browse the repository at this point in the history
Fixed child folder setting to the highest level root folder, also fixed linking between parent folder and child project in the generated sln file as this was missing in some cases
  • Loading branch information
efoleymsft authored and jeffkl committed Oct 31, 2019
1 parent 5f27c0f commit 98d14d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/SlnGen.Build.Tasks.UnitTests/SlnFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ public void NoFolders()
ValidateProjectInSolution((s, p) => p.ParentProjectGuid.ShouldBe(null), projects, false);
}

[Fact]
public void WithFolders()
{
SlnProject[] projects =
{
new SlnProject(GetTempFileName(), "ProjectA", new Guid("C95D800E-F016-4167-8E1B-1D3FF94CE2E2"), new Guid("88152E7E-47E3-45C8-B5D3-DDB15B2F0435"), new[] { "Debug" }, new[] { "x64" }, isMainProject: true, isDeployable: false),
new SlnProject(GetTempFileName(), "ProjectB", new Guid("EAD108BE-AC70-41E6-A8C3-450C545FDC0E"), new Guid("F38341C3-343F-421A-AE68-94CD9ADCD32F"), new[] { "Debug" }, new[] { "x64" }, isMainProject: false, isDeployable: false),
new SlnProject(GetTempFileName(), "ProjectC", new Guid("00C5B0C0-E19C-48C5-818D-E8CD4FA2A915"), new Guid("F38341C3-343F-421A-AE68-94CD9ADCD32F"), new[] { "Debug" }, new[] { "x64" }, isMainProject: false, isDeployable: false),
};

var action = new Action<SlnProject, ProjectInSolution>((s, p) =>
{
if (s.IsMainProject)
{
p.ParentProjectGuid.ShouldBeNull();
}
else
{
p.ParentProjectGuid.ShouldNotBeNull();
}
});

ValidateProjectInSolution(action, projects, true);
}

[Fact]
public void SaveToCustomLocationCreatesDirectory()
{
Expand Down
1 change: 1 addition & 0 deletions src/SlnGen.Build.Tasks/Internal/SlnHierarchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ private void CreateHierarchy(SlnProject project)
if (!_rootFolder.Folders.Contains(childFolder))
{
_rootFolder.Folders.Add(childFolder);
childFolder.Parent = _rootFolder;
}
}

Expand Down

0 comments on commit 98d14d1

Please sign in to comment.