dependabot-nuget 0.288.0 → 0.289.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/Directory.Packages.props +19 -17
  3. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Packaging/NuGet.Packaging.csproj +0 -1
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +3 -1
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +23 -3
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +30 -15
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +1 -1
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementArrayConverter.cs +39 -0
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +1 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/ShellGitCommandHandler.cs +1 -1
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +60 -66
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +2 -2
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +2 -2
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +11 -3
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +1 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +2 -4
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +54 -11
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +0 -1
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +1 -2
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +1 -1
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +2 -2
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +43 -54
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +13 -43
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +4 -4
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -5
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -10
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +38 -33
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +12 -11
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +16 -12
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +1 -1
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +19 -19
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +11 -1
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +18 -17
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -17
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +17 -9
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +96 -0
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +87 -5
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +2 -5
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +16 -0
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +6 -0
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +147 -36
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +184 -48
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +5 -5
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +32 -10
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +400 -76
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +2 -2
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +60 -2
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +1 -1
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs +1 -1
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +4 -2
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +40 -0
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1 -1
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +1 -1
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LinuxOnlyAttribute.cs +12 -0
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +8 -5
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +47 -2
  57. data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +3 -1
  58. data/lib/dependabot/nuget/file_fetcher.rb +12 -393
  59. data/lib/dependabot/nuget/file_parser.rb +23 -60
  60. data/lib/dependabot/nuget/file_updater.rb +21 -16
  61. data/lib/dependabot/nuget/native_discovery/native_dependency_file_discovery.rb +2 -9
  62. data/lib/dependabot/nuget/native_discovery/native_discovery_json_reader.rb +183 -77
  63. data/lib/dependabot/nuget/native_discovery/native_project_discovery.rb +25 -3
  64. data/lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb +1 -8
  65. data/lib/dependabot/nuget/native_update_checker/native_update_checker.rb +17 -4
  66. metadata +8 -9
  67. data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props +0 -29
  68. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs +0 -17
  69. data/lib/dependabot/nuget/file_fetcher/import_paths_finder.rb +0 -73
  70. data/lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb +0 -60
@@ -63,7 +63,10 @@ public class RunWorkerTests
63
63
  Dependencies =
64
64
  [
65
65
  new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"]),
66
- ]
66
+ ],
67
+ ReferencedProjectPaths = [],
68
+ ImportedFiles = [],
69
+ AdditionalFiles = [],
67
70
  }
68
71
  ]
69
72
  });
@@ -268,7 +271,10 @@ public class RunWorkerTests
268
271
  [
269
272
  new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"]),
270
273
  new("Some.Package2", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"]),
271
- ]
274
+ ],
275
+ ReferencedProjectPaths = [],
276
+ ImportedFiles = [],
277
+ AdditionalFiles = [],
272
278
  }
273
279
  ]
274
280
  });
@@ -288,7 +294,7 @@ public class RunWorkerTests
288
294
  }),
289
295
  updaterWorker: new TestUpdaterWorker(async input =>
290
296
  {
291
- Assert.Contains(input.Item3, ["Some.Package", "Some.Package2"]);
297
+ Assert.Contains(input.Item3, new List<string> { "Some.Package", "Some.Package2" });
292
298
  Assert.Equal("1.0.0", input.Item4);
293
299
  Assert.Equal("1.0.1", input.Item5);
294
300
  var projectPath = input.Item1 + input.Item2;
@@ -584,7 +590,10 @@ public class RunWorkerTests
584
590
  [
585
591
  new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"]),
586
592
  new("Some.Package2", "2.0.0", DependencyType.PackagesConfig, TargetFrameworks: ["net8.0"]),
587
- ]
593
+ ],
594
+ ReferencedProjectPaths = [],
595
+ ImportedFiles = [],
596
+ AdditionalFiles = ["packages.config"],
588
597
  }
589
598
  ]
590
599
  });
@@ -607,9 +616,9 @@ public class RunWorkerTests
607
616
  CanUpdate = true,
608
617
  UpdatedVersion = "2.0.1",
609
618
  UpdatedDependencies =
