dependabot-nuget 0.309.0 → 0.310.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,11 +27,8 @@ public class RunWorkerTests
27
27
  public const string TestPullRequestTitle = "test-pull-request-title";
28
28
  public const string TestPullRequestBody = "test-pull-request-body";
29
29
 
30
- [Theory]
31
- [InlineData(EOLType.CR)]
32
- [InlineData(EOLType.LF)]
33
- [InlineData(EOLType.CRLF)]
34
- public async Task UpdateSinglePackageProducedExpectedAPIMessages(EOLType EOL)
30
+ [Fact]
31
+ public async Task UpdateSinglePackageProducedExpectedAPIMessages()
35
32
  {
36
33
  await RunAsync(
37
34
  packages: [],
@@ -55,7 +52,7 @@ public class RunWorkerTests
55
52
  <PackageReference Include="Some.Package" Version="1.0.0" />
56
53
  </ItemGroup>
57
54
  </Project>
58
- """.SetEOL(EOL))
55
+ """)
59
56
  ],
60
57
  discoveryWorker: new TestDiscoveryWorker(_input =>
61
58
  {
@@ -106,7 +103,7 @@ public class RunWorkerTests
106
103
  <PackageReference Include="Some.Package" Version="1.0.1" />
107
104
  </ItemGroup>
108
105
  </Project>
109
- """.SetEOL(EOL));
106
+ """);
110
107
  return new UpdateOperationResult()
111
108
  {
112
109
  UpdateOperations = [
@@ -136,7 +133,7 @@ public class RunWorkerTests
136
133
  <PackageReference Include="Some.Package" Version="1.0.0" />
137
134
  </ItemGroup>
138
135
  </Project>
139
- """.SetEOL(EOL))),
136
+ """)),
140
137
  ContentEncoding = "base64"
141
138
  }
142
139
  ],
@@ -222,7 +219,7 @@ public class RunWorkerTests
222
219
  <PackageReference Include="Some.Package" Version="1.0.1" />
223
220
  </ItemGroup>
224
221
  </Project>
225
- """.SetEOL(EOL),
222
+ """,
226
223
  },
227
224
  ],
228
225
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -235,14 +232,11 @@ public class RunWorkerTests
235
232
  );
236
233
  }
237
234
 
238
- [Theory]
239
- [InlineData(EOLType.CR)]
240
- [InlineData(EOLType.LF)]
241
- [InlineData(EOLType.CRLF)]
242
- public async Task UpdateHandlesSemicolonsInPackageReference(EOLType EOL)
235
+ [Fact]
236
+ public async Task UpdateHandlesSemicolonsInPackageReference()
243
237
  {
244
- var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""".SetEOL(EOL));
245
- var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""".SetEOL(EOL));
238
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
239
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
246
240
  await RunAsync(
247
241
  packages:
248
242
  [
@@ -272,7 +266,7 @@ public class RunWorkerTests
272
266
  <PackageReference Include="Some.Package;Some.Package2" Version="1.0.0" />
273
267
  </ItemGroup>
274
268
  </Project>
275
- """.SetEOL(EOL))
269
+ """)
276
270
  ],
277
271
  discoveryWorker: new TestDiscoveryWorker(_input =>
278
272
  {
@@ -325,7 +319,7 @@ public class RunWorkerTests
325
319
  <PackageReference Include="Some.Package;Some.Package2" Version="1.0.1" />
326
320
  </ItemGroup>
327
321
  </Project>
328
- """.SetEOL(EOL));
322
+ """);
329
323
  return new UpdateOperationResult()
330
324
  {
331
325
  UpdateOperations = [
@@ -361,7 +355,7 @@ public class RunWorkerTests
361
355
  <PackageReference Include="Some.Package;Some.Package2" Version="1.0.0" />
362
356
  </ItemGroup>
363
357
  </Project>
364
- """.SetEOL(EOL))),
358
+ """)),
365
359
  ContentEncoding = "base64"
366
360
  }
367
361
  ],
@@ -490,7 +484,7 @@ public class RunWorkerTests
490
484
  <PackageReference Include="Some.Package;Some.Package2" Version="1.0.1" />
491
485
  </ItemGroup>
492
486
  </Project>
493
- """.SetEOL(EOL),
487
+ """,
494
488
  }
495
489
 
496
490
  ],
@@ -504,11 +498,8 @@ public class RunWorkerTests
504
498
  );
505
499
  }
506
500
 
