dependabot-nuget 0.288.0 → 0.290.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) 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/Commands/AnalyzeCommand.cs +7 -3
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +1 -1
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +29 -2
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +25 -4
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +0 -6
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +33 -16
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +25 -10
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/NuGetContext.cs +0 -13
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementArrayConverter.cs +39 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +1 -1
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/ShellGitCommandHandler.cs +1 -1
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +60 -66
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +2 -2
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +2 -2
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +11 -3
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +1 -0
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +2 -4
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +54 -11
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +0 -1
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +1 -2
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +1 -1
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +2 -2
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Advisory.cs +13 -0
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/AllowedUpdate.cs +18 -1
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/CommitOptions.cs +8 -0
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Condition.cs +19 -0
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyGroup.cs +8 -0
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/GroupPullRequest.cs +9 -0
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +13 -10
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PullRequest.cs +11 -0
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/RequirementsUpdateStrategy.cs +15 -0
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +67 -58
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/VersionConverter.cs +19 -0
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +15 -44
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +4 -4
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -5
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -10
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +38 -33
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +25 -23
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +16 -12
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +1 -1
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +19 -19
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +11 -1
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +2 -0
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +18 -17
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -17
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +17 -9
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +96 -0
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTestBase.cs +5 -2
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +87 -5
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +2 -5
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +45 -1
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +35 -1
  57. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +16 -0
  58. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +6 -0
  59. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +143 -36
  60. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +184 -48
  61. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +5 -5
  62. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +32 -10
  63. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +85 -0
  64. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +402 -102
  65. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +342 -2
  66. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +60 -2
  67. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +18 -7
  68. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +1 -1
  69. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs +1 -1
  70. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +24 -0
  71. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +4 -14
  72. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +84 -0
  73. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +66 -0
  74. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +95 -0
  75. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1 -7
  76. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +1 -1
  77. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LinuxOnlyAttribute.cs +12 -0
  78. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +558 -711
  79. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +47 -2
  80. data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +4 -2
  81. data/lib/dependabot/nuget/analysis/dependency_analysis.rb +3 -3
  82. data/lib/dependabot/nuget/discovery/dependency_details.rb +10 -3
  83. data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +8 -12
  84. data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +214 -29
  85. data/lib/dependabot/nuget/discovery/project_discovery.rb +41 -8
  86. data/lib/dependabot/nuget/discovery/workspace_discovery.rb +14 -19
  87. data/lib/dependabot/nuget/file_fetcher.rb +11 -393
  88. data/lib/dependabot/nuget/file_parser.rb +23 -61
  89. data/lib/dependabot/nuget/file_updater.rb +28 -23
  90. data/lib/dependabot/nuget/native_helpers.rb +14 -5
  91. data/lib/dependabot/nuget/update_checker/requirements_updater.rb +23 -27
  92. data/lib/dependabot/nuget/update_checker.rb +116 -190
  93. metadata +20 -32
  94. data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props +0 -29
  95. data/lib/dependabot/nuget/discovery/directory_packages_props_discovery.rb +0 -43
  96. data/lib/dependabot/nuget/file_fetcher/import_paths_finder.rb +0 -73
  97. data/lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb +0 -60
  98. data/lib/dependabot/nuget/http_response_helpers.rb +0 -19
  99. data/lib/dependabot/nuget/native_discovery/native_dependency_details.rb +0 -102
  100. data/lib/dependabot/nuget/native_discovery/native_dependency_file_discovery.rb +0 -129
  101. data/lib/dependabot/nuget/native_discovery/native_discovery_json_reader.rb +0 -171
  102. data/lib/dependabot/nuget/native_discovery/native_evaluation_details.rb +0 -63
  103. data/lib/dependabot/nuget/native_discovery/native_project_discovery.rb +0 -82
  104. data/lib/dependabot/nuget/native_discovery/native_property_details.rb +0 -43
  105. data/lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb +0 -68
  106. data/lib/dependabot/nuget/native_update_checker/native_requirements_updater.rb +0 -105
  107. data/lib/dependabot/nuget/native_update_checker/native_update_checker.rb +0 -201
  108. data/lib/dependabot/nuget/nuget_client.rb +0 -223
  109. data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +0 -116
  110. data/lib/dependabot/nuget/update_checker/dependency_finder.rb +0 -297
  111. data/lib/dependabot/nuget/update_checker/nupkg_fetcher.rb +0 -221
  112. data/lib/dependabot/nuget/update_checker/nuspec_fetcher.rb +0 -110
  113. data/lib/dependabot/nuget/update_checker/property_updater.rb +0 -196
  114. data/lib/dependabot/nuget/update_checker/repository_finder.rb +0 -466
  115. data/lib/dependabot/nuget/update_checker/tfm_comparer.rb +0 -34
  116. data/lib/dependabot/nuget/update_checker/tfm_finder.rb +0 -30
  117. data/lib/dependabot/nuget/update_checker/version_finder.rb +0 -449
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 970779cacdfb8250a46cf1c24ac9fcda325b69b1502c3f0e99b9f1bf80a1add8
4
- data.tar.gz: a8c7a1b0aba00354ffdb35a8903e912d60ce00e73521f53b76b5f20458194e2f
3
+ metadata.gz: b3ca35ae6f3d02ce8507984f89e7c929eb75cec515b39af94db530d6600f0caa
4
+ data.tar.gz: cbd548418a3e25163af5d8543109b520b6c9bd9e2bf5a5869421f8fe838128d1
5
5
  SHA512:
