diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs
index a88c45f8ff..baa206419e 100644
--- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs
+++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs
@@ -46,7 +46,7 @@ await RunAsync(
- """.Replace("\n", EOL))
+ """.SetEOL(EOL))
],
discoveryWorker: new TestDiscoveryWorker(_input =>
{
@@ -97,7 +97,7 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
return new UpdateOperationResult();
}),
expectedResult: new RunResult()
@@ -117,7 +117,7 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
}
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -202,7 +202,7 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL),
+ """.SetEOL(EOL),
},
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -221,8 +221,8 @@ await File.WriteAllTextAsync(projectPath, """
[InlineData(["\r\n"])]
public async Task UpdateHandlesSemicolonsInPackageReference(string EOL)
{
- var repoMetadata = XElement.Parse("""""".Replace("\n", EOL));
- var repoMetadata2 = XElement.Parse("""""".Replace("\n", EOL));
+ var repoMetadata = XElement.Parse("""""".SetEOL(EOL));
+ var repoMetadata2 = XElement.Parse("""""".SetEOL(EOL));
await RunAsync(
packages:
[
@@ -252,7 +252,7 @@ await RunAsync(
- """.Replace("\n", EOL))
+ """.SetEOL(EOL))
],
discoveryWorker: new TestDiscoveryWorker(_input =>
{
@@ -305,7 +305,7 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
return new UpdateOperationResult();
}),
expectedResult: new RunResult()
@@ -325,7 +325,7 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
}
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -453,7 +453,7 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL),
+ """.SetEOL(EOL),
}
],
@@ -495,7 +495,7 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("project.csproj", """
@@ -505,7 +505,7 @@ await RunAsync(
- """.Replace("\n", EOL))
+ """.SetEOL(EOL))
],
discoveryWorker: new TestDiscoveryWorker((_input) =>
{
@@ -532,8 +532,8 @@ await RunAsync(
[InlineData(["\r\n"])]
public async Task UpdateHandlesPackagesConfigFiles(string EOL)
{
- var repoMetadata = XElement.Parse("""""".Replace("\n", EOL));
- var repoMetadata2 = XElement.Parse("""""".Replace("\n", EOL));
+ var repoMetadata = XElement.Parse("""""".SetEOL(EOL));
+ var repoMetadata2 = XElement.Parse("""""".SetEOL(EOL));
await RunAsync(
packages:
[
@@ -563,13 +563,13 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("some-dir/packages.config", """
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
],
discoveryWorker: new TestDiscoveryWorker(_input =>
{
@@ -642,7 +642,7 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
break;
case "Some.Package2":
await File.WriteAllTextAsync(projectPath, """
@@ -660,14 +660,14 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
var packagesConfigPath = Path.Join(Path.GetDirectoryName(projectPath)!, "packages.config");
await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
break;
default:
throw new NotSupportedException();
@@ -688,7 +688,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
new DependencyFile()
{
@@ -703,7 +703,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -827,7 +827,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL),
+ """.SetEOL(EOL),
},
new DependencyFile()
{
@@ -848,7 +848,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL),
+ """.SetEOL(EOL),
},
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -867,8 +867,8 @@ await File.WriteAllTextAsync(packagesConfigPath, """
[InlineData(["\r\n"])]
public async Task UpdateHandlesPackagesConfigFromReferencedCsprojFiles(string EOL)
{
- var repoMetadata = XElement.Parse("""""".Replace("\n", EOL));
- var repoMetadata2 = XElement.Parse("""""".Replace("\n", EOL));
+ var repoMetadata = XElement.Parse("""""".SetEOL(EOL));
+ var repoMetadata2 = XElement.Parse("""""".SetEOL(EOL));
await RunAsync(
packages:
[
@@ -901,13 +901,13 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("some-dir/ProjectA/packages.config", """
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("some-dir/ProjectB/ProjectB.csproj", """
@@ -917,13 +917,13 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("some-dir/ProjectB/packages.config", """
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
],
discoveryWorker: new TestDiscoveryWorker(_input =>
{
@@ -1014,7 +1014,7 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
break;
case ("ProjectA.csproj", "Some.Package2"):
await File.WriteAllTextAsync(projectPath, """
@@ -1035,13 +1035,13 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
break;
case ("ProjectB.csproj", "Some.Package"):
await File.WriteAllTextAsync(projectPath, """
@@ -1053,7 +1053,7 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
break;
case ("ProjectB.csproj", "Some.Package2"):
await File.WriteAllTextAsync(projectPath, """
@@ -1071,13 +1071,13 @@ await File.WriteAllTextAsync(projectPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
break;
default:
throw new NotSupportedException();
@@ -1098,7 +1098,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
new DependencyFile()
{
@@ -1116,7 +1116,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
new DependencyFile()
{
@@ -1127,7 +1127,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
new DependencyFile()
{
@@ -1142,7 +1142,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1352,7 +1352,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL),
+ """.SetEOL(EOL),
},
new DependencyFile()
{
@@ -1376,7 +1376,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL),
+ """.SetEOL(EOL),
},
new DependencyFile()
{
@@ -1387,7 +1387,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL),
+ """.SetEOL(EOL),
},
new DependencyFile()
{
@@ -1408,7 +1408,7 @@ await File.WriteAllTextAsync(packagesConfigPath, """
- """.Replace("\n", EOL),
+ """.SetEOL(EOL),
},
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1452,14 +1452,14 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("Directory.Build.props", """
1.0.0
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("project1/project1.csproj", """
@@ -1469,7 +1469,7 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("project2/project2.csproj", """
@@ -1479,7 +1479,7 @@ await RunAsync(
- """.Replace("\n", EOL))
+ """.SetEOL(EOL))
],
discoveryWorker: new TestDiscoveryWorker(_input =>
{
@@ -1544,7 +1544,7 @@ await File.WriteAllTextAsync(directoryBuildPropsPath, """
1.1.0
- """.Replace("\n", EOL));
+ """.SetEOL(EOL));
return new UpdateOperationResult();
}),
expectedResult: new RunResult()
@@ -1561,7 +1561,7 @@ await File.WriteAllTextAsync(directoryBuildPropsPath, """
1.0.0
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
new DependencyFile()
{
@@ -1576,7 +1576,7 @@ await File.WriteAllTextAsync(directoryBuildPropsPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
new DependencyFile()
{
@@ -1591,7 +1591,7 @@ await File.WriteAllTextAsync(directoryBuildPropsPath, """
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1716,7 +1716,7 @@ await File.WriteAllTextAsync(directoryBuildPropsPath, """
1.1.0
- """.Replace("\n", EOL),
+ """.SetEOL(EOL),
}
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1775,7 +1775,7 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("Directory.Build.props", ""),
("Directory.Build.targets", ""),
("Directory.Packages.props", """
@@ -1784,7 +1784,7 @@ await RunAsync(
false
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("library1/library1.csproj", """
@@ -1794,7 +1794,7 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("library2/library2.csproj", """
@@ -1804,7 +1804,7 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
("library3/library3.csproj", """
@@ -1814,7 +1814,7 @@ await RunAsync(
- """.Replace("\n", EOL)),
+ """.SetEOL(EOL)),
],
discoveryWorker: null,
analyzeWorker: null,
@@ -1845,7 +1845,7 @@ await RunAsync(
false
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
new DependencyFile()
{
@@ -1860,7 +1860,7 @@ await RunAsync(
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
new DependencyFile()
{
@@ -1875,7 +1875,7 @@ await RunAsync(
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
},
new DependencyFile()
{
@@ -1890,7 +1890,7 @@ await RunAsync(
- """.Replace("\n", EOL)))
+ """.SetEOL(EOL)))
}
],
BaseCommitSha = "TEST-COMMIT-SHA",
@@ -2041,7 +2041,7 @@ await RunAsync(
- """.Replace("\n", EOL)
+ """.SetEOL(EOL)
},
new()
{
@@ -2057,7 +2057,7 @@ await RunAsync(
- """.Replace("\n", EOL)
+ """.SetEOL(EOL)
}
],
BaseCommitSha = "TEST-COMMIT-SHA",
diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/StringExtensions.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/StringExtensions.cs
new file mode 100644
index 0000000000..e0e2ac60a4
--- /dev/null
+++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/StringExtensions.cs
@@ -0,0 +1,6 @@
+namespace NuGetUpdater.Core.Test.Run;
+
+public static class StringExtensions
+{
+ public static string SetEOL(this string input, string EOL) => input.Replace("\r\n", EOL).Replace("\r", EOL).Replace("\n", EOL);
+}