Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.slnx support - use the new parser for .sln and .slnx #10836

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3d1897d
include SolutionPersistence package
surayya-MS Oct 10, 2024
86f4847
add slnx in XMake.ProcessProjectSwitch
surayya-MS Oct 10, 2024
8a60719
support for .slnx format
surayya-MS Oct 10, 2024
e734a1b
small fix
surayya-MS Oct 10, 2024
32bc09f
update package
surayya-MS Oct 10, 2024
9fd5e8c
fix comment
surayya-MS Oct 11, 2024
221fb65
Apply suggestions from code review
surayya-MS Oct 11, 2024
62ed515
fix error message
surayya-MS Oct 11, 2024
9c2002f
move package version
surayya-MS Oct 11, 2024
c30f7c0
apply suggestions
surayya-MS Oct 11, 2024
94130b9
remove comment
surayya-MS Oct 11, 2024
09a5a7b
small fix
surayya-MS Oct 11, 2024
63be4f4
small change in xmake tests
surayya-MS Oct 11, 2024
73b8443
apply same suggestion to the other xmake tests
surayya-MS Oct 11, 2024
1bd2a25
refactor ParseSolutionHelper
surayya-MS Oct 11, 2024
7a9ff3a
rename to Solution_OldParser_Tests; move old parser specific tests to…
surayya-MS Oct 14, 2024
8e40124
refactor SolutionFile_Tests
surayya-MS Oct 14, 2024
b4ba54b
refactor and use old and new parser in SolutionProjectGenerator_Tests;
surayya-MS Oct 14, 2024
bdf1737
add change wave 17.13
surayya-MS Oct 14, 2024
f527f7a
use new parser if 17.13 chqange wave enabled
surayya-MS Oct 14, 2024
f448ffc
fix test
surayya-MS Oct 14, 2024
02021e3
throw ArgumentException if solutionFile is null or empty
surayya-MS Oct 16, 2024
3e54b2a
fix unix tests
surayya-MS Oct 16, 2024
dab0dd8
reorder usings
surayya-MS Oct 16, 2024
2743bbb
add 17.13 change wave to docs
surayya-MS Oct 16, 2024
ba36988
merge from main
surayya-MS Oct 17, 2024
f8bb751
add this pr to change waves docs
surayya-MS Oct 17, 2024
dc79f39
small fix
surayya-MS Oct 17, 2024
6affa44
small fix
surayya-MS Oct 17, 2024
741c7c8
fix typo
surayya-MS Oct 17, 2024
531d8cd
fix tests
surayya-MS Oct 17, 2024
092ba65
reference package Microsoft.VisualStudio.SolutionPersistence in Micro…
surayya-MS Oct 17, 2024
ec99bb0
Merge branch 'main' into slnx-support-followup
surayya-MS Oct 17, 2024
cae485d
refererence Microsoft.VisualStudio.SolutionPersistence in MSBuild.csp…
surayya-MS Oct 17, 2024
4c35c25
Revert "refererence Microsoft.VisualStudio.SolutionPersistence in MSB…
surayya-MS Oct 17, 2024
d22aa31
Revert "reference package Microsoft.VisualStudio.SolutionPersistence …
surayya-MS Oct 17, 2024
18280dd
fix bootstrap
YuliiaKovalova Oct 18, 2024
53a1fe9
Merge branch 'main' into slnx-support-followup
YuliiaKovalova Oct 24, 2024
5d85ba8
remove extra code
YuliiaKovalova Oct 25, 2024
dd84fe7
Merge branch 'main' into slnx-support-followup
surayya-MS Oct 25, 2024
cbccc42
add Microsoft.VisualStudio.SolutionPersistence to BootStrapMsBuild.ta…
surayya-MS Oct 28, 2024
ddaefd0
Update src/Build/Construction/Solution/SolutionFile.cs
surayya-MS Oct 28, 2024
5362002
Update documentation/wiki/ChangeWaves.md
surayya-MS Oct 28, 2024
fb7655a
use 17.14 instead of 17.13
surayya-MS Oct 28, 2024
535ae37
Merge branch 'slnx-support-followup' of https://github.com/surayya-MS…
surayya-MS Oct 28, 2024
4744800
fix space
surayya-MS Oct 28, 2024
23e5b72
use Assert.Throws around the line that throws exception
surayya-MS Oct 28, 2024
7b01fc0
save long line for test
surayya-MS Oct 28, 2024
8b2308e
set VersionPrefix to 17.13
surayya-MS Oct 28, 2024
1066ee0
fix bootstrap targets
surayya-MS Oct 28, 2024
f620185
Merge branch 'main' into slnx-support-followup
surayya-MS Oct 28, 2024
d714733
Merge branch 'main' into slnx-support-followup
surayya-MS Oct 29, 2024
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
3 changes: 3 additions & 0 deletions documentation/wiki/ChangeWaves.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ A wave of features is set to "rotate out" (i.e. become standard functionality) t

