dependabot-nuget 0.296.0 → 0.296.1

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.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +2 -0
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +6 -7
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +29 -4
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionResult.cs +7 -10
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.props +2 -1
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/ClosePullRequest.cs +12 -0
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PullRequestExistsForLatestVersion.cs +11 -0
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/SecurityUpdateNotNeeded.cs +10 -0
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UpdatePullRequest.cs +28 -0
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/HttpApiHandler.cs +5 -0
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/IApiHandler.cs +1 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +106 -64
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/TargetFrameworkReporter.targets +1 -6
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +5 -2
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +41 -30
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathComparer.cs +13 -6
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/VersionFinderTests.cs +33 -0
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +8 -4
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +175 -0
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +21 -21
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +69 -0
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/TestApiHandler.cs +6 -0
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +10 -10
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +83 -0
  26. metadata +9 -5
@@ -1,6 +1,11 @@
1
+ using System.Collections.Immutable;
2
+
3
+ using NuGet.Frameworks;
1
4
  using NuGet.Versioning;
2
5
 
3
6
  using NuGetUpdater.Core.Analyze;
7
+ using NuGetUpdater.Core.Test.Update;
8
+ using NuGetUpdater.Core.Test.Utilities;
4
9
 
5
10
  using Xunit;
6
11
 
@@ -190,4 +195,32 @@ public class VersionFinderTests
190
195
 
191
196
  Assert.True(result);
192
197
  }
198
+
199
+ [Fact]
200
+ public async Task TargetFrameworkIsConsideredForUpdatedVersions()
201
+ {
202
+ // arrange
203
+ using var tempDir = new TemporaryDirectory();
204
+ await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(
205
+ [
206
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
207
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0"), // can only update to this version because of the tfm
208
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "3.0.0", "net9.0"),
209
+ ],
210
+ tempDir.DirectoryPath);
211
+
212
+ // act
213
+ var projectTfms = new[] { "net8.0" }.Select(NuGetFramework.Parse).ToImmutableArray();
214
+ var packageId = "Some.Package";
215
+ var currentVersion = NuGetVersion.Parse("1.0.0");
216
+ var logger = new TestLogger();
217
+ var nugetContext = new NuGetContext(tempDir.DirectoryPath);
218
+ var versionResult = await VersionFinder.GetVersionsAsync(projectTfms, packageId, currentVersion, nugetContext, logger, CancellationToken.None);
219
+ var versions = versionResult.GetVersions();
220
+
221
+ // assert
222
+ var actual = versions.Select(v => v.ToString()).ToArray();
223
+ var expected = new[] { "2.0.0" };
224
+ AssertEx.Equal(expected, actual);
225
+ }
193
226
  }