6
- metadata.gz: 0ae55b0bfbfa8874ef9b2f9a6864587b13d107e9702319397161dbd70c9df97f638b9e906807966f3a0ca2214fce5760c1b4c58eb5b481c68171a270fadbbded
7
- data.tar.gz: bea5ba0649370308fa5a1a6c8d2211708ebdf99d33da6461d38c3a4a10e095b87be83e8ae39b4050fa7ce40ad096fdb349c7bc715971c7e0971ba5eb1f68265d
6
+ metadata.gz: 9395fb4eea720fbcba3b0cef278344b41a9ace7315ce62f5cb193bb05af2aa23553130dab3112cb900d39ad12cadd321e64291d72e4e21e4bbee2f2b7610626a
7
+ data.tar.gz: d74843dc18cab2fd6a58a31f1df2a4172cb308a3a2e452db7056727666e9f153b611046c25bd78f7c0679abe8be4eb57462886d87c8010ba21ac0a2ee316120e
@@ -5,36 +5,38 @@
5
5
  </PropertyGroup>
6
6
 
7
7
  <PropertyGroup>
8
- <MSBuildPackageVersion>17.5.0</MSBuildPackageVersion>
8
+ <MSBuildPackageVersion>17.12.6</MSBuildPackageVersion>
9
9
  </PropertyGroup>
10
10
 
11
11
  <ItemGroup>
12
- <PackageVersion Include="DiffPlex" Version="1.7.1" />
13
-
12
+ <PackageVersion Include="DiffPlex" Version="1.7.2" />
14
13
  <PackageVersion Include="GuiLabs.Language.Xml" Version="1.2.93" />
15
-
14
+ <PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
16
15
  <PackageVersion Include="Microsoft.Build" Version="$(MSBuildPackageVersion)" />
17
16
  <PackageVersion Include="Microsoft.Build.Framework" Version="$(MSBuildPackageVersion)" />
18
- <PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
17
+ <PackageVersion Include="Microsoft.Build.Tasks.Core" Version="$(MSBuildPackageVersion)" />
19
18
  <PackageVersion Include="Microsoft.Build.Utilities.Core" Version="$(MSBuildPackageVersion)" />
20
-
21
- <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
22
-
23
- <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
24
-
19
+ <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
20
+ <PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
21
+ <PackageVersion Include="Microsoft.Extensions.FileProviders.Abstractions" Version="9.0.0" />
22
+ <PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.0" />
23
+ <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
24
+ <PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.12.2149" />
25
+ <PackageVersion Include="Microsoft.Web.Xdt" Version="3.1.0" />
25
26
  <PackageVersion Include="MSBuild.StructuredLogger" Version="2.2.386" />
26
-
27
- <PackageVersion Include="NuGet.Core" Version="2.14.0-rtm-832" Aliases="CoreV2" />
28
-
27
+ <PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
28
+ <PackageVersion Include="NuGet.Core" Version="2.14.0" Aliases="CoreV2" />
29
29
  <PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