610
- [
611
- new("Some.Package2", "2.0.1", DependencyType.Unknown, TargetFrameworks: ["net8.0"], InfoUrl: "https://nuget.example.com/some-package2"),
612
- ]
619
+ [
620
+ new("Some.Package2", "2.0.1", DependencyType.Unknown, TargetFrameworks: ["net8.0"], InfoUrl: "https://nuget.example.com/some-package2"),
621
+ ]
613
622
  },
614
623
  _ => throw new NotSupportedException(),
615
624
  };
@@ -674,6 +683,17 @@ public class RunWorkerTests
674
683
  {
675
684
  Base64DependencyFiles =
676
685
  [
686
+ new DependencyFile()
687
+ {
688
+ Directory = "/some-dir",
689
+ Name = "packages.config",
690
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
691
+ <?xml version="1.0" encoding="utf-8"?>
692
+ <packages>
693
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
694
+ </packages>
695
+ """))
696
+ },
677
697
  new DependencyFile()
678
698
  {
679
699
  Directory = "/some-dir",
@@ -689,17 +709,6 @@ public class RunWorkerTests
689
709
  </Project>
690
710
  """))
691
711
  },
692
- new DependencyFile()
693
- {
694
- Directory = "/some-dir",
695
- Name = "packages.config",
696
- Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
697
- <?xml version="1.0" encoding="utf-8"?>
698
- <packages>
699
- <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
700
- </packages>
701
- """))
702
- }
703
712
  ],
704
713
  BaseCommitSha = "TEST-COMMIT-SHA",
705
714
  },
@@ -732,13 +741,13 @@ public class RunWorkerTests
732
741
  new ReportedRequirement()
733
742
  {
734
743
  Requirement = "2.0.0",
735
- File = "/some-dir/packages.config",
744
+ File = "/some-dir/project.csproj",
736
745
  Groups = ["dependencies"],
737
746
  }
738
747
  ]
739
748
  }
740
749
  ],
741
- DependencyFiles = ["/some-dir/project.csproj", "/some-dir/packages.config"],
750
+ DependencyFiles = ["/some-dir/packages.config", "/some-dir/project.csproj"],
742
751
  },
743
752
  new IncrementMetric()
744
753
  {
@@ -790,7 +799,7 @@ public class RunWorkerTests
790
799
  new ReportedRequirement()
791
800
  {
792
801
  Requirement = "2.0.1",
793
- File = "/some-dir/packages.config",
802
+ File = "/some-dir/project.csproj",
794
803
  Groups = ["dependencies"],
795
804
  Source = new()
796
805
  {
@@ -805,7 +814,7 @@ public class RunWorkerTests
805
814
  new ReportedRequirement()
806
815
  {
807
816
  Requirement = "2.0.0",
808
- File = "/some-dir/packages.config",
817
+ File = "/some-dir/project.csproj",
809
818
  Groups = ["dependencies"],
810
819
  }
811
820
  ],
@@ -813,6 +822,17 @@ public class RunWorkerTests
813
822
  ],
814
823
  UpdatedDependencyFiles =
815
824
  [
825
+ new DependencyFile()
826
+ {
827
+ Name = "packages.config",
828
+ Directory = "/some-dir",
829
+ Content = """
830
+ <?xml version="1.0" encoding="utf-8"?>
831
+ <packages>
832
+ <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
833
+ </packages>
834
+ """,
835
+ },
816
836
  new DependencyFile()
817
837
  {
818
838
  Name = "project.csproj",
@@ -834,17 +854,6 @@ public class RunWorkerTests
834
854
  </Project>
835
855
  """,
836
856
  },
837
- new DependencyFile()
838
- {
839
- Name = "packages.config",
840
- Directory = "/some-dir",
841
- Content = """
842
- <?xml version="1.0" encoding="utf-8"?>
843
- <packages>
844
- <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
845
- </packages>
846
- """,
847
- },
848
857
  ],
849
858
  BaseCommitSha = "TEST-COMMIT-SHA",
850
859
  CommitMessage = "TODO: message",
