Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/wiki/ChangeWaves.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A wave of features is set to "rotate out" (i.e. become standard functionality) t
## Current Rotation of Change Waves

### 17.14
- [.SLNX support - use the new parser for .sln and .slnx](https://github.com/dotnet/msbuild/pull/10836)
- ~[.SLNX support - use the new parser for .sln and .slnx](https://github.com/dotnet/msbuild/pull/10836)~ reverted after compat problems discovered
- [Support custom culture in RAR](https://github.com/dotnet/msbuild/pull/11000)
- [VS Telemetry](https://github.com/dotnet/msbuild/pull/11255)

Expand Down
50 changes: 29 additions & 21 deletions src/Build.OM.UnitTests/Construction/SolutionFile_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,21 @@ namespace Microsoft.Build.UnitTests.Construction
/// <summary>
/// Tests for the parts of SolutionFile that are surfaced as public API
/// </summary>
public class SolutionFile_Tests
public class SolutionFile_Tests : IDisposable
{

private readonly TestEnvironment _testEnvironment;

public SolutionFile_Tests()
{
_testEnvironment = TestEnvironment.Create();
}

public void Dispose()
{
_testEnvironment.Dispose();
}

/// <summary>
/// Test that a project with the C++ project guid and an extension of vcproj is seen as invalid.
/// </summary>
Expand Down Expand Up @@ -57,7 +70,7 @@ public void ParseSolution_VC()

Assert.Throws<InvalidProjectFileException>(() =>
{
ParseSolutionHelper(solutionFileContents);
ParseSolutionHelper(_testEnvironment, solutionFileContents);
Assert.Fail("Should not get here");
});
}
Expand Down Expand Up @@ -93,7 +106,7 @@ public void ParseSolution_VC2(bool convertToSlnx)
EndGlobal
""";

SolutionFile solution = ParseSolutionHelper(solutionFileContents, convertToSlnx);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents, convertToSlnx);

string expectedProjectName = convertToSlnx ? "Project name" : "Project name.myvctype";
Assert.Equal(expectedProjectName, solution.ProjectsInOrder[0].ProjectName);
Expand Down Expand Up @@ -137,7 +150,7 @@ public void ParseSolution_EmptyProjectName()

Assert.Throws<InvalidProjectFileException>(() =>
{
SolutionFile solution = ParseSolutionHelper(solutionFileContents);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents);
});
}

Expand Down Expand Up @@ -184,7 +197,7 @@ public void BasicSolution(bool convertToSlnx)
EndGlobal
""";

SolutionFile solution = ParseSolutionHelper(solutionFileContents, convertToSlnx);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents, convertToSlnx);

Assert.Equal(3, solution.ProjectsInOrder.Count);

Expand Down Expand Up @@ -266,7 +279,7 @@ public void SolutionFolders(bool convertToSlnx)
EndGlobal
""";

SolutionFile solution = ParseSolutionHelper(solutionFileContents, convertToSlnx);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents, convertToSlnx);

Assert.Equal(3, solution.ProjectsInOrder.Count);

Expand Down Expand Up @@ -351,7 +364,7 @@ public void SolutionDependencies(bool convertToSlnx)
EndGlobal
""";

SolutionFile solution = ParseSolutionHelper(solutionFileContents, convertToSlnx);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents, convertToSlnx);

Assert.Equal(3, solution.ProjectsInOrder.Count);

Expand Down Expand Up @@ -432,7 +445,7 @@ public void ParseSolutionConfigurations(bool convertToSlnx)
EndGlobal
""";

SolutionFile solution = ParseSolutionHelper(solutionFileContents, convertToSlnx);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents, convertToSlnx);

Assert.Equal(7, solution.SolutionConfigurations.Count);

Expand Down Expand Up @@ -494,7 +507,7 @@ public void ParseSolutionConfigurationsNoMixedPlatform(bool convertToSlnx)
EndGlobal
""";

SolutionFile solution = ParseSolutionHelper(solutionFileContents, convertToSlnx);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents, convertToSlnx);

Assert.Equal(6, solution.SolutionConfigurations.Count);

Expand Down Expand Up @@ -569,7 +582,7 @@ public void ParseProjectConfigurationsInSolutionConfigurations1(bool convertToSl
EndGlobal
""";

SolutionFile solution = ParseSolutionHelper(solutionFileContents, convertToSlnx);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents, convertToSlnx);

ProjectInSolution csharpProject = solution.ProjectsInOrder.First(p => p.ProjectName == "ClassLibrary1");
ProjectInSolution vcProject = solution.ProjectsInOrder.First(p => p.ProjectName == "MainApp");
Expand Down Expand Up @@ -654,7 +667,7 @@ public void ParseProjectConfigurationsInSolutionConfigurations2(bool convertToSl
EndGlobal
""";

SolutionFile solution = ParseSolutionHelper(solutionFileContents, convertToSlnx);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents, convertToSlnx);

ProjectInSolution winFormsApp1 = solution.ProjectsInOrder.First(p => p.ProjectName == "WinFormsApp1");
ProjectInSolution classLibrary1 = solution.ProjectsInOrder.First(p => p.ProjectName == "ClassLibrary1");
Expand All @@ -680,18 +693,13 @@ public void ParseProjectConfigurationsInSolutionConfigurations2(bool convertToSl
/// Helper method to create a SolutionFile object, and call it to parse the SLN file
/// represented by the string contents passed in. Optionally can convert the SLN to SLNX and then parse the solution.
/// </summary>
private static SolutionFile ParseSolutionHelper(string solutionFileContents, bool convertToSlnx = false)
private static SolutionFile ParseSolutionHelper(TestEnvironment testEnvironment, string solutionFileContents, bool convertToSlnx = false)
{
solutionFileContents = solutionFileContents.Replace('\'', '"');

using (TestEnvironment testEnvironment = TestEnvironment.Create())
{
TransientTestFile sln = testEnvironment.CreateFile(FileUtilities.GetTemporaryFileName(".sln"), solutionFileContents);

string solutionPath = convertToSlnx ? ConvertToSlnx(sln.Path) : sln.Path;

return SolutionFile.Parse(solutionPath);
}
testEnvironment.SetEnvironmentVariable("MSBUILD_SLN_PARSING_SOLUTIONPERSISTENCE_OPTIN", "1");
TransientTestFile sln = testEnvironment.CreateFile(FileUtilities.GetTemporaryFileName(".sln"), solutionFileContents);
string solutionPath = convertToSlnx ? ConvertToSlnx(sln.Path) : sln.Path;
return SolutionFile.Parse(solutionPath);
}

private static string ConvertToSlnx(string slnPath)
Expand Down
31 changes: 17 additions & 14 deletions src/Build.UnitTests/Construction/SolutionFile_NewParser_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@

namespace Microsoft.Build.UnitTests.Construction
{
public class SolutionFile_NewParser_Tests
public class SolutionFile_NewParser_Tests : IDisposable
{
public ITestOutputHelper TestOutputHelper { get; }

private readonly TestEnvironment _testEnvironment;

public SolutionFile_NewParser_Tests(ITestOutputHelper testOutputHelper)
{
TestOutputHelper = testOutputHelper;
_testEnvironment = TestEnvironment.Create();
}

public void Dispose()
{
_testEnvironment.Dispose();
}

/// <summary>
Expand Down Expand Up @@ -80,7 +88,7 @@ public void ProjectWithWebsiteProperties(bool convertToSlnx)
EndGlobal
""";

SolutionFile solution = ParseSolutionHelper(solutionFileContents.Replace('`', '"'), convertToSlnx);
SolutionFile solution = ParseSolutionHelper(_testEnvironment, solutionFileContents.Replace('`', '"'), convertToSlnx);

solution.ProjectsInOrder.ShouldHaveSingleItem();

Expand Down Expand Up @@ -129,20 +137,15 @@ public void ProjectWithWebsiteProperties(bool convertToSlnx)
/// Helper method to create a SolutionFile object, and call it to parse the SLN file
/// represented by the string contents passed in. Optionally can convert the SLN to SLNX and then parse the solution.
/// </summary>
internal static SolutionFile ParseSolutionHelper(string solutionFileContents, bool convertToSlnx = false)
internal static SolutionFile ParseSolutionHelper(TestEnvironment testEnvironment, string solutionFileContents, bool convertToSlnx = false)
{
solutionFileContents = solutionFileContents.Replace('\'', '"');

using (TestEnvironment testEnvironment = TestEnvironment.Create())
{
TransientTestFile sln = testEnvironment.CreateFile(FileUtilities.GetTemporaryFileName(".sln"), solutionFileContents);

string solutionPath = convertToSlnx ? ConvertToSlnx(sln.Path) : sln.Path;

SolutionFile solutionFile = new SolutionFile { FullPath = solutionPath };
solutionFile.ParseUsingNewParser();
return solutionFile;
}
testEnvironment.SetEnvironmentVariable("MSBUILD_SLN_PARSING_SOLUTIONPERSISTENCE_OPTIN", "1");
TransientTestFile sln = testEnvironment.CreateFile(FileUtilities.GetTemporaryFileName(".sln"), solutionFileContents);
string solutionPath = convertToSlnx ? ConvertToSlnx(sln.Path) : sln.Path;
SolutionFile solutionFile = new SolutionFile { FullPath = solutionPath };
solutionFile.ParseUsingNewParser();
return solutionFile;
}

private static string ConvertToSlnx(string slnPath)
Expand Down
Loading