30
+ <PackageVersion Include="System.ComponentModel.Composition" Version="9.0.0" />
30
31
  <PackageVersion Include="System.Net.Http" Version="4.3.4" />
31
32
  <PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
32
- <PackageVersion Include="System.Security.Cryptography.Pkcs" Version="8.0.0" />
33
+ <PackageVersion Include="System.Security.Cryptography.Pkcs" Version="9.0.0" />
34
+ <PackageVersion Include="System.Security.Cryptography.ProtectedData" Version="9.0.0" />
33
35
  <PackageVersion Include="System.Text.Json" Version="8.0.4" />
34
36
  <PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
35
-
36
- <PackageVersion Include="xunit" Version="2.4.2" />
37
- <PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
37
+ <PackageVersion Include="System.Threading.Tasks.Dataflow" Version="9.0.0" />
38
+ <PackageVersion Include="xunit" Version="2.9.2" />
39
+ <PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
38
40
  </ItemGroup>
39
41
 
40
42
  </Project>
@@ -14,7 +14,6 @@
14
14
  <ItemGroup>
15
15
  <PackageReference Include="Newtonsoft.Json" />
16
16
  <PackageReference Include="System.Security.Cryptography.Pkcs" />
17
- <PackageReference Include="System.Security.Cryptography.Cng" />
18
17
  </ItemGroup>
19
18
 
20
19
  <ItemGroup>
@@ -7,6 +7,7 @@ namespace NuGetUpdater.Cli.Commands;
7
7
 
8
8
  internal static class AnalyzeCommand