@@ -936,7 +945,10 @@ public class RunWorkerTests
936
945
  [
937
946
  new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"]),
938
947
  new("Some.Package2", "2.0.0", DependencyType.PackagesConfig, TargetFrameworks: ["net8.0"]),
939
- ]
948
+ ],
949
+ ReferencedProjectPaths = [],
950
+ ImportedFiles = [],
951
+ AdditionalFiles = ["packages.config"],
940
952
  },
941
953
  new()
942
954
  {
@@ -946,7 +958,10 @@ public class RunWorkerTests
946
958
  [
947
959
  new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"]),
948
960
  new("Some.Package2", "2.0.0", DependencyType.PackagesConfig, TargetFrameworks: ["net8.0"]),
949
- ]
961
+ ],
962
+ ReferencedProjectPaths = [],
963
+ ImportedFiles = [],
964
+ AdditionalFiles = ["packages.config"],
950
965
  }
951
966
  ]
952
967
  });
@@ -969,9 +984,9 @@ public class RunWorkerTests
969
984
  CanUpdate = true,
970
985
  UpdatedVersion = "2.0.1",
971
986
  UpdatedDependencies =
972
- [
973
- new("Some.Package2", "2.0.1", DependencyType.Unknown, TargetFrameworks: ["net8.0"], InfoUrl: "https://nuget.example.com/some-package2"),
974
- ]
987
+ [
988
+ new("Some.Package2", "2.0.1", DependencyType.Unknown, TargetFrameworks: ["net8.0"], InfoUrl: "https://nuget.example.com/some-package2"),
989
+ ]
975
990
  },
976
991
  _ => throw new NotSupportedException(),
977
992
  };
@@ -1081,22 +1096,7 @@ public class RunWorkerTests
1081
1096
  [
1082
1097
  new DependencyFile()
1083
1098
  {
1084
- Directory = "/some-dir/ProjectB",
1085
- Name = "ProjectB.csproj",
1086
- Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1087
- <Project Sdk="Microsoft.NET.Sdk">
1088
- <PropertyGroup>
1089
- <TargetFramework>net8.0</TargetFramework>
1090
- </PropertyGroup>
1091
- <ItemGroup>
1092
- <PackageReference Include="Some.Package" Version="1.0.0" />
1093
- </ItemGroup>
1094
- </Project>
1095
- """))
1096
- },
1097
- new DependencyFile()
1098
- {
1099
- Directory = "/some-dir/ProjectB",
1099
+ Directory = "/some-dir/ProjectA",
1100
1100
  Name = "packages.config",
1101
1101
  Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1102
1102
  <?xml version="1.0" encoding="utf-8"?>
@@ -1125,7 +1125,7 @@ public class RunWorkerTests
1125
1125
  },
1126
1126
  new DependencyFile()
1127
1127
  {
1128
- Directory = "/some-dir/ProjectA",
1128
+ Directory = "/some-dir/ProjectB",
1129
1129
  Name = "packages.config",
1130
1130
  Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1131
1131
  <?xml version="1.0" encoding="utf-8"?>
@@ -1134,6 +1134,21 @@ public class RunWorkerTests
1134
1134
  </packages>
1135
1135
  """))
1136
1136
  },
