dependabot-nuget 0.242.0 → 0.243.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/.editorconfig +37 -28
  3. data/helpers/lib/NuGetUpdater/.gitignore +1 -0
  4. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.CommandLine/AssemblyMetadataExtractor.cs +2 -1
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +2 -2
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +178 -176
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -1
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs +1 -0
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs +5 -4
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +1 -0
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs +10 -5
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs +16 -12
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +18 -17
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs +7 -7
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +13 -20
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +9 -3
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +32 -16
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +42 -22
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +32 -13
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/WebApplicationTargetsConditionPatcher.cs +47 -0
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/XmlFilePreAndPostProcessor.cs +55 -0
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +12 -9
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +50 -42
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +16 -3
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +6 -6
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/XmlExtensions.cs +11 -0
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs +18 -9
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs +2 -2
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/FrameworkCompatibilityServiceFacts.cs +7 -7
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/SupportedFrameworkFacts.cs +1 -1
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +9 -9
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorker.DirsProj.cs +81 -80
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +22 -9
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +140 -104
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +25 -25
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +8 -9
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +198 -22
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +401 -399
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs +17 -15
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +111 -42
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterTests.cs +161 -82
  42. data/lib/dependabot/nuget/file_fetcher.rb +3 -23
  43. data/lib/dependabot/nuget/file_parser/project_file_parser.rb +47 -60
  44. data/lib/dependabot/nuget/file_parser.rb +24 -6
  45. data/lib/dependabot/nuget/file_updater.rb +42 -6
  46. data/lib/dependabot/nuget/native_helpers.rb +27 -8
  47. data/lib/dependabot/nuget/nuget_client.rb +130 -24
  48. data/lib/dependabot/nuget/nuget_config_credential_helpers.rb +7 -3
  49. data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +63 -59
  50. data/lib/dependabot/nuget/update_checker/dependency_finder.rb +2 -2
  51. data/lib/dependabot/nuget/update_checker/nupkg_fetcher.rb +1 -1
  52. data/lib/dependabot/nuget/update_checker/nuspec_fetcher.rb +22 -17
  53. data/lib/dependabot/nuget/update_checker/repository_finder.rb +292 -270
  54. data/lib/dependabot/nuget/update_checker/tfm_comparer.rb +11 -13
  55. data/lib/dependabot/nuget/update_checker/tfm_finder.rb +80 -82
  56. data/lib/dependabot/nuget/update_checker/version_finder.rb +4 -7
  57. data/lib/dependabot/nuget/version.rb +18 -7
  58. data/lib/dependabot/nuget.rb +0 -2
  59. metadata +7 -5
@@ -1,6 +1,8 @@
1
1
  using System;
2
2
  using System.Collections.Generic;
3
+
3
4
  using NuGetUpdater.Core.Utilities;
5
+
4
6
  using Xunit;
5
7
 
6
8
  namespace NuGetUpdater.Core.Test.Utilities;
@@ -18,8 +20,8 @@ public class JsonHelperTests
18
20
 
19
21
  public static IEnumerable<object[]> JsonUpdaterTestData()
20
22
  {
21
- yield return new object[]
22
- {
23
+ yield return
24
+ [
23
25
  // json
24
26
  """
25
27
  {
@@ -75,10 +77,10 @@ public class JsonHelperTests
75
77
  }
76
78
  }
77
79
  """
78
- };
80
+ ];
79
81
 
80
- yield return new object[]
81
- {
82
+ yield return
83
+ [
82
84
  // json
83
85
  """
84
86
  {
@@ -119,11 +121,11 @@ public class JsonHelperTests
119
121
  }
120
122
  }
121
123
  """
122
- };
124
+ ];
123
125
 
124
126
  // differing case between `propertyPath` and the actual property values
125
- yield return new object[]
126
- {
127
+ yield return
128
+ [
127
129
  // json
128
130
  """
129
131
  {
@@ -177,11 +179,11 @@ public class JsonHelperTests
177
179
  }
178
180
  }
179
181
  """
180
- };
182
+ ];
181
183
 
182
184
  // shallow property path
183
- yield return new object[]
184
- {
185
+ yield return
186
+ [
185
187
  // original json
186
188
  """
187
189
  {
@@ -209,11 +211,11 @@ public class JsonHelperTests
209
211
  "path2": "new-value"
210
212
  }
211
213
  """
212
- };
214
+ ];
213
215
 
214
216
  // line comment after comma
215
- yield return new object[]
216
- {
217
+ yield return
218
+ [
217
219
  // original json
218
220
  """
219
221
  {
@@ -234,6 +236,6 @@ public class JsonHelperTests
234
236
  "property2": "updated-value"
235
237
  }
236
238
  """
237
- };
239
+ ];
238
240
  }