9
9
  {
10
+ internal static readonly Option<FileInfo> JobPathOption = new("--job-path") { IsRequired = true };
10
11
  internal static readonly Option<DirectoryInfo> RepoRootOption = new("--repo-root") { IsRequired = true };
11
12
  internal static readonly Option<FileInfo> DependencyFilePathOption = new("--dependency-file-path") { IsRequired = true };
12
13
  internal static readonly Option<FileInfo> DiscoveryFilePathOption = new("--discovery-file-path") { IsRequired = true };
@@ -16,6 +17,7 @@ internal static class AnalyzeCommand
16
17
  {
17
18
  Command command = new("analyze", "Determines how to update a dependency based on the workspace discovery information.")
18
19
  {
20
+ JobPathOption,
19
21
  RepoRootOption,
20
22
  DependencyFilePathOption,
21
23
  DiscoveryFilePathOption,
@@ -24,11 +26,13 @@ internal static class AnalyzeCommand
24
26
 
25
27
  command.TreatUnmatchedTokensAsErrors = true;
26
28
 
27
- command.SetHandler(async (repoRoot, discoveryPath, dependencyPath, analysisDirectory) =>
29
+ command.SetHandler(async (jobPath, repoRoot, discoveryPath, dependencyPath, analysisDirectory) =>
28
30
  {
29
- var worker = new AnalyzeWorker(new ConsoleLogger());
31
+ var logger = new ConsoleLogger();
32
+ var experimentsManager = await ExperimentsManager.FromJobFileAsync(jobPath.FullName, logger);
33
+ var worker = new AnalyzeWorker(experimentsManager, logger);
30
34
  await worker.RunAsync(repoRoot.FullName, discoveryPath.FullName, dependencyPath.FullName, analysisDirectory.FullName);
31
- }, RepoRootOption, DiscoveryFilePathOption, DependencyFilePathOption, AnalysisFolderOption);
35
+ }, JobPathOption, RepoRootOption, DiscoveryFilePathOption, DependencyFilePathOption, AnalysisFolderOption);
32
36
 
33
37
  return command;
34
38
  }
@@ -36,7 +36,7 @@ internal static class RunCommand
36
36
  var logger = new ConsoleLogger();
37
37
  var experimentsManager = await ExperimentsManager.FromJobFileAsync(jobPath.FullName, logger);
38
38
  var discoverWorker = new DiscoveryWorker(experimentsManager, logger);
39
- var analyzeWorker = new AnalyzeWorker(logger);
39
+ var analyzeWorker = new AnalyzeWorker(experimentsManager, logger);
40
40
  var updateWorker = new UpdaterWorker(experimentsManager, logger);
41
41
  var worker = new RunWorker(apiHandler, discoverWorker, analyzeWorker, updateWorker, logger);
42
42
  await worker.RunAsync(jobPath, repoContentsPath, baseCommitSha, outputPath);
@@ -26,6 +26,8 @@ public partial class EntryPointTests
26
26
  await RunAsync(path =>
27
27
  [
28
28
  "analyze",
29
+ "--job-path",
30
+ Path.Combine(path, "job.json"),
29
31
  "--repo-root",
30
32
  path,
31
33
  "--discovery-file-path",
@@ -94,7 +96,9 @@ public partial class EntryPointTests
94
96
  "TargetFrameworks": [
95
97
  "net8.0"
96
98
  ],
97
- "ReferencedProjectPaths": []
99
+ "ReferencedProjectPaths": [],
100
+ "ImportedFiles": [],
101
+ "AdditionalFiles": []
98
102
  }
99
103
  ],
100
104
  "DirectoryPackagesProps": null,
@@ -142,6 +146,8 @@ public partial class EntryPointTests
142
146
  await RunAsync(path =>
143
147
  [
144
148
  "analyze",
149
+ "--job-path",
150
+ Path.Combine(path, "job.json"),
145
151
  "--repo-root",
146
152
  path,
147
153
  "--discovery-file-path",
@@ -229,6 +235,8 @@ public partial class EntryPointTests
229
235
  await RunAsync(path =>
230
236
  [
231
237
  "analyze",
238
+ "--job-path",
239
+ Path.Combine(path, "job.json"),
232
240
  "--repo-root",
233
241
  path,
234
242
  "--discovery-file-path",
@@ -306,8 +314,16 @@ public partial class EntryPointTests
306
314
  );
307
315
  }
308
316
 
309
- private static async Task RunAsync(Func<string, string[]> getArgs, string dependencyName, TestFile[] initialFiles, ExpectedAnalysisResult expectedResult, MockNuGetPackage[]? packages = null)
317
+ private static async Task RunAsync(
318
+ Func<string, string[]> getArgs,
319
+ string dependencyName,
320
+ TestFile[] initialFiles,
321
+ ExpectedAnalysisResult expectedResult,
322
+ MockNuGetPackage[]? packages = null,
323
+ ExperimentsManager? experimentsManager = null
324
+ )
310
325
  {
326
+ experimentsManager ??= new ExperimentsManager();
311
327
  var actualResult = await RunAnalyzerAsync(dependencyName, initialFiles, async path =>
312
328
  {
313
329
  var sb = new StringBuilder();
@@ -320,8 +336,19 @@ public partial class EntryPointTests
320
336
 
321
337
  try
322
338
  {
339
+ await UpdateWorkerTestBase.MockJobFileInDirectory(path, experimentsManager);
323
340
  await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, path);
324
341
  var args = getArgs(path);
342
+
343
+ // manually pull out the experiments manager for the validate step below
344
+ for (int i = 0; i < args.Length - 1; i++)
345
+ {
346
+ if (args[i] == "--job-path")
347
+ {
348
+ experimentsManager = await ExperimentsManager.FromJobFileAsync(args[i + 1], new TestLogger());
349
+ }
350
+ }
351
+
325
352
  var result = await Program.Main(args);
326
353
  if (result != 0)
327
354
  {
@@ -66,6 +66,9 @@ public partial class EntryPointTests
66
66
  Properties = [
67
67
  new("TargetFramework", "net8.0", "path/to/some directory with spaces/project.csproj"),
68
68
  ],
69
+ ReferencedProjectPaths = [],
70
+ ImportedFiles = [],
71
+ AdditionalFiles = [],
69
72
  }
70
73
  ]
71
74
  }
@@ -156,6 +159,11 @@ public partial class EntryPointTests
156
159
  new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"]),
157
160
  ],
158
161
  Properties = [],
162
+ ReferencedProjectPaths = [],
163
+ ImportedFiles = [],
164
+ AdditionalFiles = [
165
+ "packages.config"
166
+ ],
159
167
  }
160
168
  ]
161
169
  }