507
- [Theory]
508
- [InlineData(EOLType.CR)]
509
- [InlineData(EOLType.LF)]
510
- [InlineData(EOLType.CRLF)]
511
- public async Task PrivateSourceAuthenticationFailureIsForwaredToApiHandler(EOLType EOL)
501
+ [Fact]
502
+ public async Task PrivateSourceAuthenticationFailureIsForwaredToApiHandler()
512
503
  {
513
504
  await RunAsync(
514
505
  packages:
@@ -532,7 +523,7 @@ public class RunWorkerTests
532
523
  <add key="private_feed" value="http://example.com/nuget/index.json" allowInsecureConnections="true" />
533
524
  </packageSources>
534
525
  </configuration>
535
- """.SetEOL(EOL)),
526
+ """),
536
527
  ("project.csproj", """
537
528
  <Project Sdk="Microsoft.NET.Sdk">
538
529
  <PropertyGroup>
@@ -542,7 +533,7 @@ public class RunWorkerTests
542
533
  <PackageReference Include="Some.Package" Version="1.0.0" />
543
534
  </ItemGroup>
544
535
  </Project>
545
- """.SetEOL(EOL))
536
+ """)
546
537
  ],
547
538
  discoveryWorker: new TestDiscoveryWorker((_input) =>
548
539
  {
@@ -563,14 +554,11 @@ public class RunWorkerTests
563
554
  );
564
555
  }
565
556
 
566
- [Theory]
567
- [InlineData(EOLType.CR)]
568
- [InlineData(EOLType.LF)]
569
- [InlineData(EOLType.CRLF)]
570
- public async Task UpdateHandlesPackagesConfigFiles(EOLType EOL)
557
+ [Fact]
558
+ public async Task UpdateHandlesPackagesConfigFiles()
571
559
  {
572
- var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""".SetEOL(EOL));
573
- var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""".SetEOL(EOL));
560
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
561
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
574
562
  await RunAsync(
575
563
  packages:
576
564
  [
@@ -600,13 +588,13 @@ public class RunWorkerTests
600
588
  <PackageReference Include="Some.Package" Version="1.0.0" />
601
589
  </ItemGroup>
602
590
  </Project>
603
- """.SetEOL(EOL)),
591
+ """),
604
592
  ("some-dir/packages.config", """
605
593
  <?xml version="1.0" encoding="utf-8"?>
606
594
  <packages>
607
595
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
608
596
  </packages>
609
- """.SetEOL(EOL)),
597
+ """),
610
598
  ],
611
599
  discoveryWorker: new TestDiscoveryWorker(_input =>
612
600
  {
@@ -679,7 +667,7 @@ public class RunWorkerTests
679
667
  <PackageReference Include="Some.Package" Version="1.0.1" />
680
668
  </ItemGroup>
681
669
  </Project>
682
- """.SetEOL(EOL));
670
+ """);
683
671
  break;
684
672
  case "Some.Package2":
685
673
  await File.WriteAllTextAsync(projectPath, """
@@ -697,14 +685,14 @@ public class RunWorkerTests
697
685
  </Reference>
698
686
  </ItemGroup>
699
687
  </Project>
700
- """.SetEOL(EOL));
688
+ """);
701
689
  var packagesConfigPath = Path.Join(Path.GetDirectoryName(projectPath)!, "packages.config");
702
690
  await File.WriteAllTextAsync(packagesConfigPath, """
703
691
  <?xml version="1.0" encoding="utf-8"?>
704
692
  <packages>
705
693
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
706
694
  </packages>
707
- """.SetEOL(EOL));
695
+ """);
708
696
  break;
709
697
  default:
710
698
  throw new NotSupportedException();
@@ -735,7 +723,7 @@ public class RunWorkerTests
735
723
  <packages>
736
724
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
737
725
  </packages>
738
- """.SetEOL(EOL))),
726
+ """)),
739
727
  ContentEncoding = "base64"
740
728
  },
741
729
  new DependencyFile()
@@ -751,7 +739,7 @@ public class RunWorkerTests
751
739
  <PackageReference Include="Some.Package" Version="1.0.0" />
752
740
  </ItemGroup>
753
741
  </Project>
754
- """.SetEOL(EOL))),
742
+ """)),
755
743
  ContentEncoding = "base64"
756
744
  },
757
745
  ],
@@ -876,7 +864,7 @@ public class RunWorkerTests
876
864
  <packages>
877
865
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
878
866
  </packages>
879
- """.SetEOL(EOL),
867
+ """,
880
868
  },
881
869
  new DependencyFile()
882
870
  {
@@ -897,7 +885,7 @@ public class RunWorkerTests
897
885
  </Reference>
898
886
  </ItemGroup>
899
887
  </Project>
900
- """.SetEOL(EOL),
888
+ """,
901
889
  },
902
890
  ],
903
891
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -910,14 +898,11 @@ public class RunWorkerTests
910
898
  );
911
899
  }
912
900
 
913
- [Theory]
914
- [InlineData(EOLType.CR)]
915
- [InlineData(EOLType.LF)]
916
- [InlineData(EOLType.CRLF)]
917
- public async Task UpdateHandlesPackagesConfigFromReferencedCsprojFiles(EOLType EOL)
901
+ [Fact]
902
+ public async Task UpdateHandlesPackagesConfigFromReferencedCsprojFiles()
918
903
  {
919
- var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""".SetEOL(EOL));
920
- var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""".SetEOL(EOL));
904
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
905
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
921
906
  await RunAsync(
922
907
  packages:
923
908
  [
@@ -950,13 +935,13 @@ public class RunWorkerTests
950
935
  <ProjectReference Include="../ProjectB/ProjectB.csproj" />
951
936
  </ItemGroup>
952
937
  </Project>
953
- """.SetEOL(EOL)),
938
+ """),
954
939
  ("some-dir/ProjectA/packages.config", """
955
940
  <?xml version="1.0" encoding="utf-8"?>
956
941
  <packages>
957
942
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
958
943
  </packages>
959
- """.SetEOL(EOL)),
944
+ """),
960
945
  ("some-dir/ProjectB/ProjectB.csproj", """
961
946
  <Project Sdk="Microsoft.NET.Sdk">
962
947
  <PropertyGroup>
@@ -966,13 +951,13 @@ public class RunWorkerTests
966
951
  <PackageReference Include="Some.Package" Version="1.0.0" />
967
952
  </ItemGroup>
968
953
  </Project>
969
- """.SetEOL(EOL)),
954
+ """),
970
955
  ("some-dir/ProjectB/packages.config", """
971
956
  <?xml version="1.0" encoding="utf-8"?>
972
957
  <packages>
973
958
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
974
959
  </packages>
975
- """.SetEOL(EOL)),
960
+ """),
976
961
  ],
977
962
  discoveryWorker: new TestDiscoveryWorker(_input =>
978
963
  {
@@ -1063,7 +1048,7 @@ public class RunWorkerTests
1063
1048
  <ProjectReference Include="../ProjectB/ProjectB.csproj" />
1064
1049
  </ItemGroup>
1065
1050
  </Project>
1066
- """.SetEOL(EOL));
1051
+ """);
1067
1052
  break;
1068
1053
  case ("ProjectA.csproj", "Some.Package2"):
1069
1054
  await File.WriteAllTextAsync(projectPath, """