@@ -1131,7 +1131,7 @@ public partial class DiscoveryWorkerTests
1131
1131
  ("src/project.csproj", """
1132
1132
  <Project Sdk="Microsoft.NET.Sdk">
1133
1133
  <PropertyGroup>
1134
- <TargetFrameworks>net8.0-ios;net8.0-android;net8.0-macos;net8.0-maccatalyst</TargetFrameworks>
1134
+ <TargetFrameworks>net8.0-ios;net8.0-android;net8.0-macos;net8.0-maccatalyst;net8.0-windows</TargetFrameworks>
1135
1135
  </PropertyGroup>
1136
1136
  <ItemGroup>
1137
1137
  <PackageReference Include="Some.Package" Version="1.2.3" />
@@ -1151,11 +1151,12 @@ public partial class DiscoveryWorkerTests
1151
1151
  new("Some.Package", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0-ios"], IsDirect: true),
1152
1152
  new("Some.Package", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0-maccatalyst"], IsDirect: true),
1153
1153
  new("Some.Package", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0-macos"], IsDirect: true),
1154
+ new("Some.Package", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0-windows"], IsDirect: true),
1154
1155
  ],
1155
1156
  Properties = [
1156
- new("TargetFrameworks", "net8.0-ios;net8.0-android;net8.0-macos;net8.0-maccatalyst", @"src/project.csproj"),
1157
+ new("TargetFrameworks", "net8.0-ios;net8.0-android;net8.0-macos;net8.0-maccatalyst;net8.0-windows", @"src/project.csproj"),
1157
1158
  ],
1158
- TargetFrameworks = ["net8.0-android", "net8.0-ios", "net8.0-maccatalyst", "net8.0-macos"],
1159
+ TargetFrameworks = ["net8.0-android", "net8.0-ios", "net8.0-maccatalyst", "net8.0-macos", "net8.0-windows"],
1159
1160
  ReferencedProjectPaths = [],
1160
1161
  ImportedFiles = [],
1161
1162
  AdditionalFiles = [],
@@ -1310,6 +1311,8 @@ public partial class DiscoveryWorkerTests
1310
1311
 
1311
1312
  <PropertyGroup>
1312
1313
  <TargetFramework>net8.0</TargetFramework>
1314
+ <!-- the SDK turns `<TargetFramework>net8.0</TargetFramework>` into the following -->
1315
+ <TargetFrameworkMoniker>.NETCoreApp,Version=8.0</TargetFrameworkMoniker>
1313
1316
  </PropertyGroup>
1314
1317
 
1315
1318
  <ItemGroup>
@@ -1360,7 +1363,8 @@ public partial class DiscoveryWorkerTests
1360
1363
  new("Test.Only.Package", "1.0.99", DependencyType.Unknown, TargetFrameworks: ["net8.0"], IsTransitive: true)
1361
1364
  ],
1362
1365
  Properties = [
1363
- new("TargetFramework", "net8.0", "project.csproj")
1366
+ new("TargetFramework", "net8.0", "project.csproj"),
1367
+ new("TargetFrameworkMoniker", ".NETCoreApp,Version=8.0", "project.csproj"),
1364
1368
  ],
1365
1369
  TargetFrameworks = ["net8.0"],
1366
1370
  ReferencedProjectPaths = [],
@@ -1,8 +1,10 @@
1
+ using System.Collections.Immutable;
1
2
  using System.Text.Json;
2
3
 
3
4
  using NuGet.Versioning;
4
5
 
5
6
  using NuGetUpdater.Core.Analyze;
7
+ using NuGetUpdater.Core.Discover;
6
8
  using NuGetUpdater.Core.Run;
7
9
  using NuGetUpdater.Core.Run.ApiModel;
8
10
 
@@ -41,6 +43,59 @@ public class MiscellaneousTests
41
43
  Assert.Equal(expectedString, actualString);
42
44
  }
43
45
 
46
+ [Theory]
47
+ [MemberData(nameof(GetIncrementMetricData))]
48
+ public void GetIncrementMetric(Job job, IncrementMetric expected)
49
+ {
50
+ var actual = RunWorker.GetIncrementMetric(job);
51
+ var actualJson = HttpApiHandler.Serialize(actual);
52
+ var expectedJson = HttpApiHandler.Serialize(expected);
53
+ Assert.Equal(expectedJson, actualJson);
54
+ }
55
+
56
+ [Theory]
57
+ [MemberData(nameof(GetUpdateOperationsData))]
58
+ public void GetUpdateOperations(WorkspaceDiscoveryResult discovery, (string ProjectPath, string DependencyName)[] expectedUpdateOperations)
59
+ {
60
+ var updateOperations = RunWorker.GetUpdateOperations(discovery).ToArray();
61
+ var actualUpdateOperations = updateOperations.Select(uo => (uo.ProjectPath, uo.Dependency.Name)).ToArray();
62
+ Assert.Equal(expectedUpdateOperations, actualUpdateOperations);
63
+ }
64
+
65
+ public static IEnumerable<object[]> GetUpdateOperationsData()
66
+ {
67
+ static ProjectDiscoveryResult GetProjectDiscovery(string filePath, params string[] dependencyNames)
68
+ {
69
+ return new()
70
+ {
71
+ FilePath = filePath,
72
+ Dependencies = dependencyNames.Select(d => new Dependency(d, "1.0.0", DependencyType.PackageReference)).ToImmutableArray(),
73
+ ImportedFiles = [],
74
+ AdditionalFiles = [],
75
+ };
76
+ }
77
+
78
+ yield return
79
+ [
80
+ new WorkspaceDiscoveryResult()
81
+ {
82
+ Path = "",
83
+ Projects = [
84
+ GetProjectDiscovery("src/Library.csproj", "Package.B", "Package.C"),
85
+ GetProjectDiscovery("src/Common.csproj", "Package.A", "Package.C", "Package.D"),
86
+ ]
87
+ },
88
+ new (string, string)[]
89
+ {
90
+ ("/src/Common.csproj", "Package.A"),
91
+ ("/src/Library.csproj", "Package.B"),
92
+ ("/src/Common.csproj", "Package.C"),
93
+ ("/src/Library.csproj", "Package.C"),
94
+ ("/src/Common.csproj", "Package.D"),
95
+ },
96
+ ];
97
+ }
98
+
44
99
  public static IEnumerable<object?[]> RequirementsFromIgnoredVersionsData()
45
100
  {
46
101
  yield return
@@ -143,4 +198,124 @@ public class MiscellaneousTests
143
198
  }
144
199
  ];
145
200
  }
201
+
202
+ public static IEnumerable<object?[]> GetIncrementMetricData()
203
+ {
204
+ static Job GetJob(AllowedUpdate[] allowed, bool securityUpdatesOnly, bool updatingAPullRequest)
205
+ {
206
+ return new Job()
207
+ {
208
+ AllowedUpdates = allowed.ToImmutableArray(),
209
+ Source = new()
210
+ {
211
+ Provider = "github",
212
+ Repo = "some/repo"
213
+ },
214
+ SecurityUpdatesOnly = securityUpdatesOnly,
215
+ UpdatingAPullRequest = updatingAPullRequest,
216
+ };
217
+ }
218
+
219
+ // version update
220
+ yield return
221
+ [
222
+ GetJob(
223
+ allowed: [new AllowedUpdate() { UpdateType = UpdateType.All }],
224
+ securityUpdatesOnly: false,
225
+ updatingAPullRequest: false),
226
+ new IncrementMetric()
227
+ {
228
+ Metric = "updater.started",
229
+ Tags =
230
+ {
231
+ ["operation"] = "group_update_all_versions"
232
+ }
233
+ }
234
+ ];
235
+
236
+ // version update - existing pr
237
+ yield return
238
+ [
239
+ GetJob(
240
+ allowed: [new AllowedUpdate() { UpdateType = UpdateType.All }],
241
+ securityUpdatesOnly: false,
242
+ updatingAPullRequest: true),
243
+ new IncrementMetric()
244
+ {
245
+ Metric = "updater.started",
246
+ Tags =
247
+ {
248
+ ["operation"] = "update_version_pr"
249
+ }
250
+ }
251
+ ];
252
+
253
+ // create security pr - allowed security update
254
+ yield return
255
+ [
256
+ GetJob(
257
+ allowed: [new AllowedUpdate() { UpdateType = UpdateType.All }, new AllowedUpdate() { UpdateType = UpdateType.Security }],
258
+ securityUpdatesOnly: false,
259
+ updatingAPullRequest: false),
260
+ new IncrementMetric()
261
+ {
262
+ Metric = "updater.started",
263
+ Tags =
264
+ {
265
+ ["operation"] = "create_security_pr"
266
+ }
267
+ }
268
+ ];
269
+
270
+ // create security pr - security only
271
+ yield return
272
+ [
273
+ GetJob(
274
+ allowed: [new AllowedUpdate() { UpdateType = UpdateType.All } ],
275
+ securityUpdatesOnly: true,
276
+ updatingAPullRequest: false),
277
+ new IncrementMetric()
278
+ {
279
+ Metric = "updater.started",
280
+ Tags =
281
+ {
282
+ ["operation"] = "create_security_pr"
283
+ }
284
+ }
285
+ ];
286
+
287
+ // update security pr - allowed security update
288
+ yield return
289
+ [
290
+ GetJob(
291
+ allowed: [new AllowedUpdate() { UpdateType = UpdateType.All }, new AllowedUpdate() { UpdateType = UpdateType.Security } ],
292
+ securityUpdatesOnly: false,
293
+ updatingAPullRequest: true),
294
+ new IncrementMetric()
295
+ {
296
+ Metric = "updater.started",
297
+ Tags =
298
+ {
299
+ ["operation"] = "update_security_pr"
300
+ }
301
+ }
302
+ ];
303
+
304
+ // update security pr - security only
305
+ yield return
306
+ [
307
+ GetJob(
308
+ allowed: [new AllowedUpdate() { UpdateType = UpdateType.All } ],
309
+ securityUpdatesOnly: true,
310
+ updatingAPullRequest: true),
311
+ new IncrementMetric()
312
+ {
313
+ Metric = "updater.started",
314
+ Tags =
315
+ {
316
+ ["operation"] = "update_security_pr"
317
+ }
318
+ }
319
+ ];
320
+ }
146
321
  }
@@ -1147,7 +1147,7 @@ public class RunWorkerTests
1147
1147
  new ReportedRequirement()
1148
1148
  {
1149
1149
  Requirement = "1.0.0",
1150
- File = "/some-dir/ProjectB/ProjectB.csproj",
1150
+ File = "/some-dir/ProjectA/ProjectA.csproj",
1151
1151
  Groups = ["dependencies"],
1152
1152
  }
1153
1153
  ]
@@ -1161,7 +1161,7 @@ public class RunWorkerTests
1161
1161
  new ReportedRequirement()
1162
1162
  {
1163
1163
  Requirement = "2.0.0",
1164
- File = "/some-dir/ProjectB/ProjectB.csproj",
1164
+ File = "/some-dir/ProjectA/ProjectA.csproj",
1165
1165
  Groups = ["dependencies"],
1166
1166
  }
1167
1167
  ]
@@ -1175,7 +1175,7 @@ public class RunWorkerTests
1175
1175
  new ReportedRequirement()
1176
1176
  {
1177
1177
  Requirement = "1.0.0",
1178
- File = "/some-dir/ProjectA/ProjectA.csproj",
1178
+ File = "/some-dir/ProjectB/ProjectB.csproj",
1179
1179
  Groups = ["dependencies"],
1180
1180
  }
1181
1181
  ]
@@ -1189,7 +1189,7 @@ public class RunWorkerTests
1189
1189
  new ReportedRequirement()
1190
1190
  {
1191
1191
  Requirement = "2.0.0",
1192
- File = "/some-dir/ProjectA/ProjectA.csproj",
1192
+ File = "/some-dir/ProjectB/ProjectB.csproj",
1193
1193
  Groups = ["dependencies"],
1194
1194
  }
1195
1195
  ]
@@ -1218,7 +1218,7 @@ public class RunWorkerTests
1218
1218
  new ReportedRequirement()
1219
1219
  {
1220
1220
  Requirement = "1.0.1",
1221
- File = "/some-dir/ProjectB/ProjectB.csproj",
1221
+ File = "/some-dir/ProjectA/ProjectA.csproj",
1222
1222
  Groups = ["dependencies"],
1223
1223
  Source = new()
1224
1224
  {
@@ -1233,35 +1233,35 @@ public class RunWorkerTests
1233
1233
  new ReportedRequirement()
1234
1234
  {
1235
1235
  Requirement = "1.0.0",
1236
- File = "/some-dir/ProjectB/ProjectB.csproj",
1236
+ File = "/some-dir/ProjectA/ProjectA.csproj",
1237
1237
  Groups = ["dependencies"],
1238
1238
  }
1239
1239
  ],
1240
1240
  },
1241
1241
  new ReportedDependency()
1242
1242
  {
1243
- Name = "Some.Package2",
1244
- Version = "2.0.1",
1243
+ Name = "Some.Package",
1244
+ Version = "1.0.1",
1245
1245
  Requirements =
1246
1246
  [
1247
1247
  new ReportedRequirement()
1248
1248
  {
1249
- Requirement = "2.0.1",
1249
+ Requirement = "1.0.1",
1250
1250
  File = "/some-dir/ProjectB/ProjectB.csproj",
1251
1251
  Groups = ["dependencies"],
1252
1252
  Source = new()
1253
1253
  {
1254
- SourceUrl = "https://nuget.example.com/some-package2",
1254
+ SourceUrl = "https://nuget.example.com/some-package",
1255
1255
  Type = "nuget_repo",
1256
1256
  }
1257
1257
  }
1258
1258
  ],
1259
- PreviousVersion = "2.0.0",
1259
+ PreviousVersion = "1.0.0",
1260
1260
  PreviousRequirements =
1261
1261
  [
1262
1262
  new ReportedRequirement()
1263
1263
  {
1264
- Requirement = "2.0.0",
1264
+ Requirement = "1.0.0",
1265
1265
  File = "/some-dir/ProjectB/ProjectB.csproj",
1266
1266
  Groups = ["dependencies"],
1267
1267
  }
@@ -1269,28 +1269,28 @@ public class RunWorkerTests
1269
1269
  },
1270
1270
  new ReportedDependency()
1271
1271
  {
1272
- Name = "Some.Package",
1273
- Version = "1.0.1",
1272
+ Name = "Some.Package2",
1273
+ Version = "2.0.1",
1274
1274
  Requirements =
1275
1275
  [
1276
1276
  new ReportedRequirement()
1277
1277
  {
1278
- Requirement = "1.0.1",
1278
+ Requirement = "2.0.1",
1279
1279
  File = "/some-dir/ProjectA/ProjectA.csproj",
1280
1280
  Groups = ["dependencies"],
1281
1281
  Source = new()
1282
1282
  {
1283
- SourceUrl = "https://nuget.example.com/some-package",
1283
+ SourceUrl = "https://nuget.example.com/some-package2",
1284
1284
  Type = "nuget_repo",
1285
1285
  }
1286
1286
  }
1287
1287
  ],
1288
- PreviousVersion = "1.0.0",
1288
+ PreviousVersion = "2.0.0",
1289
1289
  PreviousRequirements =
1290
1290
  [
1291
1291
  new ReportedRequirement()
1292
1292
  {
1293
- Requirement = "1.0.0",
1293
+ Requirement = "2.0.0",
1294
1294
  File = "/some-dir/ProjectA/ProjectA.csproj",
1295
1295
  Groups = ["dependencies"],
1296
1296
  }
@@ -1305,7 +1305,7 @@ public class RunWorkerTests
1305
1305
  new ReportedRequirement()
1306
1306
  {
1307
1307
  Requirement = "2.0.1",
1308
- File = "/some-dir/ProjectA/ProjectA.csproj",
1308
+ File = "/some-dir/ProjectB/ProjectB.csproj",
1309
1309
  Groups = ["dependencies"],
1310
1310
  Source = new()
1311
1311
  {
@@ -1320,7 +1320,7 @@ public class RunWorkerTests
1320
1320
  new ReportedRequirement()
1321
1321
  {
1322
1322
  Requirement = "2.0.0",
1323
- File = "/some-dir/ProjectA/ProjectA.csproj",
1323
+ File = "/some-dir/ProjectB/ProjectB.csproj",
1324
1324
  Groups = ["dependencies"],
1325
1325
  }
1326
1326
  ],
@@ -1945,7 +1945,7 @@ public class RunWorkerTests
1945
1945
  Metric = "updater.started",
1946
1946
  Tags = new()
1947
1947
  {
1948
- ["operation"] = "group_update_all_versions"
1948
+ ["operation"] = "create_security_pr"
1949
1949
  }
1950
1950
  },
1951
1951
  new CreatePullRequest()
@@ -541,6 +541,59 @@ public class SerializationTests
541
541
  Assert.True(jobWrapper.Job.CommitMessageOptions!.IncludeScope);
542
542
  }
543
543
 
544
+ [Fact]
545
+ public void SerializeClosePullRequest()
546
+ {
547
+ var close = new ClosePullRequest()
548
+ {
549
+ DependencyNames = ["dep"],
550
+ };
551
+ var actual = HttpApiHandler.Serialize(close);
552
+ var expected = """
553
+ {"data":{"dependency-names":["dep"],"reason":"up_to_date"}}
554
+ """;
555
+ Assert.Equal(expected, actual);
556
+ }
557
+
558
+ [Fact]
559
+ public void SerializeCreatePullRequest()
560
+ {
561
+ var create = new CreatePullRequest()
562
+ {
563
+ Dependencies = [new() { Name = "dep", Version = "ver2", PreviousVersion = "ver1", Requirements = [new() { Requirement = "ver2", File = "project.csproj" }], PreviousRequirements = [new() { Requirement = "ver1", File = "project.csproj" }] }],
564
+ UpdatedDependencyFiles = [new() { Name = "project.csproj", Directory = "/", Content = "updated content" }],
565
+ BaseCommitSha = "TEST-COMMIT-SHA",
566
+ CommitMessage = "commit message",
567
+ PrTitle = "pr title",
568
+ PrBody = "pr body"
569
+ };
570
+ var actual = HttpApiHandler.Serialize(create);
571
+ var expected = """
572
+ {"data":{"dependencies":[{"name":"dep","version":"ver2","requirements":[{"requirement":"ver2","file":"project.csproj","groups":[],"source":null}],"previous-version":"ver1","previous-requirements":[{"requirement":"ver1","file":"project.csproj","groups":[],"source":null}]}],"updated-dependency-files":[{"name":"project.csproj","content":"updated content","directory":"/","type":"file","support_file":false,"content_encoding":"utf-8","deleted":false,"operation":"update","mode":null}],"base-commit-sha":"TEST-COMMIT-SHA","commit-message":"commit message","pr-title":"pr title","pr-body":"pr body"}}
573
+ """;
574
+ Assert.Equal(expected, actual);
575
+ }
576
+
577
+ [Fact]
578
+ public void SerializeUpdatePullRequest()
579
+ {
580
+ var update = new UpdatePullRequest()
581
+ {
582
+ BaseCommitSha = "TEST-COMMIT-SHA",
583
+ DependencyNames = ["dep"],
584
+ UpdatedDependencyFiles = [new() { Name = "project.csproj", Directory = "/", Content = "updated content" }],
585
+ PrTitle = "pr title",
586
+ PrBody = "pr body",
587
+ CommitMessage = "commit message",
588
+ DependencyGroup = null,
589
+ };
590
+ var actual = HttpApiHandler.Serialize(update);
591
+ var expected = """
592
+ {"data":{"base-commit-sha":"TEST-COMMIT-SHA","dependency-names":["dep"],"updated-dependency-files":[{"name":"project.csproj","content":"updated content","directory":"/","type":"file","support_file":false,"content_encoding":"utf-8","deleted":false,"operation":"update","mode":null}],"pr-title":"pr title","pr-body":"pr body","commit-message":"commit message","dependency-group":null}}
593
+ """;
594
+ Assert.Equal(expected, actual);
595
+ }
596
+
544
597
  public static IEnumerable<object?[]> DeserializeErrorTypesData()
545
598
  {
546
599
  yield return
@@ -583,6 +636,22 @@ public class SerializationTests
583
636
  """
584
637
  ];