@@ -223,6 +231,11 @@ public partial class EntryPointTests
223
231
  new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
224
232
  ],
225
233
  Properties = [],
234
+ ReferencedProjectPaths = [],
235
+ ImportedFiles = [],
236
+ AdditionalFiles = [
237
+ "packages.config"
238
+ ],
226
239
  }
227
240
  ]
228
241
  }
@@ -291,6 +304,11 @@ public partial class EntryPointTests
291
304
  new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
292
305
  ],
293
306
  Properties = [],
307
+ ReferencedProjectPaths = [],
308
+ ImportedFiles = [],
309
+ AdditionalFiles = [
310
+ "packages.config"
311
+ ],
294
312
  }
295
313
  ]
296
314
  }
@@ -359,11 +377,13 @@ public partial class EntryPointTests
359
377
  new("ManagePackageVersionsCentrally", "false", "path/to/my.csproj"),
360
378
  new("TargetFramework", "net8.0", "path/to/my.csproj"),
361
379
  ],
380
+ ReferencedProjectPaths = [],
381
+ ImportedFiles = [
382
+ "../Directory.Build.props"
383
+ ],
384
+ AdditionalFiles = [],
362
385
  }
363
386
  ],
364
- ImportedFiles = [
365
- "Directory.Build.props"
366
- ]
367
387
  }
368
388
  );
369
389
  }
@@ -373,7 +393,8 @@ public partial class EntryPointTests
373
393
  TestFile[] initialFiles,
374
394
  ExpectedWorkspaceDiscoveryResult expectedResult,
375
395
  MockNuGetPackage[]? packages = null,