@@ -1084,13 +1069,13 @@ public class RunWorkerTests
1084
1069
  </Reference>
1085
1070
  </ItemGroup>
1086
1071
  </Project>
1087
- """.SetEOL(EOL));
1072
+ """);
1088
1073
  await File.WriteAllTextAsync(packagesConfigPath, """
1089
1074
  <?xml version="1.0" encoding="utf-8"?>
1090
1075
  <packages>
1091
1076
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1092
1077
  </packages>
1093
- """.SetEOL(EOL));
1078
+ """);
1094
1079
  break;
1095
1080
  case ("ProjectB.csproj", "Some.Package"):
1096
1081
  await File.WriteAllTextAsync(projectPath, """
@@ -1102,7 +1087,7 @@ public class RunWorkerTests
1102
1087
  <PackageReference Include="Some.Package" Version="1.0.1" />
1103
1088
  </ItemGroup>
1104
1089
  </Project>
1105
- """.SetEOL(EOL));
1090
+ """);
1106
1091
  break;
1107
1092
  case ("ProjectB.csproj", "Some.Package2"):
1108
1093
  await File.WriteAllTextAsync(projectPath, """
@@ -1120,13 +1105,13 @@ public class RunWorkerTests
1120
1105
  </Reference>
1121
1106
  </ItemGroup>
1122
1107
  </Project>
1123
- """.SetEOL(EOL));
1108
+ """);
1124
1109
  await File.WriteAllTextAsync(packagesConfigPath, """
1125
1110
  <?xml version="1.0" encoding="utf-8"?>
1126
1111
  <packages>
1127
1112
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1128
1113
  </packages>
1129
- """.SetEOL(EOL));
1114
+ """);
1130
1115
  break;
1131
1116
  default:
1132
1117
  throw new NotSupportedException();
@@ -1157,7 +1142,7 @@ public class RunWorkerTests
1157
1142
  <packages>
1158
1143
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
1159
1144
  </packages>
1160
- """.SetEOL(EOL))),
1145
+ """)),
1161
1146
  ContentEncoding = "base64"
1162
1147
  },
1163
1148
  new DependencyFile()
@@ -1176,7 +1161,7 @@ public class RunWorkerTests
1176
1161
  <ProjectReference Include="../ProjectB/ProjectB.csproj" />
1177
1162
  </ItemGroup>
1178
1163
  </Project>
1179
- """.SetEOL(EOL))),
1164
+ """)),
1180
1165
  ContentEncoding = "base64"
1181
1166
  },
1182
1167
  new DependencyFile()
@@ -1188,7 +1173,7 @@ public class RunWorkerTests
1188
1173
  <packages>
1189
1174
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
1190
1175
  </packages>
1191
- """.SetEOL(EOL))),
1176
+ """)),
1192
1177
  ContentEncoding = "base64"
1193
1178
  },
1194
1179
  new DependencyFile()
@@ -1204,7 +1189,7 @@ public class RunWorkerTests
1204
1189
  <PackageReference Include="Some.Package" Version="1.0.0" />
1205
1190
  </ItemGroup>
1206
1191
  </Project>
1207
- """.SetEOL(EOL))),
1192
+ """)),
1208
1193
  ContentEncoding = "base64"
1209
1194
  },
1210
1195
  ],
@@ -1415,7 +1400,7 @@ public class RunWorkerTests
1415
1400
  <packages>
1416
1401
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1417
1402
  </packages>
1418
- """.SetEOL(EOL),
1403
+ """,
1419
1404
  },
1420
1405
  new DependencyFile()
1421
1406
  {
@@ -1439,7 +1424,7 @@ public class RunWorkerTests
1439
1424
  </Reference>
1440
1425
  </ItemGroup>
1441
1426
  </Project>
1442
- """.SetEOL(EOL),
1427
+ """,
1443
1428
  },
1444
1429
  new DependencyFile()
1445
1430
  {
@@ -1450,7 +1435,7 @@ public class RunWorkerTests
1450
1435
  <packages>
1451
1436
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1452
1437
  </packages>
1453
- """.SetEOL(EOL),
1438
+ """,
1454
1439
  },
1455
1440
  new DependencyFile()