1137
+ new DependencyFile()
1138
+ {
1139
+ Directory = "/some-dir/ProjectB",
1140
+ Name = "ProjectB.csproj",
1141
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1142
+ <Project Sdk="Microsoft.NET.Sdk">
1143
+ <PropertyGroup>
1144
+ <TargetFramework>net8.0</TargetFramework>
1145
+ </PropertyGroup>
1146
+ <ItemGroup>
1147
+ <PackageReference Include="Some.Package" Version="1.0.0" />
1148
+ </ItemGroup>
1149
+ </Project>
1150
+ """))
1151
+ },
1137
1152
  ],
1138
1153
  BaseCommitSha = "TEST-COMMIT-SHA",
1139
1154
  },
@@ -1166,7 +1181,7 @@ public class RunWorkerTests
1166
1181
  new ReportedRequirement()
1167
1182
  {
1168
1183
  Requirement = "2.0.0",
1169
- File = "/some-dir/ProjectB/packages.config",
1184
+ File = "/some-dir/ProjectB/ProjectB.csproj",
1170
1185
  Groups = ["dependencies"],
1171
1186
  }
1172
1187
  ]
@@ -1194,13 +1209,13 @@ public class RunWorkerTests
1194
1209
  new ReportedRequirement()
1195
1210
  {
1196
1211
  Requirement = "2.0.0",
1197
- File = "/some-dir/ProjectA/packages.config",
1212
+ File = "/some-dir/ProjectA/ProjectA.csproj",
1198
1213
  Groups = ["dependencies"],
1199
1214
  }
1200
1215
  ]
1201
1216
  },
1202
1217
  ],
1203
- DependencyFiles = ["/some-dir/ProjectB/ProjectB.csproj", "/some-dir/ProjectA/ProjectA.csproj", "/some-dir/ProjectB/packages.config", "/some-dir/ProjectA/packages.config"],
1218
+ DependencyFiles = ["/some-dir/ProjectA/packages.config", "/some-dir/ProjectA/ProjectA.csproj", "/some-dir/ProjectB/packages.config", "/some-dir/ProjectB/ProjectB.csproj"],
1204
1219
  },
1205
1220
  new IncrementMetric()
1206
1221
  {
@@ -1252,7 +1267,7 @@ public class RunWorkerTests
1252
1267
  new ReportedRequirement()
1253
1268
  {
1254
1269
  Requirement = "2.0.1",
1255
- File = "/some-dir/ProjectB/packages.config",
1270
+ File = "/some-dir/ProjectB/ProjectB.csproj",
1256
1271
  Groups = ["dependencies"],
1257
1272
  Source = new()
1258
1273
  {
@@ -1267,7 +1282,7 @@ public class RunWorkerTests
1267
1282
  new ReportedRequirement()
1268
1283
  {
1269
1284
  Requirement = "2.0.0",
1270
- File = "/some-dir/ProjectB/packages.config",
1285
+ File = "/some-dir/ProjectB/ProjectB.csproj",
1271
1286
  Groups = ["dependencies"],
1272
1287
  }
1273
1288
  ],
@@ -1310,7 +1325,7 @@ public class RunWorkerTests
1310
1325
  new ReportedRequirement()
1311
1326
  {
1312
1327
  Requirement = "2.0.1",
1313
- File = "/some-dir/ProjectA/packages.config",
1328
+ File = "/some-dir/ProjectA/ProjectA.csproj",
1314
1329
  Groups = ["dependencies"],
1315
1330
  Source = new()
1316
1331
  {
@@ -1325,7 +1340,7 @@ public class RunWorkerTests
1325
1340
  new ReportedRequirement()
1326
1341
  {
1327
1342
  Requirement = "2.0.0",
1328
- File = "/some-dir/ProjectA/packages.config",
1343
+ File = "/some-dir/ProjectA/ProjectA.csproj",
1329
1344
  Groups = ["dependencies"],
1330
1345
  }
1331
1346
  ],
@@ -1335,8 +1350,19 @@ public class RunWorkerTests
1335
1350
  [
1336
1351
  new DependencyFile()
1337
1352
  {
1338
- Name = "ProjectB.csproj",
1339
- Directory = "/some-dir/ProjectB",
1353
+ Name = "packages.config",
1354
+ Directory = "/some-dir/ProjectA",
1355
+ Content = """
1356
+ <?xml version="1.0" encoding="utf-8"?>
1357
+ <packages>
1358
+ <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1359
+ </packages>
1360
+ """,
1361
+ },
1362
+ new DependencyFile()
1363
+ {
1364
+ Name = "ProjectA.csproj",
1365
+ Directory = "/some-dir/ProjectA",
1340
1366
  Content = """
1341
1367
  <Project Sdk="Microsoft.NET.Sdk">
1342
1368
  <PropertyGroup>
@@ -1345,6 +1371,9 @@ public class RunWorkerTests
1345
1371
  <ItemGroup>
1346
1372
  <PackageReference Include="Some.Package" Version="1.0.1" />
1347
1373
  </ItemGroup>
1374
+ <ItemGroup>
1375
+ <ProjectReference Include="../ProjectB/ProjectB.csproj" />
1376
+ </ItemGroup>
1348
1377
  <ItemGroup>
1349
1378
  <Reference Include="Some.Package2">
1350
1379
  <HintPath>..\packages\Some.Package2.2.0.1\lib\net8.0\Some.Package2.dll</HintPath>
@@ -1367,8 +1396,8 @@ public class RunWorkerTests
1367
1396
  },