## Current Rotation of Change Waves

### 17.13
surayya-MS marked this conversation as resolved.
Show resolved Hide resolved
- [.SLNX support - use the new parser for .sln and .slnx](https://github.com/dotnet/msbuild/pull/10836)

### 17.12
- [Log TaskParameterEvent for scalar parameters](https://github.com/dotnet/msbuild/pull/9908)
- [Convert.ToString during a property evaluation uses the InvariantCulture for all types](https://github.com/dotnet/msbuild/pull/9874)
Expand Down
620 changes: 38 additions & 582 deletions src/Build.OM.UnitTests/Construction/SolutionFile_Tests.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.Build.Construction;
using Microsoft.Build.Exceptions;
using Microsoft.Build.Shared;
Expand All @@ -16,11 +17,11 @@

namespace Microsoft.Build.UnitTests.Construction
{
public class SolutionFile_Tests
public class SolutionFile_OldParser_Tests
{
public ITestOutputHelper TestOutputHelper { get; }

public SolutionFile_Tests(ITestOutputHelper testOutputHelper)
public SolutionFile_OldParser_Tests(ITestOutputHelper testOutputHelper)
{
TestOutputHelper = testOutputHelper;
}
Expand Down Expand Up @@ -104,6 +105,42 @@ public void ParseFirstProjectLineWithDifferentSpacing()
proj.ProjectGuid.ShouldBe("Unique name-GUID");
}

/// <summary>
/// A slightly more complicated test where there is some different whitespace.
/// </summary>
[Fact]
public void ParseSolutionWithDifferentSpacing()
{
string solutionFileContents =
@"
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project(' { Project GUID} ') = ' Project name ', ' Relative path to project file ' , ' {0ABED153-9451-483C-8140-9E8D7306B216} '
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AnyCPU = Debug|AnyCPU
Release|AnyCPU = Release|AnyCPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0ABED153-9451-483C-8140-9E8D7306B216}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU
{0ABED153-9451-483C-8140-9E8D7306B216}.Debug|AnyCPU.Build.0 = Debug|AnyCPU
{0ABED153-9451-483C-8140-9E8D7306B216}.Release|AnyCPU.ActiveCfg = Release|AnyCPU
{0ABED153-9451-483C-8140-9E8D7306B216}.Release|AnyCPU.Build.0 = Release|AnyCPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
";

SolutionFile solution = ParseSolutionHelper(solutionFileContents);

Assert.Equal("Project name", solution.ProjectsInOrder[0].ProjectName);
Assert.Equal("Relative path to project file", solution.ProjectsInOrder[0].RelativePath);
Assert.Equal("{0ABED153-9451-483C-8140-9E8D7306B216}", solution.ProjectsInOrder[0].ProjectGuid);
}

/// <summary>
/// First project line with an empty project name. This is somewhat malformed, but we should
/// still behave reasonably instead of crashing.
Expand Down Expand Up @@ -687,6 +724,43 @@ public void ParseFirstProjectLineWhereProjectNameHasSpecialCharacters()
proj.ProjectGuid.ShouldBe("Unique name-GUID");
}

/// <summary>
/// Test some characters that are valid in a file name but that also could be
/// considered a delimiter by a parser. Does quoting work for special characters?
surayya-MS marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
[Fact]
public void ParseSolutionWhereProjectNameHasSpecialCharacters()
{
string solutionFileContents =
@"
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project('{Project GUID}') = 'MyProject,(=IsGreat)', 'Relative path to project file' , '{0ABED153-9451-483C-8140-9E8D7306B216}'
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AnyCPU = Debug|AnyCPU
Release|AnyCPU = Release|AnyCPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0ABED153-9451-483C-8140-9E8D7306B216}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU
{0ABED153-9451-483C-8140-9E8D7306B216}.Debug|AnyCPU.Build.0 = Debug|AnyCPU
{0ABED153-9451-483C-8140-9E8D7306B216}.Release|AnyCPU.ActiveCfg = Release|AnyCPU
{0ABED153-9451-483C-8140-9E8D7306B216}.Release|AnyCPU.Build.0 = Release|AnyCPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
";

SolutionFile solution = ParseSolutionHelper(solutionFileContents);

Assert.Equal("MyProject,(=IsGreat)", solution.ProjectsInOrder[0].ProjectName);
Assert.Equal("Relative path to project file", solution.ProjectsInOrder[0].RelativePath);
Assert.Equal("{0ABED153-9451-483C-8140-9E8D7306B216}", solution.ProjectsInOrder[0].ProjectGuid);
}

/// <summary>
/// Test some characters that are valid in a file name but that also could be
/// considered a delimiter by a parser. Does quoting work for special characters?
Expand Down Expand Up @@ -2355,5 +2429,58 @@ public void ParseSolutionWithParentedPaths()
solution.ProjectsInOrder[0].AbsolutePath.ShouldBe(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(solution.FullPath)!, expectedRelativePath)));
solution.ProjectsInOrder[0].ProjectGuid.ShouldBe("{0ABED153-9451-483C-8140-9E8D7306B216}");
}