585
638
 
639
+ yield return
640
+ [
641
+ new PullRequestExistsForLatestVersion("dep", "ver"),
642
+ """
643
+ {"data":{"error-type":"pull_request_exists_for_latest_version","error-details":{"dependency-name":"dep","dependency-version":"ver"}}}
644
+ """
645
+ ];
646
+
647
+ yield return
648
+ [
649
+ new SecurityUpdateNotNeeded("dep"),
650
+ """
651
+ {"data":{"error-type":"security_update_not_needed","error-details":{"dependency-name":"dep"}}}
652
+ """
653
+ ];
654
+
586
655
  yield return
587
656
  [
588
657
  new UnknownError(new Exception("some message"), "JOB-ID"),
@@ -33,6 +33,12 @@ internal class TestApiHandler : IApiHandler
33
33
  return Task.CompletedTask;
34
34
  }
35
35
 
36
+ public Task UpdatePullRequest(UpdatePullRequest updatePullRequest)
37
+ {
38
+ _receivedMessages.Add((updatePullRequest.GetType(), updatePullRequest));
39
+ return Task.CompletedTask;
40
+ }
41
+
36
42
  public Task MarkAsProcessed(MarkAsProcessed markAsProcessed)
37
43
  {
38
44
  _receivedMessages.Add((markAsProcessed.GetType(), markAsProcessed));
@@ -92,31 +92,31 @@ public class UpdatedDependencyListTests
92
92
  },