1456
1441
  {
@@ -1471,7 +1456,7 @@ public class RunWorkerTests
1471
1456
  </Reference>
1472
1457
  </ItemGroup>
1473
1458
  </Project>
1474
- """.SetEOL(EOL),
1459
+ """,
1475
1460
  },
1476
1461
  ],
1477
1462
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1484,11 +1469,8 @@ public class RunWorkerTests
1484
1469
  );
1485
1470
  }
1486
1471
 
1487
- [Theory]
1488
- [InlineData(EOLType.CR)]
1489
- [InlineData(EOLType.LF)]
1490
- [InlineData(EOLType.CRLF)]
1491
- public async Task UpdatedFilesAreOnlyReportedOnce(EOLType EOL)
1472
+ [Fact]
1473
+ public async Task UpdatedFilesAreOnlyReportedOnce()
1492
1474
  {
1493
1475
  await RunAsync(
1494
1476
  job: new()
@@ -1515,14 +1497,14 @@ public class RunWorkerTests
1515
1497
  <ProjectFile Include="project2/project2.csproj" />
1516
1498
  </ItemGroup>
1517
1499
  </Project>
1518
- """.SetEOL(EOL)),
1500
+ """),
1519
1501
  ("Directory.Build.props", """
1520
1502
  <Project>
1521
1503
  <PropertyGroup>
1522
1504
  <SomePackageVersion>1.0.0</SomePackageVersion>
1523
1505
  </PropertyGroup>
1524
1506
  </Project>
1525
- """.SetEOL(EOL)),
1507
+ """),
1526
1508
  ("project1/project1.csproj", """
1527
1509
  <Project Sdk="Microsoft.NET.Sdk">
1528
1510
  <PropertyGroup>
@@ -1532,7 +1514,7 @@ public class RunWorkerTests
1532
1514
  <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1533
1515
  </ItemGroup>
1534
1516
  </Project>
1535
- """.SetEOL(EOL)),
1517
+ """),
1536
1518
  ("project2/project2.csproj", """
1537
1519
  <Project Sdk="Microsoft.NET.Sdk">
1538
1520
  <PropertyGroup>
@@ -1542,7 +1524,7 @@ public class RunWorkerTests
1542
1524
  <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1543
1525
  </ItemGroup>
1544
1526
  </Project>
1545
- """.SetEOL(EOL))
1527
+ """)
1546
1528
  ],
1547
1529
  discoveryWorker: new TestDiscoveryWorker(_input =>
1548
1530
  {
@@ -1607,7 +1589,7 @@ public class RunWorkerTests
1607
1589
  <SomePackageVersion>1.1.0</SomePackageVersion>
1608
1590
  </PropertyGroup>
1609
1591
  </Project>
1610
- """.SetEOL(EOL));
1592
+ """);
1611
1593
  return new UpdateOperationResult()
1612
1594
  {
1613
1595
  UpdateOperations = [
@@ -1634,7 +1616,7 @@ public class RunWorkerTests
1634
1616
  <SomePackageVersion>1.0.0</SomePackageVersion>
1635
1617
  </PropertyGroup>
1636
1618
  </Project>
1637
- """.SetEOL(EOL))),
1619
+ """)),
1638
1620
  ContentEncoding = "base64"
1639
1621
  },
1640
1622
  new DependencyFile()
@@ -1650,7 +1632,7 @@ public class RunWorkerTests
1650
1632
  <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1651
1633
  </ItemGroup>
1652
1634
  </Project>
1653
- """.SetEOL(EOL))),
1635
+ """)),
1654
1636
  ContentEncoding = "base64"
1655
1637
  },
1656
1638
  new DependencyFile()
@@ -1666,7 +1648,7 @@ public class RunWorkerTests
1666
1648
  <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1667
1649
  </ItemGroup>
1668
1650
  </Project>
1669
- """.SetEOL(EOL))),
1651
+ """)),
1670
1652
  ContentEncoding = "base64"
1671
1653
  },
1672
1654
  ],
@@ -1792,7 +1774,7 @@ public class RunWorkerTests
1792
1774
  <SomePackageVersion>1.1.0</SomePackageVersion>
1793
1775
  </PropertyGroup>
1794
1776
  </Project>
1795
- """.SetEOL(EOL),
1777
+ """,
1796
1778
  }
1797
1779
  ],
1798
1780
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1805,353 +1787,6 @@ public class RunWorkerTests
1805
1787
  );
1806
1788
  }
1807
1789
 
1808
- [Theory]
1809
- [InlineData(EOLType.CR)]
1810
- [InlineData(EOLType.LF)]
1811
- [InlineData(EOLType.CRLF)]
1812
- public async Task UpdatePackageWithDifferentVersionsInDifferentDirectories(EOLType EOL)
1813
- {
1814
- // this test passes `null` for discovery, analyze, and update workers to fully test the desired behavior
1815
-
1816
- // the same dependency Some.Package is reported for 3 cases:
1817
- // library1.csproj - top level dependency, already up to date
1818
- // library2.csproj - top level dependency, needs direct update
1819
- // library3.csproj - transitive dependency, needs pin
1820
- await RunAsync(
1821
- experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true },
1822
- packages: [
1823
- MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
1824
- MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0"),
1825
- MockNuGetPackage.CreateSimplePackage("Package.With.Transitive.Dependency", "0.1.0", "net8.0", [(null, [("Some.Package", "1.0.0")])]),
1826
- ],
1827
- job: new Job()
1828
- {
1829
- AllowedUpdates = [new() { UpdateType = UpdateType.Security }],
1830
- SecurityAdvisories =
1831
- [
1832
- new()
1833
- {
1834
- DependencyName = "Some.Package",
1835
- AffectedVersions = [Requirement.Parse("= 1.0.0")]
1836
- }
1837
- ],
1838
- Source = new()
1839
- {
1840
- Provider = "github",
1841
- Repo = "test/repo",
1842
- Directory = "/"
1843
- }
1844
- },
1845
- files: [
1846
- ("dirs.proj", """
1847
- <Project>
1848
- <ItemGroup>
1849
- <ProjectFile Include="library1\library1.csproj" />
1850
- <ProjectFile Include="library2\library2.csproj" />
1851
- <ProjectFile Include="library3\library3.csproj" />
1852
- </ItemGroup>
1853
- </Project>
1854
- """.SetEOL(EOL)),
1855
- ("Directory.Build.props", "<Project />"),
1856
- ("Directory.Build.targets", "<Project />"),
1857
- ("Directory.Packages.props", """
1858
- <Project>
1859
- <PropertyGroup>
1860
- <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
1861
- </PropertyGroup>
1862
- </Project>
1863
- """.SetEOL(EOL)),
1864
- ("library1/library1.csproj", """
1865
- <Project Sdk="Microsoft.NET.Sdk">
1866
- <PropertyGroup>
1867
- <TargetFramework>net8.0</TargetFramework>
1868
- </PropertyGroup>
1869
- <ItemGroup>
1870
- <PackageReference Include="Some.Package" Version="2.0.0" />
1871
- </ItemGroup>
1872
- </Project>
1873
- """.SetEOL(EOL)),
1874
- ("library2/library2.csproj", """
1875
- <Project Sdk="Microsoft.NET.Sdk">
1876
- <PropertyGroup>
1877
- <TargetFramework>net8.0</TargetFramework>
1878
- </PropertyGroup>
1879
- <ItemGroup>
1880
- <PackageReference Include="Some.Package" Version="1.0.0" />
1881
- </ItemGroup>
1882
- </Project>
1883
- """.SetEOL(EOL)),
1884
- ("library3/library3.csproj", """
1885
- <Project Sdk="Microsoft.NET.Sdk">
1886
- <PropertyGroup>
1887
- <TargetFramework>net8.0</TargetFramework>
1888
- </PropertyGroup>
1889
- <ItemGroup>
1890
- <PackageReference Include="Package.With.Transitive.Dependency" Version="0.1.0" />
1891
- </ItemGroup>
1892
- </Project>
1893
- """.SetEOL(EOL)),
1894
- ],
1895
- discoveryWorker: null,
1896
- analyzeWorker: null,
1897
- updaterWorker: null,
1898
- expectedResult: new RunResult()
1899
- {
1900
- Base64DependencyFiles =
1901
- [
1902
- new DependencyFile()
1903
- {
1904
- Directory = "/",
1905
- Name = "Directory.Build.props",
1906
- Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("<Project />")),
1907
- ContentEncoding = "base64"
1908
- },
1909
- new DependencyFile()
1910
- {
1911
- Directory = "/",
1912
- Name = "Directory.Build.targets",
1913
- Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("<Project />")),
1914
- ContentEncoding = "base64"
1915
- },
1916
- new DependencyFile()
1917
- {
1918
- Directory = "/",
1919
- Name = "Directory.Packages.props",
1920
- Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1921
- <Project>
1922
- <PropertyGroup>
1923
- <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
1924
- </PropertyGroup>
1925
- </Project>
1926
- """.SetEOL(EOL))),
1927
- ContentEncoding = "base64"
1928
- },
1929
- new DependencyFile()
1930
- {
1931
- Directory = "/library1",
1932
- Name = "library1.csproj",
1933
- Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1934
- <Project Sdk="Microsoft.NET.Sdk">
1935
- <PropertyGroup>
1936
- <TargetFramework>net8.0</TargetFramework>
1937
- </PropertyGroup>
1938
- <ItemGroup>
1939
- <PackageReference Include="Some.Package" Version="2.0.0" />
1940
- </ItemGroup>
1941
- </Project>
1942
- """.SetEOL(EOL))),
1943
- ContentEncoding = "base64"
1944
- },
1945
- new DependencyFile()
1946
- {
1947
- Directory = "/library2",
1948
- Name = "library2.csproj",
1949
- Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1950
- <Project Sdk="Microsoft.NET.Sdk">
1951
- <PropertyGroup>
1952
- <TargetFramework>net8.0</TargetFramework>
1953
- </PropertyGroup>
1954
- <ItemGroup>
1955
- <PackageReference Include="Some.Package" Version="1.0.0" />
1956
- </ItemGroup>
1957
- </Project>
1958
- """.SetEOL(EOL))),
1959
- ContentEncoding = "base64"
1960
- },
1961
- new DependencyFile()
1962
- {
1963
- Directory = "/library3",
1964
- Name = "library3.csproj",
1965
- Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1966
- <Project Sdk="Microsoft.NET.Sdk">
1967
- <PropertyGroup>
1968
- <TargetFramework>net8.0</TargetFramework>
1969
- </PropertyGroup>
1970
- <ItemGroup>
1971
- <PackageReference Include="Package.With.Transitive.Dependency" Version="0.1.0" />
1972
- </ItemGroup>
1973
- </Project>
1974
- """.SetEOL(EOL))),
1975
- ContentEncoding = "base64"
1976
- }
1977
- ],
1978
- BaseCommitSha = "TEST-COMMIT-SHA",
1979
- },
1980
- expectedApiMessages: [
1981
- new UpdatedDependencyList()
1982
- {
1983
- Dependencies = [
1984
- new()
1985
- {
1986
- Name = "Some.Package",
1987
- Version = "2.0.0",
1988
- Requirements = [
1989
- new()
1990
- {
1991
- Requirement = "2.0.0",
1992
- File = "/library1/library1.csproj",
1993
- Groups = ["dependencies"],
1994
- }
1995
- ]
1996
- },
1997
- new()
1998
- {
1999
- Name = "Some.Package",
2000
- Version = "1.0.0",
2001
- Requirements = [
2002
- new()
2003
- {
2004
- Requirement = "1.0.0",
2005
- File = "/library2/library2.csproj",
2006
- Groups = ["dependencies"],
2007
- }
2008
- ]
2009
- },
2010
- new()
2011
- {
2012
- Name = "Package.With.Transitive.Dependency",
2013
- Version = "0.1.0",
2014
- Requirements = [
2015
- new()
2016
- {
2017
- Requirement = "0.1.0",
2018
- File = "/library3/library3.csproj",
2019
- Groups = ["dependencies"],
2020
- }
2021
- ]
2022
- },
2023
- new()
2024
- {
2025
- Name = "Some.Package",
2026
- Version = "1.0.0",
2027
- Requirements = [
2028
- new()
2029
- {
2030
- Requirement = "1.0.0",
2031
- File = "/library3/library3.csproj",
2032
- Groups = ["dependencies"],
2033
- }
2034
- ]
2035
- },
2036
- ],
2037
- DependencyFiles = [
2038
- "/Directory.Build.props",
2039
- "/Directory.Build.targets",
2040
- "/Directory.Packages.props",
2041
- "/library1/library1.csproj",
2042
- "/library2/library2.csproj",
2043
- "/library3/library3.csproj",
2044
- ],
2045
- },
2046
- new IncrementMetric()
2047
- {
2048
- Metric = "updater.started",
2049
- Tags = new()
2050
- {
2051
- ["operation"] = "create_security_pr"
2052
- }
2053
- },
2054
- new CreatePullRequest()
2055
- {
2056
- Dependencies = [
2057
- new()
2058
- {
2059
- Name = "Some.Package",
2060
- Version = "2.0.0",
2061
- Requirements = [
2062
- new()
2063
- {
2064
- Requirement = "2.0.0",
2065
- File = "/library2/library2.csproj",
2066
- Groups = ["dependencies"],
2067
- Source = new()
2068
- {
2069
- SourceUrl = null,
2070
- Type = "nuget_repo",
2071
- }
2072
- }
2073
- ],
2074
- PreviousVersion = "1.0.0",
2075
- PreviousRequirements = [
2076
- new()
2077
- {
2078
- Requirement = "1.0.0",
2079
- File = "/library2/library2.csproj",
2080
- Groups = ["dependencies"],
2081
- }
2082
- ],
2083
- },
2084
- new()
2085
- {
2086
- Name = "Some.Package",
2087
- Version = "2.0.0",
2088
- Requirements = [
2089
- new()
2090
- {
2091
- Requirement = "2.0.0",
2092
- File = "/library3/library3.csproj",
2093
- Groups = ["dependencies"],
2094
- Source = new()
2095
- {
2096
- SourceUrl = null,
2097
- Type = "nuget_repo",
2098
- }
2099
- }
2100
- ],
2101
- PreviousVersion = "1.0.0",
2102
- PreviousRequirements = [
2103
- new()
2104
- {
2105
- Requirement = "1.0.0",
2106
- File = "/library3/library3.csproj",
2107
- Groups = ["dependencies"],
2108
- }
2109
- ],
2110
- },
2111
- ],
2112
- UpdatedDependencyFiles = [
2113
- new()
2114
- {
2115
- Directory = "/library2",
2116
- Name = "library2.csproj",
2117
- Content = """
2118
- <Project Sdk="Microsoft.NET.Sdk">
2119
- <PropertyGroup>
2120
- <TargetFramework>net8.0</TargetFramework>
2121
- </PropertyGroup>
2122
- <ItemGroup>
2123
- <PackageReference Include="Some.Package" Version="2.0.0" />
2124
- </ItemGroup>
2125
- </Project>
2126
- """.SetEOL(EOL)
2127
- },
2128
- new()
2129
- {
2130
- Directory = "/library3",
2131
- Name = "library3.csproj",
2132
- Content = """
2133
- <Project Sdk="Microsoft.NET.Sdk">
2134
- <PropertyGroup>
2135
- <TargetFramework>net8.0</TargetFramework>
2136
- </PropertyGroup>
2137
- <ItemGroup>
2138
- <PackageReference Include="Package.With.Transitive.Dependency" Version="0.1.0" />
2139
- <PackageReference Include="Some.Package" Version="2.0.0" />
2140
- </ItemGroup>
2141
- </Project>
2142
- """.SetEOL(EOL)
2143
- }
2144
- ],
2145
- BaseCommitSha = "TEST-COMMIT-SHA",
2146
- CommitMessage = TestPullRequestCommitMessage,
2147
- PrTitle = TestPullRequestTitle,
2148
- PrBody = TestPullRequestBody
2149
- },
2150
- new MarkAsProcessed("TEST-COMMIT-SHA")
2151
- ]
2152
- );
2153
- }
2154
-
2155
1790
  [Fact]
2156
1791
  public async Task PackageListedInSecurityAdvisoriesSectionIsNotVulnerable()
2157
1792
  {
@@ -2894,7 +2529,262 @@ public class RunWorkerTests
2894
2529
  );
2895
2530
  }
2896
2531
 
2897
- private static Task RunAsync(Job job, TestFile[] files, IDiscoveryWorker? discoveryWorker, IAnalyzeWorker? analyzeWorker, IUpdaterWorker? updaterWorker, RunResult expectedResult, object[] expectedApiMessages, MockNuGetPackage[]? packages = null, ExperimentsManager? experimentsManager = null, string? repoContentsPath = null)
2532
+ [Fact]
2533
+ public async Task LineEndingsAreDetectedAndRestored()
2534
+ {
2535
+ await RunAsync(
2536
+ job: new Job()
2537
+ {
2538
+ Source = new()
2539
+ {
2540
+ Provider = "github",
2541
+ Repo = "test/repo",
2542
+ Directory = "/",
2543
+ }
2544
+ },
2545
+ files:
2546
+ [
2547
+ // initially LF
2548
+ ("file1", string.Concat(
2549
+ "file1-line1\n",
2550
+ "file1-line2\n",
2551
+ "file1-line3\n"
2552
+ )
2553
+ ),
2554
+ // initially CRLF
2555
+ ("file2", string.Concat(
2556
+ "file2-line1\r\n",
2557
+ "file2-line2\r\n",
2558
+ "file2-line3\r\n"
2559
+ )
2560
+ )
2561
+ ],
2562
+ discoveryWorker: TestDiscoveryWorker.FromResults(("/", new()
2563
+ {
2564
+ Path = "/",
2565
+ Projects = [
2566
+ new()
2567
+ {
2568
+ FilePath = "file1",
2569
+ Dependencies = [new("Dependency1", "1.0.0", DependencyType.PackageReference)],
2570
+ ImportedFiles = [],
2571
+ AdditionalFiles = [],
2572
+ },
2573
+ new()
2574
+ {
2575
+ FilePath = "file2",
2576
+ Dependencies = [new("Dependency2", "2.0.0", DependencyType.PackageReference)],
2577
+ ImportedFiles = [],
2578
+ AdditionalFiles = [],
2579
+ }
2580
+ ]
2581
+ })),
2582
+ analyzeWorker: new TestAnalyzeWorker(args =>
2583
+ {
2584
+ AnalysisResult result = args.Item3.Name switch
2585
+ {
2586
+ "Dependency1" => new()
2587
+ {
2588
+ CanUpdate = true,
2589
+ UpdatedVersion = "1.0.1",
2590
+ UpdatedDependencies = [new("Dependency1", "1.0.1", DependencyType.PackageReference)],
2591
+ },
2592
+ "Dependency2" => new()
2593
+ {
2594
+ CanUpdate = true,
2595
+ UpdatedVersion = "2.0.1",
2596
+ UpdatedDependencies = [new("Dependency2", "2.0.1", DependencyType.PackageReference)],
2597
+ },
2598
+ _ => throw new NotImplementedException()
2599
+ };
2600
+ return Task.FromResult(result);
2601
+ }),
2602
+ updaterWorker: new TestUpdaterWorker(async args =>
2603
+ {
2604
+ var (repoRoot, filePath, dependencyName, _previousVersion, _newVersion, _isTransitive) = args;
2605
+
2606
+ // file is explicitly updated with CR
2607
+ var (updatedFileContent, newVersion) = dependencyName switch
2608
+ {
2609
+ "Dependency1" => (string.Concat(
2610
+ "file1-line1-updated\r",
2611
+ "file1-line2-updated\r",
2612
+ "file1-line3-updated\r"), "1.0.1"),
2613
+ "Dependency2" => (string.Concat(
2614
+ "file2-line1-updated\r",
2615
+ "file2-line2-updated\r",
2616
+ "file2-line3-updated\r"), "2.0.1"),
2617
+ _ => throw new NotImplementedException(),
2618
+ };
2619
+ var fullFilePath = Path.Join(repoRoot, filePath);
2620
+ await File.WriteAllTextAsync(fullFilePath, updatedFileContent);
2621
+ return new UpdateOperationResult()
2622
+ {
2623
+ UpdateOperations = [new DirectUpdate()
2624
+ {
2625
+ DependencyName = dependencyName,
2626
+ NewVersion = NuGetVersion.Parse(newVersion),
2627
+ UpdatedFiles = [filePath],
2628
+ }],
2629
+ };
2630
+ }),
2631
+ expectedResult: new()
2632
+ {
2633
+ Base64DependencyFiles = [
2634
+ new()
2635
+ {
2636
+ Directory = "/",
2637
+ Name = "file1",
2638
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Concat(
2639
+ "file1-line1\n",
2640
+ "file1-line2\n",
2641
+ "file1-line3\n"))),
2642
+ ContentEncoding = "base64",
2643
+ },
2644
+ new()
2645
+ {
2646
+ Directory = "/",
2647
+ Name = "file2",
2648
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Concat(
2649
+ "file2-line1\r\n",
2650
+ "file2-line2\r\n",
2651
+ "file2-line3\r\n"))),
2652
+ ContentEncoding = "base64",
2653
+ }
2654
+ ],
2655
+ BaseCommitSha = "TEST-COMMIT-SHA",
2656
+ },
2657
+ expectedApiMessages: [
2658
+ new UpdatedDependencyList()
2659
+ {
2660
+ Dependencies = [
2661
+ new()
2662
+ {
2663
+ Name = "Dependency1",
2664
+ Version = "1.0.0",
2665
+ Requirements = [
2666
+ new()
2667
+ {
2668
+ Requirement = "1.0.0",
2669
+ File = "/file1",
2670
+ Groups = ["dependencies"],
2671
+ }
2672
+ ]
2673
+ },
2674
+ new()
2675
+ {
2676
+ Name = "Dependency2",
2677
+ Version = "2.0.0",
2678
+ Requirements = [
2679
+ new()
2680
+ {
2681
+ Requirement = "2.0.0",
2682
+ File = "/file2",
2683
+ Groups = ["dependencies"]
2684
+ }
2685
+ ]
2686
+ }
2687
+ ],
2688
+ DependencyFiles = ["/file1", "/file2"]
2689
+ },
2690
+ new IncrementMetric()
2691
+ {
2692
+ Metric = "updater.started",
2693
+ Tags = new()
2694
+ {
2695
+ ["operation"] = "group_update_all_versions"
2696
+ }
2697
+ },
2698
+ new CreatePullRequest()
2699
+ {
2700
+ Dependencies =
2701
+ [
2702
+ new ReportedDependency()
2703
+ {
2704
+ Name = "Dependency1",
2705
+ Version = "1.0.1",
2706
+ Requirements =
2707
+ [
2708
+ new ReportedRequirement()
2709
+ {
2710
+ Requirement = "1.0.1",
2711
+ File = "/file1",
2712
+ Groups = ["dependencies"],
2713
+ Source = new() { SourceUrl = null },
2714
+ }
2715
+ ],
2716
+ PreviousVersion = "1.0.0",
2717
+ PreviousRequirements =
2718
+ [
2719
+ new ReportedRequirement()
2720
+ {
2721
+ Requirement = "1.0.0",
2722
+ File = "/file1",
2723
+ Groups = ["dependencies"],
2724
+ }
2725
+ ],
2726
+ },
2727
+ new ReportedDependency()
2728
+ {
2729
+ Name = "Dependency2",
2730
+ Version = "2.0.1",
2731
+ Requirements =
2732
+ [
2733
+ new ReportedRequirement()
2734
+ {
2735
+ Requirement = "2.0.1",
2736
+ File = "/file2",
2737
+ Groups = ["dependencies"],
2738
+ Source = new() { SourceUrl = null },
2739
+ }
2740
+ ],
2741
+ PreviousVersion = "2.0.0",
2742
+ PreviousRequirements =
2743
+ [
2744
+ new ReportedRequirement()
2745
+ {
2746
+ Requirement = "2.0.0",
2747
+ File = "/file2",
2748
+ Groups = ["dependencies"],
2749
+ }
2750
+ ],
2751
+ },
2752
+ ],
2753
+ UpdatedDependencyFiles =
2754
+ [
2755
+ // original line endings have been restored
2756
+ new DependencyFile()
2757
+ {
2758
+ Name = "file1",
2759
+ Directory = "/",
2760
+ Content = string.Concat(
2761
+ "file1-line1-updated\n",
2762
+ "file1-line2-updated\n",
2763
+ "file1-line3-updated\n"
2764
+ ),
2765
+ },
2766
+ new DependencyFile()
2767
+ {
2768
+ Name = "file2",
2769
+ Directory = "/",
2770
+ Content = string.Concat(
2771
+ "file2-line1-updated\r\n",
2772
+ "file2-line2-updated\r\n",
2773
+ "file2-line3-updated\r\n"
2774
+ ),
2775
+ },
2776
+ ],
2777
+ BaseCommitSha = "TEST-COMMIT-SHA",
2778
+ CommitMessage = TestPullRequestCommitMessage,
2779
+ PrTitle = TestPullRequestTitle,
2780
+ PrBody = TestPullRequestBody,
2781
+ },
2782
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
2783
+ ]
2784
+ );
2785
+ }
2786
+
2787
+ internal static Task RunAsync(Job job, TestFile[] files, IDiscoveryWorker? discoveryWorker, IAnalyzeWorker? analyzeWorker, IUpdaterWorker? updaterWorker, RunResult expectedResult, object[] expectedApiMessages, MockNuGetPackage[]? packages = null, ExperimentsManager? experimentsManager = null, string? repoContentsPath = null)
2898
2788
  {
2899
2789
  var rawTestFiles = files.Select(f => (f.Path, Encoding.UTF8.GetBytes(f.Content))).ToArray();
2900
2790
  return RunAsync(job, rawTestFiles, discoveryWorker, analyzeWorker, updaterWorker, expectedResult, expectedApiMessages, packages, experimentsManager, repoContentsPath);