/// <summary>
/// Parse solution file with comments
/// </summary>
[Fact]
public void ParseSolutionWithComments()
{
const string solutionFileContent = @"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29123.89
MinimumVisualStudioVersion = 10.0.40219.1
Project('{9A19103F-16F7-4668-BE54-9A1E7A4F7556}') = 'SlnCommentTest', 'SlnCommentTest.csproj', '{00000000-0000-0000-FFFF-FFFFFFFFFFFF}'
EndProject
Project('{2150E333-8FDC-42A3-9474-1A3956D46DE8}') = 'Solution Items', 'Solution Items', '{054DED3B-B890-4652-B449-839F581E5D86}'
ProjectSection(SolutionItems) = preProject
SlnFile.txt = SlnFile.txt
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{00000000-0000-0000-FFFF-FFFFFFFFFFFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00000000-0000-0000-FFFF-FFFFFFFFFFFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00000000-0000-0000-FFFF-FFFFFFFFFFFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00000000-0000-0000-FFFF-FFFFFFFFFFFF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FFFFFFFF-FFFF-FFFF-0000-000000000000}
EndGlobalSection
EndGlobal
";

StringBuilder stringBuilder = new StringBuilder();

// Put comment between all lines
const string comment = "\t# comment";
string[] lines = solutionFileContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < lines.Length; i++)
{
stringBuilder.AppendLine(comment);
stringBuilder.AppendLine(lines[i]);
}
stringBuilder.AppendLine(comment);

Should.NotThrow(() => ParseSolutionHelper(stringBuilder.ToString()));
}
}
}
8 changes: 4 additions & 4 deletions src/Build.UnitTests/Construction/SolutionFilter_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ public void SolutionFilterFiltersProjects(bool graphBuild)
");
// Slashes here (and in the .slnf) are hardcoded as backslashes intentionally to support the common case.
TransientTestFile solutionFile = testEnvironment.CreateFile(simpleProjectFolder, "SimpleProject.sln",
@"
"""
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29326.124
MinimumVisualStudioVersion = 10.0.40219.1
Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""SimpleProject"", ""SimpleProject\SimpleProject.csproj"", ""{79B5EBA6-5D27-4976-BC31-14422245A59A}""
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleProject", "SimpleProject\SimpleProject.csproj", "{79B5EBA6-5D27-4976-BC31-14422245A59A}"
EndProject
Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""ClassLibrary"", ""..\ClassLibrary\ClassLibrary\ClassLibrary.csproj"", ""{8EFCCA22-9D51-4268-90F7-A595E11FCB2D}""
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary", "..\ClassLibrary\ClassLibrary\ClassLibrary.csproj", "{8EFCCA22-9D51-4268-90F7-A595E11FCB2D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -106,7 +106,7 @@ public void SolutionFilterFiltersProjects(bool graphBuild)
SolutionGuid = {DE7234EC-0C4D-4070-B66A-DCF1B4F0CFEF}
EndGlobalSection
EndGlobal
");
""");
TransientTestFile filterFile = testEnvironment.CreateFile(folder, "solutionFilter.slnf",
@"
{
Expand Down
Loading
Loading