93
93
  new ReportedDependency()
94
94
  {
95
- Name = "System.Text.Json",
96
- Version = "6.0.0",
95
+ Name = "Newtonsoft.Json",
96
+ Version = "13.0.1",
97
97
  Requirements =
98
98
  [
99
99
  new ReportedRequirement()
100
100
  {
101
- Requirement = "6.0.0",
101
+ Requirement = "13.0.1",
102
102
  File = "/src/c/project.csproj",
103
103
  Groups = ["dependencies"],
104
- }
105
- ],
104
+ },
105
+ ]
106
106
  },
107
107
  new ReportedDependency()
108
108
  {
109
- Name = "Newtonsoft.Json",
110
- Version = "13.0.1",
109
+ Name = "System.Text.Json",
110
+ Version = "6.0.0",
111
111
  Requirements =
112
112
  [
113
113
  new ReportedRequirement()
114
114
  {
115
- Requirement = "13.0.1",
115
+ Requirement = "6.0.0",
116
116
  File = "/src/c/project.csproj",
117
117
  Groups = ["dependencies"],
118
- },
119
- ]
118
+ }
119
+ ],
120
120
  },
121
121
  ],
122
122
  DependencyFiles = ["/src/a/packages.config", "/src/a/project.csproj", "/src/b/packages.config", "/src/b/project.csproj", "/src/c/packages.config", "/src/c/project.csproj"],