239
241
  }
@@ -167,7 +167,11 @@ public class MSBuildHelperTests
167
167
  new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown),
168
168
  new("NETStandard.Library", "2.0.3", DependencyType.Unknown),
169
169
  };
170
- var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", new[] { new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown) });
170
+ var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(
171
+ temp.DirectoryPath,
172
+ temp.DirectoryPath,
173
+ "netstandard2.0",
174
+ [new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown)]);
171
175
  Assert.Equal(expectedDependencies, actualDependencies);
172
176
  }
173
177
 
@@ -251,7 +255,8 @@ public class MSBuildHelperTests
251
255
  new("MSTest.TestAdapter", "2.1.0", DependencyType.Unknown),
252
256
  new("NETStandard.Library", "2.0.3", DependencyType.Unknown),
253
257
  };
254
- var packages = new[] {
258
+ var packages = new[]
259
+ {
255
260
  new Dependency("System", "4.1.311.2", DependencyType.Unknown),
256
261
  new Dependency("System.Core", "3.5.21022.801", DependencyType.Unknown),
257
262
  new Dependency("Moq", "4.16.1", DependencyType.Unknown),
@@ -269,12 +274,13 @@ public class MSBuildHelperTests
269
274
  new Dependency("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
270
275
  };
271
276
  var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", packages);
272
- for(int i = 0; i < actualDependencies.Length; i++)
277
+ for (int i = 0; i < actualDependencies.Length; i++)
273
278
  {
274
279
  var ad = actualDependencies[i];
275
280
  var ed = expectedDependencies[i];
276
281
  Assert.Equal(ed, ad);
277
282
  }
283
+
278
284
  Assert.Equal(expectedDependencies, actualDependencies);
279
285
  }
280
286
 
@@ -301,7 +307,8 @@ public class MSBuildHelperTests
301
307
  new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown),
302
308
  new("NETStandard.Library", "2.0.3", DependencyType.Unknown),
303
309
  };
304
- var packages = new[] {
310
+ var packages = new[]
311
+ {
305
312
  new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown),
306
313
  new Dependency("Newtonsoft.Json", "12.0.1", DependencyType.Unknown, IsUpdate: true)
307
314
  };
@@ -326,11 +333,16 @@ public class MSBuildHelperTests
326
333
  Environment.SetEnvironmentVariable("NUGET_HTTP_CACHE_PATH", tempNuGetHttpCacheDirectory);
327
334
 
328
335
  // First validate that we are unable to find dependencies for the package version without a NuGet.config.
329
- var dependenciesNoNuGetConfig = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", new[] { new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown) });
330
- Assert.Equal(Array.Empty<Dependency>(), dependenciesNoNuGetConfig);
336
+ var dependenciesNoNuGetConfig = await MSBuildHelper.GetAllPackageDependenciesAsync(
337
+ temp.DirectoryPath,
338
+ temp.DirectoryPath,
339
+ "netstandard2.0",
340
+ [new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown)]);
341
+ Assert.Equal([], dependenciesNoNuGetConfig);
331
342
 
332
343
  // Write the NuGet.config and try again.
333
- await File.WriteAllTextAsync(Path.Combine(temp.DirectoryPath, "NuGet.Config"), """
344
+ await File.WriteAllTextAsync(
345
+ Path.Combine(temp.DirectoryPath, "NuGet.Config"), """
334
346
  <?xml version="1.0" encoding="utf-8"?>
335
347
  <configuration>
336
348
  <packageSources>
@@ -355,7 +367,12 @@ public class MSBuildHelperTests
355
367
  new("Microsoft.CodeAnalysis.Analyzers", "3.3.4", DependencyType.Unknown),
356
368
  new("NETStandard.Library", "2.0.3", DependencyType.Unknown),
357
369
  };