1368
1397
  new DependencyFile()
1369
1398
  {
1370
- Name = "ProjectA.csproj",
1371
- Directory = "/some-dir/ProjectA",
1399
+ Name = "ProjectB.csproj",
1400
+ Directory = "/some-dir/ProjectB",
1372
1401
  Content = """
1373
1402
  <Project Sdk="Microsoft.NET.Sdk">
1374
1403
  <PropertyGroup>
@@ -1377,9 +1406,6 @@ public class RunWorkerTests
1377
1406
  <ItemGroup>
1378
1407
  <PackageReference Include="Some.Package" Version="1.0.1" />
1379
1408
  </ItemGroup>
1380
- <ItemGroup>
1381
- <ProjectReference Include="../ProjectB/ProjectB.csproj" />
1382
- </ItemGroup>
1383
1409
  <ItemGroup>
1384
1410
  <Reference Include="Some.Package2">
1385
1411
  <HintPath>..\packages\Some.Package2.2.0.1\lib\net8.0\Some.Package2.dll</HintPath>
@@ -1389,17 +1415,315 @@ public class RunWorkerTests
1389
1415
  </Project>
1390
1416
  """,
1391
1417
  },
1418
+ ],
1419
+ BaseCommitSha = "TEST-COMMIT-SHA",
1420
+ CommitMessage = "TODO: message",
1421
+ PrTitle = "TODO: title",
1422
+ PrBody = "TODO: body",
1423
+ },
1424
+ new MarkAsProcessed("TEST-COMMIT-SHA")
1425
+ ]
1426
+ );
1427
+ }
1428
+
1429
+ [Fact]
1430
+ public async Task UpdatedFilesAreOnlyReportedOnce()
1431
+ {
1432
+ await RunAsync(
1433
+ job: new()
1434
+ {
1435
+ PackageManager = "nuget",
1436
+ Source = new()
1437
+ {
1438
+ Provider = "github",
1439
+ Repo = "test/repo",
1440
+ Directory = "/",
1441
+ },
1442
+ AllowedUpdates =
1443
+ [
1444
+ new() { UpdateType = "all" }
1445
+ ]
1446
+ },
1447
+ packages:
1448
+ [
1449
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
1450
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.1.0", "net8.0"),
1451
+ ],
1452
+ files:
1453
+ [
1454
+ ("dirs.proj", """
1455
+ <Project>
1456
+ <ItemGroup>
1457
+ <ProjectFile Include="project1/project1.csproj" />
1458
+ <ProjectFile Include="project2/project2.csproj" />
1459
+ </ItemGroup>
1460
+ </Project>
1461
+ """),
1462
+ ("Directory.Build.props", """
1463
+ <Project>
1464
+ <PropertyGroup>
1465
+ <SomePackageVersion>1.0.0</SomePackageVersion>
1466
+ </PropertyGroup>
1467
+ </Project>
1468
+ """),
1469
+ ("project1/project1.csproj", """
1470
+ <Project Sdk="Microsoft.NET.Sdk">
1471
+ <PropertyGroup>
1472
+ <TargetFramework>net8.0</TargetFramework>
1473
+ </PropertyGroup>
1474
+ <ItemGroup>
1475
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1476
+ </ItemGroup>
1477
+ </Project>
1478
+ """),
1479
+ ("project2/project2.csproj", """
1480
+ <Project Sdk="Microsoft.NET.Sdk">
1481
+ <PropertyGroup>
1482
+ <TargetFramework>net8.0</TargetFramework>
1483
+ </PropertyGroup>
1484
+ <ItemGroup>
1485
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1486
+ </ItemGroup>
1487
+ </Project>
1488
+ """)
1489
+ ],
1490
+ discoveryWorker: new TestDiscoveryWorker(_input =>
1491
+ {
1492
+ return Task.FromResult(new WorkspaceDiscoveryResult()
1493
+ {
1494
+ Path = "",
1495
+ Projects = [
1496
+ new()
1497
+ {
1498
+ FilePath = "project1/project1.csproj",
1499
+ TargetFrameworks = ["net8.0"],
1500
+ Dependencies = [
1501
+ new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"]),
1502
+ ],
1503
+ ReferencedProjectPaths = [],
1504
+ ImportedFiles = [
1505
+ "../Directory.Build.props",
1506
+ ],
1507
+ AdditionalFiles = [],
1508
+ },
1509
+ new()
1510
+ {
1511
+ FilePath = "project2/project2.csproj",
1512
+ TargetFrameworks = ["net8.0"],
1513
+ Dependencies = [
1514
+ new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"]),
1515
+ ],
1516
+ ReferencedProjectPaths = [],
1517
+ ImportedFiles = [
1518
+ "../Directory.Build.props",
1519
+ ],
1520
+ AdditionalFiles = [],
1521
+ },
1522
+ ]
1523
+ });
1524
+ }),
1525
+ analyzeWorker: new TestAnalyzeWorker(_input =>
1526
+ {
1527
+ return Task.FromResult(new AnalysisResult()
1528
+ {
1529
+ CanUpdate = true,
1530
+ UpdatedVersion = "1.1.0",
1531
+ UpdatedDependencies =
1532
+ [
1533
+ new("Some.Package", "1.1.0", DependencyType.Unknown, TargetFrameworks: ["net8.0"]),
1534
+ ]
1535
+ });
1536
+ }),
1537
+ updaterWorker: new TestUpdaterWorker(async input =>
1538
+ {
1539
+ var repoRootPath = input.Item1;
1540
+ var filePath = input.Item2;
1541
+ var packageName = input.Item3;
1542
+ var previousVersion = input.Item4;
1543
+ var newVersion = input.Item5;
1544
+ var _isTransitive = input.Item6;
1545
+
1546
+ var directoryBuildPropsPath = Path.Join(repoRootPath, "Directory.Build.props");
1547
+ await File.WriteAllTextAsync(directoryBuildPropsPath, """
1548
+ <Project>
1549
+ <PropertyGroup>
1550
+ <SomePackageVersion>1.1.0</SomePackageVersion>
1551
+ </PropertyGroup>
1552
+ </Project>
1553
+ """);
1554
+ return new UpdateOperationResult();
1555
+ }),
1556
+ expectedResult: new RunResult()
1557
+ {
1558
+ Base64DependencyFiles =
1559
+ [
1560
+ new DependencyFile()
1561
+ {
1562
+ Directory = "/",
1563
+ Name = "Directory.Build.props",
1564
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1565
+ <Project>
1566
+ <PropertyGroup>
1567
+ <SomePackageVersion>1.0.0</SomePackageVersion>
1568
+ </PropertyGroup>
1569
+ </Project>
1570
+ """))
1571
+ },
1572
+ new DependencyFile()
1573
+ {
1574
+ Directory = "/project1",
1575
+ Name = "project1.csproj",
1576
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1577
+ <Project Sdk="Microsoft.NET.Sdk">
1578
+ <PropertyGroup>
1579
+ <TargetFramework>net8.0</TargetFramework>
1580
+ </PropertyGroup>
1581
+ <ItemGroup>
1582
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1583
+ </ItemGroup>
1584
+ </Project>
1585
+ """))
1586
+ },
1587
+ new DependencyFile()
1588
+ {
1589
+ Directory = "/project2",
1590
+ Name = "project2.csproj",
1591
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
1592
+ <Project Sdk="Microsoft.NET.Sdk">
1593
+ <PropertyGroup>
1594
+ <TargetFramework>net8.0</TargetFramework>
1595
+ </PropertyGroup>
1596
+ <ItemGroup>
1597
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1598
+ </ItemGroup>
1599
+ </Project>
1600
+ """))
1601
+ },
1602
+ ],
1603
+ BaseCommitSha = "TEST-COMMIT-SHA",
1604
+ },
1605
+ expectedApiMessages:
1606
+ [
1607
+ new UpdatedDependencyList()
1608
+ {
1609
+ Dependencies =
1610
+ [
1611
+ new ReportedDependency()
1612
+ {
1613
+ Name = "Some.Package",
1614
+ Version = "1.0.0",
1615
+ Requirements =
1616
+ [
1617
+ new ReportedRequirement()
1618
+ {
1619
+ Requirement = "1.0.0",
1620
+ File = "/project1/project1.csproj",
1621
+ Groups = ["dependencies"],
1622
+ }
1623
+ ]
1624
+ },
1625
+ new ReportedDependency()
1626
+ {
1627
+ Name = "Some.Package",
1628
+ Version = "1.0.0",
1629
+ Requirements =
1630
+ [
1631
+ new ReportedRequirement()
1632
+ {
1633
+ Requirement = "1.0.0",
1634
+ File = "/project2/project2.csproj",
1635
+ Groups = ["dependencies"],
1636
+ }
1637
+ ]
1638
+ }
1639
+ ],
1640
+ DependencyFiles = ["/Directory.Build.props", "/project1/project1.csproj", "/project2/project2.csproj"],
1641
+ },
1642
+ new IncrementMetric()
1643
+ {
1644
+ Metric = "updater.started",
1645
+ Tags = new()
1646
+ {
1647
+ ["operation"] = "group_update_all_versions"
1648
+ }
1649
+ },
1650
+ new CreatePullRequest()
1651
+ {
1652
+ Dependencies =
1653
+ [
1654
+ new ReportedDependency()
1655
+ {
1656
+ Name = "Some.Package",
1657
+ Version = "1.1.0",
1658
+ Requirements =
1659
+ [
1660
+ new ReportedRequirement()
1661
+ {
1662
+ Requirement = "1.1.0",
1663
+ File = "/project1/project1.csproj",
1664
+ Groups = ["dependencies"],
1665
+ Source = new()
1666
+ {
1667
+ SourceUrl = null,
1668
+ Type = "nuget_repo",
1669
+ }
1670
+ }
1671
+ ],
1672
+ PreviousVersion = "1.0.0",
1673
+ PreviousRequirements =
1674
+ [
1675
+ new ReportedRequirement()
1676
+ {
1677
+ Requirement = "1.0.0",
1678
+ File = "/project1/project1.csproj",
1679
+ Groups = ["dependencies"],
1680
+ }
1681
+ ],
1682
+ },
1683
+ new ReportedDependency()
1684
+ {
1685
+ Name = "Some.Package",
1686
+ Version = "1.1.0",
1687
+ Requirements =
1688
+ [
1689
+ new ReportedRequirement()
1690
+ {
1691
+ Requirement = "1.1.0",
1692
+ File = "/project2/project2.csproj",
1693
+ Groups = ["dependencies"],
1694
+ Source = new()
1695
+ {
1696
+ SourceUrl = null,
1697
+ Type = "nuget_repo",
1698
+ }
1699
+ }
1700
+ ],
1701
+ PreviousVersion = "1.0.0",
1702
+ PreviousRequirements =
1703
+ [
1704
+ new ReportedRequirement()
1705
+ {
1706
+ Requirement = "1.0.0",
1707
+ File = "/project2/project2.csproj",
1708
+ Groups = ["dependencies"],
1709
+ }
1710
+ ],
1711
+ },
1712
+ ],
1713
+ UpdatedDependencyFiles =
1714
+ [
1392
1715
  new DependencyFile()
1393
1716
  {
1394
- Name = "packages.config",
1395
- Directory = "/some-dir/ProjectA",
1717
+ Name = "Directory.Build.props",
1718
+ Directory = "/",
1396
1719
  Content = """
1397
- <?xml version="1.0" encoding="utf-8"?>
1398
- <packages>
1399
- <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1400
- </packages>
1720
+ <Project>
1721
+ <PropertyGroup>
1722
+ <SomePackageVersion>1.1.0</SomePackageVersion>
1723
+ </PropertyGroup>
1724
+ </Project>
1401
1725
  """,
1402
- },
1726
+ }
1403
1727
  ],
1404
1728
  BaseCommitSha = "TEST-COMMIT-SHA",
1405
1729
  CommitMessage = "TODO: message",