376
- ExperimentsManager? experimentsManager = null)
396
+ ExperimentsManager? experimentsManager = null
397
+ )
377
398
  {
378
399
  experimentsManager ??= new ExperimentsManager();
379
400
  var actualResult = await RunDiscoveryAsync(initialFiles, async path =>
@@ -41,12 +41,6 @@ public partial class EntryPointTests
41
41
  ],
42
42
  job: new Job()
43
43
  {
44
- AllowedUpdates = [
45
- new()
46
- {
47
- UpdateType = "all"
48
- }
49
- ],
50
44
  Source = new()
51
45
  {
52
46
  Provider = "github",
@@ -16,31 +16,33 @@ public partial class AnalyzeWorker : IAnalyzeWorker
16
16
  {
17
17
  public const string AnalysisDirectoryName = "./.dependabot/analysis";
18
18
 
19
+ private readonly ExperimentsManager _experimentsManager;
19
20
  private readonly ILogger _logger;
20
21
 
21
22
  internal static readonly JsonSerializerOptions SerializerOptions = new()
22
23
  {
23
24
  WriteIndented = true,
24
- Converters = { new JsonStringEnumConverter(), new RequirementConverter() },
25
+ Converters = { new JsonStringEnumConverter(), new RequirementArrayConverter() },
25
26
  };
26
27
 
27
- public AnalyzeWorker(ILogger logger)
28
+ public AnalyzeWorker(ExperimentsManager experimentsManager, ILogger logger)
28
29
  {
30
+ _experimentsManager = experimentsManager;
29
31
  _logger = logger;
30
32
  }
31
33
 
32
34
  public async Task RunAsync(string repoRoot, string discoveryPath, string dependencyPath, string analysisDirectory)
33
35
  {
34
36
  var analysisResult = await RunWithErrorHandlingAsync(repoRoot, discoveryPath, dependencyPath);
35
- var dependencyInfo = await DeserializeJsonFileAsync<DependencyInfo>(dependencyPath, nameof(DependencyInfo));
37
+ var dependencyInfo = await DeserializeDependencyInfoFileAsync(dependencyPath);
36
38
  await WriteResultsAsync(analysisDirectory, dependencyInfo.Name, analysisResult, _logger);
37
39
  }
38
40
 
39
41
  internal async Task<AnalysisResult> RunWithErrorHandlingAsync(string repoRoot, string discoveryPath, string dependencyPath)
40
42
  {
41
43
  AnalysisResult analysisResult;
42
- var discovery = await DeserializeJsonFileAsync<WorkspaceDiscoveryResult>(discoveryPath, nameof(WorkspaceDiscoveryResult));
43
- var dependencyInfo = await DeserializeJsonFileAsync<DependencyInfo>(dependencyPath, nameof(DependencyInfo));
44
+ var discovery = await DeserializeWorkspaceDiscoveryResultFileAsync(discoveryPath);
45
+ var dependencyInfo = await DeserializeDependencyInfoFileAsync(dependencyPath);
44
46
 
45
47
  try
46
48
  {
@@ -68,7 +70,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
68
70
  {
69
71
  var startingDirectory = PathHelper.JoinPath(repoRoot, discovery.Path);
70
72
 
71
- _logger.Log($"Starting analysis of {dependencyInfo.Name}...");
73
+ _logger.Info($"Starting analysis of {dependencyInfo.Name}...");
72
74
 
73
75
  // We need to find all projects which have the given dependency. Even in cases that they
74
76
  // have it transitively may require that peer dependencies be updated in the project.
@@ -97,7 +99,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
97
99
  AnalysisResult analysisResult;
98
100
  if (isUpdateNecessary)
99
101
  {
100
- _logger.Log($" Determining multi-dependency property.");
102
+ _logger.Info($" Determining multi-dependency property.");
101
103
  var multiDependencies = DetermineMultiDependencyDetails(
102
104
  discovery,
103
105
  dependencyInfo.Name,
@@ -117,7 +119,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
117
119
  .ToImmutableArray()
118
120
  : projectFrameworks;
119
121
 
120
- _logger.Log($" Finding updated version.");
122
+ _logger.Info($" Finding updated version.");
121
123
  updatedVersion = await FindUpdatedVersionAsync(
122
124
  startingDirectory,
123
125
  dependencyInfo,
@@ -127,7 +129,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
127
129
  _logger,
128
130
  CancellationToken.None);
129
131
 
130
- _logger.Log($" Finding updated peer dependencies.");
132
+ _logger.Info($" Finding updated peer dependencies.");
131
133
  if (updatedVersion is null)
132
134
  {
133
135
  updatedDependencies = [];
@@ -173,7 +175,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
173
175
  UpdatedDependencies = updatedDependencies,
174
176
  };
175
177
 
176
- _logger.Log($"Analysis complete.");
178
+ _logger.Info($"Analysis complete.");
177
179
  return analysisResult;
178
180
  }
179
181
 
@@ -197,13 +199,28 @@ public partial class AnalyzeWorker : IAnalyzeWorker
197
199
  !d.IsTransitive));
198
200
  }
199
201
 
200
- internal static async Task<T> DeserializeJsonFileAsync<T>(string path, string fileType)
202
+ private static Task<WorkspaceDiscoveryResult> DeserializeWorkspaceDiscoveryResultFileAsync(string path)
201
203
  {
202
- var json = File.Exists(path)
203
- ? await File.ReadAllTextAsync(path)
204
- : throw new FileNotFoundException($"{fileType} file not found.", path);
204
+ return DeserializeJsonFileAsync(path, nameof(WorkspaceDiscoveryResult), json => JsonSerializer.Deserialize<WorkspaceDiscoveryResult>(json, SerializerOptions));
205
+ }
206
+
207
+ private static Task<DependencyInfo> DeserializeDependencyInfoFileAsync(string path)
208
+ {
209
+ return DeserializeJsonFileAsync(path, nameof(DependencyInfo), DeserializeDependencyInfo);
210
+ }
211
+
212
+ internal static DependencyInfo? DeserializeDependencyInfo(string content)
213
+ {
214
+ return JsonSerializer.Deserialize<DependencyInfo>(content, SerializerOptions);
215
+ }
216
+
217
+ private static async Task<T> DeserializeJsonFileAsync<T>(string filePath, string fileType, Func<string, T?> deserializer)
218
+ {
219
+ var json = File.Exists(filePath)
220
+ ? await File.ReadAllTextAsync(filePath)
221
+ : throw new FileNotFoundException($"{fileType} file not found.", filePath);
205
222
 
206
- return JsonSerializer.Deserialize<T>(json, SerializerOptions)
223
+ return deserializer(json)
207
224
  ?? throw new InvalidOperationException($"{fileType} file is empty.");
208
225
  }
209
226
 
@@ -468,7 +485,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
468
485
 
469
486
  var resultPath = Path.Combine(analysisDirectory, $"{dependencyName}.json");
470
487
 
471
- logger.Log($" Writing analysis result to [{resultPath}].");
488
+ logger.Info($" Writing analysis result to [{resultPath}].");
472
489
 
473
490
  var resultJson = JsonSerializer.Serialize(result, SerializerOptions);
474
491
  await File.WriteAllTextAsync(path: resultPath, resultJson);
@@ -68,7 +68,7 @@ internal static class CompatibilityChecker
68
68
  var incompatibleFrameworks = projectFrameworks.Where(f => !compatibleFrameworks.Contains(f)).ToArray();
69
69
  if (incompatibleFrameworks.Length > 0)
70
70
  {
71
- logger.Log($"The package {package} is not compatible. Incompatible project frameworks: {string.Join(", ", incompatibleFrameworks.Select(f => f.GetShortFolderName()))}");
71
+ logger.Info($"The package {package} is not compatible. Incompatible project frameworks: {string.Join(", ", incompatibleFrameworks.Select(f => f.GetShortFolderName()))}");
72
72
  return false;
73
73
  }
74
74
 
@@ -80,9 +80,9 @@ internal static class CompatibilityChecker
80
80
  NuGetContext nugetContext,
81
81
  CancellationToken cancellationToken)
82
82
  {
83
- var tempPackagePath = GetTempPackagePath(package, nugetContext);
84
- var readers = File.Exists(tempPackagePath)
85
- ? ReadPackage(tempPackagePath)
83
+ var packagePath = GetPackagePath(package, nugetContext);
84
+ var readers = File.Exists(packagePath)
85
+ ? ReadPackage(packagePath)
86
86
  : await DownloadPackageAsync(package, nugetContext, cancellationToken);
87
87
  return readers;
88
88
  }
@@ -134,10 +134,10 @@ internal static class CompatibilityChecker
134
134
  return (isDevDependency, tfms.ToImmutableArray());
135
135
  }
136
136
 
137
- internal static PackageReaders ReadPackage(string tempPackagePath)
137
+ internal static PackageReaders ReadPackage(string packagePath)
138
138
  {
139
139
  var stream = new FileStream(
140
- tempPackagePath,
140
+ packagePath,
141
141
  FileMode.Open,
142
142
  FileAccess.Read,
143
143
  FileShare.Read,
@@ -194,8 +194,8 @@ internal static class CompatibilityChecker
194
194
  context.Logger,
195
195
  cancellationToken);
196
196
 
197
- var tempPackagePath = GetTempPackagePath(package, context);
198
- var isDownloaded = await downloader.CopyNupkgFileToAsync(tempPackagePath, cancellationToken);
197
+ var packagePath = GetPackagePath(package, context);
198
+ var isDownloaded = await downloader.CopyNupkgFileToAsync(packagePath, cancellationToken);
199
199
  if (!isDownloaded)
200
200
  {
201
201
  continue;
@@ -207,6 +207,21 @@ internal static class CompatibilityChecker
207
207
  return null;
208
208
  }
209
209
 
210
- internal static string GetTempPackagePath(PackageIdentity package, NuGetContext context)
211
- => Path.Combine(context.TempPackageDirectory, package.Id + "." + package.Version + ".nupkg");
210
+ internal static string GetPackagePath(PackageIdentity package, NuGetContext context)
211
+ {
212
+ // https://learn.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders
213
+ var nugetPackagesPath = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
214
+ if (nugetPackagesPath is null)
215
+ {
216
+ // n.b., this path should never be hit during a unit test
217
+ nugetPackagesPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages");
218
+ }
219
+
220
+ var normalizedName = package.Id.ToLowerInvariant();
221
+ var normalizedVersion = package.Version.ToNormalizedString().ToLowerInvariant();
222
+ var packageDirectory = Path.Join(nugetPackagesPath, normalizedName, normalizedVersion);
223
+ Directory.CreateDirectory(packageDirectory);
224
+ var packagePath = Path.Join(packageDirectory, $"{normalizedName}.{normalizedVersion}.nupkg");
225
+ return packagePath;
226
+ }
212
227
  }
@@ -20,7 +20,6 @@ internal record NuGetContext : IDisposable
20
20
  public IMachineWideSettings MachineWideSettings { get; }
21
21
  public ImmutableArray<PackageSource> PackageSources { get; }
22
22
  public NuGet.Common.ILogger Logger { get; }
23
- public string TempPackageDirectory { get; }
24
23
 
25
24
  public NuGetContext(string? currentDirectory = null, NuGet.Common.ILogger? logger = null)
26
25
  {
@@ -37,23 +36,11 @@ internal record NuGetContext : IDisposable
37
36
  .Where(p => p.IsEnabled)
38
37
  .ToImmutableArray();
39
38
  Logger = logger ?? NullLogger.Instance;
40
- TempPackageDirectory = Path.Combine(Path.GetTempPath(), $"dependabot-packages_{Guid.NewGuid():d}");
41
- Directory.CreateDirectory(TempPackageDirectory);
42
39
  }
43
40
 
44
41
  public void Dispose()
45
42
  {
46
43
  SourceCacheContext.Dispose();
47
- if (Directory.Exists(TempPackageDirectory))
48
- {
49
- try
50
- {
51
- Directory.Delete(TempPackageDirectory, recursive: true);
52
- }
53
- catch
54
- {
55
- }
56
- }
57
44
  }
58
45
 
59
46
  private readonly Dictionary<PackageIdentity, string?> _packageInfoUrlCache = new();
@@ -0,0 +1,39 @@
1
+ using System.Collections.Immutable;
2
+ using System.Text.Json;
3
+ using System.Text.Json.Serialization;
4
+
5
+ namespace NuGetUpdater.Core.Analyze;
6
+
7
+ public class RequirementArrayConverter : JsonConverter<ImmutableArray<Requirement>>
8
+ {
9
+ public override ImmutableArray<Requirement> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
10
+ {
11
+ var requirements = new List<Requirement>();
12
+ var requirementStrings = JsonSerializer.Deserialize<string[]>(ref reader, options) ?? [];
13
+ foreach (var requirementString in requirementStrings)
14
+ {
15
+ try
16
+ {
17
+ var requirement = Requirement.Parse(requirementString);
18
+ requirements.Add(requirement);
19
+ }
20
+ catch (ArgumentException)
21
+ {
22
+ // couldn't parse, nothing to do
23
+ }
24
+ }
25
+
26
+ return requirements.ToImmutableArray();
27
+ }
28
+
29
+ public override void Write(Utf8JsonWriter writer, ImmutableArray<Requirement> value, JsonSerializerOptions options)
30
+ {
31
+ writer.WriteStartArray();
32
+ foreach (var requirement in value)
33
+ {
34
+ writer.WriteStringValue(requirement.ToString());
35
+ }
36
+
37
+ writer.WriteEndArray();
38
+ }
39
+ }
@@ -62,7 +62,7 @@ internal static class VersionFinder
62
62
  var feed = await sourceRepository.GetResourceAsync<MetadataResource>();
63
63
  if (feed is null)
64
64
  {
65
- logger.Log($"Failed to get MetadataResource for [{source.Source}]");
65
+ logger.Warn($"Failed to get MetadataResource for [{source.Source}]");
66
66
  continue;
67
67
  }
68
68
 
@@ -13,7 +13,7 @@ public class ShellGitCommandHandler : IGitCommandHandler
13
13
 
14
14
  public async Task RunGitCommandAsync(IReadOnlyCollection<string> args, string? workingDirectory = null)
15
15
  {
16
- _logger.Log($"Running command: git {string.Join(" ", args)}{(workingDirectory is null ? "" : $" in directory {workingDirectory}")}");
16
+ _logger.Info($"Running command: git {string.Join(" ", args)}{(workingDirectory is null ? "" : $" in directory {workingDirectory}")}");
17
17
  var (exitCode, stdout, stderr) = await ProcessEx.RunAsync("git", args, workingDirectory);
18
18
  HandleErrorsFromOutput(stdout, stderr);
19
19
  }