@@ -538,6 +538,89 @@ public class MSBuildHelperTests : TestBase
538
538
  """, evaluatedValue);
539
539
  }
540
540
 
541
+ [Theory]
542
+ [MemberData(nameof(GetTargetFrameworkValuesFromProjectData))]
543
+ public async Task GetTargetFrameworkValuesFromProject(string projectContents, string[] expectedTfms)
544
+ {
545
+ using var tempDir = await TemporaryDirectory.CreateWithContentsAsync(
546
+ [
547
+ ("Directory.Build.props", "<Project />"),
548
+ ("Directory.Build.targets", "<Project />"),
549
+ ("project.csproj", projectContents)
550
+ ]);
551
+ var projectPath = Path.Combine(tempDir.DirectoryPath, "project.csproj");
552
+ var experimentsManager = new ExperimentsManager();
553
+ var logger = new TestLogger();
554
+ var actualTfms = await MSBuildHelper.GetTargetFrameworkValuesFromProject(tempDir.DirectoryPath, projectPath, experimentsManager, logger);
555
+ AssertEx.Equal(expectedTfms, actualTfms);
556
+ }
557
+
558
+ public static IEnumerable<object[]> GetTargetFrameworkValuesFromProjectData()
559
+ {
560
+ // SDK-style projects
561
+ yield return
562
+ [
563
+ """
564
+ <Project Sdk="Microsoft.NET.Sdk">
565
+ <PropertyGroup>
566
+ <TargetFramework>net8.0</TargetFramework>
567
+ </PropertyGroup>
568
+ </Project>
569
+ """,
570
+ new[] { "net8.0" }
571
+ ];
572
+
573
+ yield return
574
+ [
575
+ """
576
+ <Project Sdk="Microsoft.NET.Sdk">
577
+ <PropertyGroup>
578
+ <TargetFrameworks> ; net8.0 ; </TargetFrameworks>
579
+ </PropertyGroup>
580
+ </Project>
581
+ """,
582
+ new[] { "net8.0" }
583
+ ];
584
+
585
+ yield return
586
+ [
587
+ """
588
+ <Project Sdk="Microsoft.NET.Sdk">
589
+ <PropertyGroup>
590
+ <TargetFrameworks>net8.0;net9.0</TargetFrameworks>
591
+ </PropertyGroup>
592
+ </Project>
593
+ """,
594
+ new[] { "net8.0", "net9.0" }
595
+ ];
596
+
597
+ yield return
598
+ [
599
+ """
600
+ <Project Sdk="Microsoft.NET.Sdk">
601
+ <PropertyGroup>
602
+ <TargetFramework>net8.0-windows7.0</TargetFramework>
603
+ </PropertyGroup>
604
+ </Project>
605
+ """,
606
+ new[] { "net8.0-windows7.0" }
607
+ ];
608
+
609
+ // legacy projects
610
+ yield return
611
+ [
612
+ """
613
+ <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
614
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
615
+ <PropertyGroup>
616
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
617
+ </PropertyGroup>
618
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
619
+ </Project>
620
+ """,
621
+ new[] { "net45" }
622
+ ];
623
+ }
541
624
 
542
625
  #region
543
626
  // Updating root package