358
- var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", new[] { new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown) });
370
+ var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(
371
+ temp.DirectoryPath,
372
+ temp.DirectoryPath,
373
+ "netstandard2.0",
374
+ [new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown)]
375
+ );
359
376
  Assert.Equal(expectedDependencies, actualDependencies);
360
377
  }
361
378
  finally
@@ -369,8 +386,8 @@ public class MSBuildHelperTests
369
386
  public static IEnumerable<object[]> GetTopLevelPackageDependenyInfosTestData()
370
387
  {
371
388
  // simple case
372
- yield return new object[]
373
- {
389
+ yield return
390
+ [
374
391
  // build file contents
375
392
  new[]
376
393
  {
@@ -387,11 +404,11 @@ public class MSBuildHelperTests
387
404
  {
388
405
  new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
389
406
  }
390
- };
407
+ ];
391
408
 
392
409
  // version is a child-node of the package reference
393
- yield return new object[]
394
- {
410
+ yield return
411
+ [
395
412
  // build file contents
396
413
  new[]
397
414
  {
@@ -410,11 +427,11 @@ public class MSBuildHelperTests
410
427
  {
411
428
  new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
412
429
  }
413
- };
430
+ ];
414
431
 
415
432
  // version is in property in same file
416
- yield return new object[]
417
- {
433
+ yield return
434
+ [
418
435
  // build file contents
419
436
  new[]
420
437
  {
@@ -434,9 +451,35 @@ public class MSBuildHelperTests
434
451
  {
435
452
  new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
436
453
  }
437
- };
454
+ ];
438
455
 
439
456
  // version is a property not triggered by a condition
457
+ yield return
458
+ [
459
+ // build file contents
460
+ new[]
461
+ {
462
+ ("project.csproj", """
463
+ <Project Sdk="Microsoft.NET.Sdk">
464
+ <PropertyGroup>
465
+ <TargetFramework>netstandard2.0</TargetFramework>
466
+ <NewtonsoftJsonVersion>12.0.1</NewtonsoftJsonVersion>
467
+ <NewtonsoftJsonVersion Condition="$(PropertyThatDoesNotExist) == 'true'">13.0.1</NewtonsoftJsonVersion>
468
+ </PropertyGroup>
469
+ <ItemGroup>
470
+ <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
471
+ </ItemGroup>
472
+ </Project>
473
+ """)
474
+ },
475
+ // expected dependencies
476
+ new Dependency[]
477
+ {
478
+ new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
479
+ }
480
+ ];
481
+
482
+ // version is a property not triggered by a quoted condition
440
483
  yield return new object[]
441
484
  {
442
485
  // build file contents
@@ -447,7 +490,7 @@ public class MSBuildHelperTests
447
490
  <PropertyGroup>
448
491
  <TargetFramework>netstandard2.0</TargetFramework>
449
492
  <NewtonsoftJsonVersion>12.0.1</NewtonsoftJsonVersion>
450
- <NewtonsoftJsonVersion Condition="$(PropertyThatDoesNotExist) == 'true'">13.0.1</NewtonsoftJsonVersion>
493
+ <NewtonsoftJsonVersion Condition="'$(PropertyThatDoesNotExist)' == 'true'">13.0.1</NewtonsoftJsonVersion>
451
494
  </PropertyGroup>
452
495
  <ItemGroup>
453
496
  <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
@@ -463,8 +506,8 @@ public class MSBuildHelperTests
463
506
  };
464
507
 
465
508
  // version is a property with a condition checking for an empty string
466
- yield return new object[]
467
- {
509
+ yield return
510
+ [
468
511
  // build file contents
469
512
  new[]
470
513
  {
@@ -486,22 +529,48 @@ public class MSBuildHelperTests
486
529
  {
487
530
  new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
488
531
  }
489
- };
532
+ ];
490
533
 
491
- // version is set in one file, used in another
534
+ // version is a property with a quoted condition checking for an empty string
492
535
  yield return new object[]
493
536
  {
494
537
  // build file contents
495
538
  new[]
496
539
  {
497
- ("Packages.props", """
498
- <Project>
540
+ ("project.csproj", """
541
+ <Project Sdk="Microsoft.NET.Sdk">
542
+ <PropertyGroup>
543
+ <TargetFramework>netstandard2.0</TargetFramework>
544
+ <NewtonsoftJsonVersion Condition="'$(NewtonsoftJsonVersion)' == ''">12.0.1</NewtonsoftJsonVersion>
545
+ <NewtonsoftJsonVersion Condition="'$(PropertyThatDoesNotExist)' == 'true'">13.0.1</NewtonsoftJsonVersion>
546
+ </PropertyGroup>
499
547
  <ItemGroup>
500
- <PackageReference Update="Azure.Identity" Version="1.6.0" />
501
- <PackageReference Update="Microsoft.Data.SqlClient" Version="5.1.4" />
548
+ <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
502
549
  </ItemGroup>
503
550
  </Project>
504
- """),
551
+ """)
552
+ },
553
+ // expected dependencies
554
+ new Dependency[]
555
+ {
556
+ new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
557
+ }
558
+ };
559
+
560
+ // version is set in one file, used in another
561
+ yield return
562
+ [
563
+ // build file contents
564
+ new[]
565
+ {
566
+ ("Packages.props", """
567
+ <Project>
568
+ <ItemGroup>
569
+ <PackageReference Update="Azure.Identity" Version="1.6.0" />
570
+ <PackageReference Update="Microsoft.Data.SqlClient" Version="5.1.4" />
571
+ </ItemGroup>
572
+ </Project>
573
+ """),
505
574
  ("project.csproj", """
506
575
  <Project Sdk="Microsoft.NET.Sdk">
507
576
  <PropertyGroup>
@@ -519,11 +588,11 @@ public class MSBuildHelperTests
519
588
  new("Azure.Identity", "1.6.0", DependencyType.Unknown),
520
589
  new("Microsoft.Data.SqlClient", "5.1.4", DependencyType.Unknown, IsUpdate: true)
521
590
  }
522
- };
591
+ ];
523
592
 
524
593
  // version is set in one file, used in another
525
- yield return new object[]
526
- {
594
+ yield return
595
+ [
527
596
  // build file contents
528
597
  new[]
529
598
  {
@@ -538,13 +607,13 @@ public class MSBuildHelperTests
538
607
  </Project>
539
608
  """),
540
609
  ("Packages.props", """
541
- <Project>
542
- <ItemGroup>
543
- <PackageReference Update="Azure.Identity" Version="1.6.0" />
544
- <PackageReference Update="Microsoft.Data.SqlClient" Version="5.1.4" />
545
- </ItemGroup>
546
- </Project>
547
- """)
610
+ <Project>
611
+ <ItemGroup>
612
+ <PackageReference Update="Azure.Identity" Version="1.6.0" />
613
+ <PackageReference Update="Microsoft.Data.SqlClient" Version="5.1.4" />
614
+ </ItemGroup>
615
+ </Project>
616
+ """)
548
617
  },
549
618
  // expected dependencies
550
619
  new Dependency[]
@@ -552,13 +621,13 @@ public class MSBuildHelperTests
552
621
  new("Azure.Identity", "1.6.0", DependencyType.Unknown),
553
622
  new("Microsoft.Data.SqlClient", "5.1.4", DependencyType.Unknown, IsUpdate: true)
554
623
  }
555
- };
624
+ ];
556
625
  }
557
626
 
558
627
  public static IEnumerable<object[]> SolutionProjectPathTestData()
559
628
  {
560
- yield return new object[]
561
- {
629
+ yield return
630
+ [
562
631
  """
563
632
  Microsoft Visual Studio Solution File, Format Version 12.00
564
633
  # Visual Studio 14
@@ -592,7 +661,7 @@ public class MSBuildHelperTests
592
661
  {
593
662
  "src/Some.Project/SomeProject.csproj",
594
663
  "src/Some.Project.Test/Some.Project.Test.csproj",
595
- },
596
- };
664
+ }
665
+ ];
597
666
  }
598
667
  }