dependabot-nuget 0.263.0 → 0.264.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +37 -0
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +3 -3
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +1 -0
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +169 -0
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +79 -67
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.FrameworkCheck.cs +0 -4
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +10 -11
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalysisResult.cs +11 -0
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +441 -0
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +177 -0
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyFinder.cs +47 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyInfo.cs +12 -0
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/Extensions.cs +36 -0
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/NuGetContext.cs +128 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/Requirement.cs +105 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs +17 -0
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/SecurityVulnerability.cs +11 -0
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/SecurityVulnerabilityExtensions.cs +36 -0
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +179 -0
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionResult.cs +54 -0
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Dependency.cs +5 -2
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +2 -1
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +2 -2
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +0 -2
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs +0 -3
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs +0 -3
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +0 -5
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs +0 -4
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +6 -2
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/WebApplicationTargetsConditionPatcher.cs +0 -4
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/XmlFilePreAndPostProcessor.cs +0 -2
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/HashSetExtensions.cs +0 -2
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +0 -4
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/Logger.cs +0 -3
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +7 -8
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +0 -4
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +0 -3
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/XmlExtensions.cs +0 -4
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTestBase.cs +90 -0
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +304 -0
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/CompatibilityCheckerTests.cs +145 -0
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/ExpectedAnalysisResult.cs +8 -0
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/RequirementTests.cs +69 -0
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/SecurityVulnerabilityExtensionsTests.cs +78 -0
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/VersionFinderTests.cs +193 -0
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +1 -2
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +2 -2
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +2 -2
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +1 -1
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +1 -1
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +102 -9
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +4 -4
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +2 -2
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +8 -2
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +2 -1
  57. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +8 -7
  58. data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +63 -0
  59. data/lib/dependabot/nuget/analysis/dependency_analysis.rb +63 -0
  60. data/lib/dependabot/nuget/file_fetcher.rb +7 -6
  61. data/lib/dependabot/nuget/file_parser.rb +28 -21
  62. data/lib/dependabot/nuget/file_updater.rb +22 -25
  63. data/lib/dependabot/nuget/metadata_finder.rb +2 -160
  64. data/lib/dependabot/nuget/native_discovery/native_dependency_details.rb +102 -0
  65. data/lib/dependabot/nuget/native_discovery/native_dependency_file_discovery.rb +129 -0
  66. data/lib/dependabot/nuget/native_discovery/native_directory_packages_props_discovery.rb +44 -0
  67. data/lib/dependabot/nuget/native_discovery/native_discovery_json_reader.rb +174 -0
  68. data/lib/dependabot/nuget/native_discovery/native_evaluation_details.rb +63 -0
  69. data/lib/dependabot/nuget/native_discovery/native_project_discovery.rb +82 -0
  70. data/lib/dependabot/nuget/native_discovery/native_property_details.rb +43 -0
  71. data/lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb +68 -0
  72. data/lib/dependabot/nuget/native_helpers.rb +59 -0
  73. data/lib/dependabot/nuget/native_update_checker/native_requirements_updater.rb +105 -0
  74. data/lib/dependabot/nuget/native_update_checker/native_update_checker.rb +200 -0
  75. data/lib/dependabot/nuget/nuget_config_credential_helpers.rb +3 -2
  76. data/lib/dependabot/nuget/update_checker.rb +47 -0
  77. metadata +39 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b855d54271454917bba3570280c68fe5d40692701654f284412132158c77a86
4
- data.tar.gz: d599048afc3f22e57d0767587e16a3bb2b2eee951f6a1f56d9b713c07baf8a91
3
+ metadata.gz: 374eac378d18521cbfed963fc5319709e1ca86c07a2b5db887e6e7fcd89b5fb4
4
+ data.tar.gz: b1c6b74d727ccdd8d7de8e4626bdbfc74caae7f3d0368b997518b71ee21b1b6d
5
5
  SHA512:
6
- metadata.gz: 4f70f9da88e35221a82c61355aa6d689a2e20eedfb8d4a2d1e62f43b9076d3b256fdb8a3de65b0fb22d8ef1579a336e98a9423ea0870056bc88df9db50407ff0
7
- data.tar.gz: 158d0fd0d8f6f8a2519712101a10ecd7c13caebbbdabacc0c09759d99cc7180e052dffbe10c23eb36b4cb8e7738d2229569370eb60b11642335c950b4e58dc9e
6
+ metadata.gz: f9e72f43e70e24dceedd5474b802af066aafa8df6516e65878a11d8b50b1364fe56d694f7457e04e5a3205018c93257719e8895dd8f35e2ee75a098ec59e2fc9
7
+ data.tar.gz: 2ca5feb309686d3eea541b38143dce03354d7d468bc7ffa8864d9b83efd15f3ef65ce8a99d0c5d1fb7fba0c8b4be18747b13adac3d3a7979415d01cc11f308d2
@@ -0,0 +1,37 @@
1
+ using System.CommandLine;
2
+
3
+ using NuGetUpdater.Core;
4
+ using NuGetUpdater.Core.Analyze;
5
+
6
+ namespace NuGetUpdater.Cli.Commands;
7
+
8
+ internal static class AnalyzeCommand
9
+ {
10
+ internal static readonly Option<DirectoryInfo> RepoRootOption = new("--repo-root") { IsRequired = true };
11
+ internal static readonly Option<FileInfo> DependencyFilePathOption = new("--dependency-file-path") { IsRequired = true };
12
+ internal static readonly Option<FileInfo> DiscoveryFilePathOption = new("--discovery-file-path") { IsRequired = true };
13
+ internal static readonly Option<DirectoryInfo> AnalysisFolderOption = new("--analysis-folder-path") { IsRequired = true };
14
+ internal static readonly Option<bool> VerboseOption = new("--verbose", getDefaultValue: () => false);
15
+
16
+ internal static Command GetCommand(Action<int> setExitCode)
17
+ {
18
+ Command command = new("analyze", "Determines how to update a dependency based on the workspace discovery information.")
19
+ {
20
+ RepoRootOption,
21
+ DependencyFilePathOption,
22
+ DiscoveryFilePathOption,
23
+ AnalysisFolderOption,
24
+ VerboseOption
25
+ };
26
+
27
+ command.TreatUnmatchedTokensAsErrors = true;
28
+
29
+ command.SetHandler(async (repoRoot, discoveryPath, dependencyPath, analysisDirectory, verbose) =>
30
+ {
31
+ var worker = new AnalyzeWorker(new Logger(verbose));
32
+ await worker.RunAsync(repoRoot.FullName, discoveryPath.FullName, dependencyPath.FullName, analysisDirectory.FullName);
33
+ }, RepoRootOption, DiscoveryFilePathOption, DependencyFilePathOption, AnalysisFolderOption, VerboseOption);
34
+
35
+ return command;
36
+ }
37
+ }
@@ -7,9 +7,9 @@ namespace NuGetUpdater.Cli.Commands;
7
7
 
8
8
  internal static class DiscoverCommand
9
9
  {
10
- internal static readonly Option<DirectoryInfo> RepoRootOption = new("--repo-root", () => new DirectoryInfo(Environment.CurrentDirectory)) { IsRequired = false };
10
+ internal static readonly Option<DirectoryInfo> RepoRootOption = new("--repo-root") { IsRequired = true };
11
11
  internal static readonly Option<string> WorkspaceOption = new("--workspace") { IsRequired = true };
12
- internal static readonly Option<string> OutputOption = new("--output", () => DiscoveryWorker.DiscoveryResultFileName) { IsRequired = false };
12
+ internal static readonly Option<FileInfo> OutputOption = new("--output") { IsRequired = true };
13
13
  internal static readonly Option<bool> VerboseOption = new("--verbose", getDefaultValue: () => false);
14
14
 
15
15
  internal static Command GetCommand(Action<int> setExitCode)
@@ -27,7 +27,7 @@ internal static class DiscoverCommand
27
27
  command.SetHandler(async (repoRoot, workspace, outputPath, verbose) =>
28
28
  {
29
29
  var worker = new DiscoveryWorker(new Logger(verbose));
30
- await worker.RunAsync(repoRoot.FullName, workspace, outputPath);
30
+ await worker.RunAsync(repoRoot.FullName, workspace, outputPath.FullName);
31
31
  }, RepoRootOption, WorkspaceOption, OutputOption, VerboseOption);
32
32
 
33
33
  return command;
@@ -15,6 +15,7 @@ internal sealed class Program
15
15
  {
16
16
  FrameworkCheckCommand.GetCommand(setExitCode),
17
17
  DiscoverCommand.GetCommand(setExitCode),
18
+ AnalyzeCommand.GetCommand(setExitCode),
18
19
  UpdateCommand.GetCommand(setExitCode),
19
20
  };
20
21
  command.TreatUnmatchedTokensAsErrors = true;
@@ -0,0 +1,169 @@
1
+ using System.Text;
2
+ using System.Xml.Linq;
3
+
4
+ using NuGetUpdater.Core;
5
+ using NuGetUpdater.Core.Analyze;
6
+ using NuGetUpdater.Core.Test;
7
+ using NuGetUpdater.Core.Test.Analyze;
8
+ using NuGetUpdater.Core.Test.Update;
9
+
10
+ using Xunit;
11
+
12
+ namespace NuGetUpdater.Cli.Test;
13
+
14
+ using TestFile = (string Path, string Content);
15
+
16
+ public partial class EntryPointTests
17
+ {
18
+ public class Analyze : AnalyzeWorkerTestBase
19
+ {
20
+ [Fact]
21
+ public async Task FindsUpdatedPackageAndReturnsTheCorrectData()
22
+ {
23
+ var repositoryXml = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some.package" />""");
24
+ await RunAsync(path =>
25
+ [
26
+ "analyze",
27
+ "--repo-root",
28
+ path,
29
+ "--discovery-file-path",
30
+ Path.Join(path, "discovery.json"),
31
+ "--dependency-file-path",
32
+ Path.Join(path, "Some.Package.json"),
33
+ "--analysis-folder-path",
34
+ Path.Join(path, AnalyzeWorker.AnalysisDirectoryName),
35
+ "--verbose",
36
+ ],
37
+ packages: [
38
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", additionalMetadata: [repositoryXml]),
39
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.1", "net8.0", additionalMetadata: [repositoryXml]),
40
+ ],
41
+ dependencyName: "Some.Package",
42
+ initialFiles:
43
+ [
44
+ ("discovery.json", """
45
+ {
46
+ "Path": "",
47
+ "IsSuccess": true,
48
+ "Projects": [
49
+ {
50
+ "FilePath": "project.csproj",
51
+ "Dependencies": [
52
+ {
53
+ "Name": "Microsoft.NET.Sdk",
54
+ "Version": null,
55
+ "Type": "MSBuildSdk",
56
+ "EvaluationResult": null,
57
+ "TargetFrameworks": null,
58
+ "IsDevDependency": false,
59
+ "IsDirect": false,
60
+ "IsTransitive": false,
61
+ "IsOverride": false,
62
+ "IsUpdate": false
63
+ },
64
+ {
65
+ "Name": "Some.Package",
66
+ "Version": "1.0.0",
67
+ "Type": "PackageReference",
68
+ "EvaluationResult": {
69
+ "ResultType": "Success",
70
+ "OriginalValue": "1.0.0",
71
+ "EvaluatedValue": "1.0.0",
72
+ "RootPropertyName": null,
73
+ "ErrorMessage": null
74
+ },
75
+ "TargetFrameworks": [
76
+ "net8.0"
77
+ ],
78
+ "IsDevDependency": false,
79
+ "IsDirect": true,
80
+ "IsTransitive": false,
81
+ "IsOverride": false,
82
+ "IsUpdate": false
83
+ }
84
+ ],
85
+ "IsSuccess": true,
86
+ "Properties": [
87
+ {
88
+ "Name": "TargetFramework",
89
+ "Value": "net8.0",
90
+ "SourceFilePath": "project.csproj"
91
+ }
92
+ ],
93
+ "TargetFrameworks": [
94
+ "net8.0"
95
+ ],
96
+ "ReferencedProjectPaths": []
97
+ }
98
+ ],
99
+ "DirectoryPackagesProps": null,
100
+ "GlobalJson": null,
101
+ "DotNetToolsJson": null
102
+ }
103
+ """),
104
+ ("Some.Package.json", """
105
+ {
106
+ "Name": "Some.Package",
107
+ "Version": "1.0.0",
108
+ "IsVulnerable": false,
109
+ "IgnoredVersions": [],
110
+ "Vulnerabilities": []
111
+ }
112
+ """),
113
+ ("project.csproj", """
114
+ <Project Sdk="Microsoft.NET.Sdk">
115
+ <PropertyGroup>
116
+ <TargetFramework>net8.0</TargetFramework>
117
+ </PropertyGroup>
118
+ <ItemGroup>
119
+ <PackageReference Include="Some.Package" Version="1.0.0" />
120
+ </ItemGroup>
121
+ </Project>
122
+ """),
123
+ ],
124
+ expectedResult: new()
125
+ {
126
+ UpdatedVersion = "1.0.1",
127
+ CanUpdate = true,
128
+ VersionComesFromMultiDependencyProperty = false,
129
+ UpdatedDependencies =
130
+ [
131
+ new Dependency("Some.Package", "1.0.1", DependencyType.Unknown, TargetFrameworks: ["net8.0"], InfoUrl: "https://nuget.example.com/some.package")
132
+ ],
133
+ }
134
+ );
135
+ }
136
+
137
+ private static async Task RunAsync(Func<string, string[]> getArgs, string dependencyName, TestFile[] initialFiles, ExpectedAnalysisResult expectedResult, MockNuGetPackage[]? packages = null)
138
+ {
139
+ var actualResult = await RunAnalyzerAsync(dependencyName, initialFiles, async path =>
140
+ {
141
+ var sb = new StringBuilder();
142
+ var writer = new StringWriter(sb);
143
+
144
+ var originalOut = Console.Out;
145
+ var originalErr = Console.Error;
146
+ Console.SetOut(writer);
147
+ Console.SetError(writer);
148
+
149
+ try
150
+ {
151
+ await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, path);
152
+ var args = getArgs(path);
153
+ var result = await Program.Main(args);
154
+ if (result != 0)
155
+ {
156
+ throw new Exception($"Program exited with code {result}.\nOutput:\n\n{sb}");
157
+ }
158
+ }
159
+ finally
160
+ {
161
+ Console.SetOut(originalOut);
162
+ Console.SetError(originalErr);
163
+ }
164
+ });
165
+
166
+ ValidateAnalysisResult(expectedResult, actualResult);
167
+ }
168
+ }
169
+ }
@@ -1,6 +1,7 @@
1
1
  using System.Text;
2
2
 
3
3
  using NuGetUpdater.Core;
4
+ using NuGetUpdater.Core.Discover;
4
5
  using NuGetUpdater.Core.Test;
5
6
  using NuGetUpdater.Core.Test.Discover;
6
7
  using NuGetUpdater.Core.Test.Update;
@@ -25,6 +26,8 @@ public partial class EntryPointTests
25
26
  path,
26
27
  "--workspace",
27
28
  "path/to/some directory with spaces",
29
+ "--output",
30
+ Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName),
28
31
  ],
29
32
  packages: [],
30
33
  initialFiles:
@@ -42,7 +45,7 @@ public partial class EntryPointTests
42
45
  ],
43
46
  expectedResult: new()
44
47
  {
45
- FilePath = "path/to/some directory with spaces",
48
+ Path = "path/to/some directory with spaces",
46
49
  Projects = [
47
50
  new()
48
51
  {
@@ -72,6 +75,8 @@ public partial class EntryPointTests
72
75
  path,
73
76
  "--workspace",
74
77
  "/",
78
+ "--output",
79
+ Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName),
75
80
  ],
76
81
  packages:
77
82
  [
@@ -129,7 +134,7 @@ public partial class EntryPointTests
129
134
  },
130
135
  expectedResult: new()
131
136
  {
132
- FilePath = "",
137
+ Path = "",
133
138
  Projects = [
134
139
  new()
135
140
  {
@@ -159,6 +164,8 @@ public partial class EntryPointTests
159
164
  path,
160
165
  "--workspace",
161
166
  "path/to",
167
+ "--output",
168
+ Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName),
162
169
  ],
163
170
  packages:
164
171
  [
@@ -193,7 +200,7 @@ public partial class EntryPointTests
193
200
  },
194
201
  expectedResult: new()
195
202
  {
196
- FilePath = "path/to",
203
+ Path = "path/to",
197
204
  Projects = [
198
205
  new()
199
206
  {
@@ -224,6 +231,8 @@ public partial class EntryPointTests
224
231
  path,
225
232
  "--workspace",
226
233
  workspacePath,
234
+ "--output",
235
+ Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName),
227
236
  ],
228
237
  packages:
229
238
  [
@@ -258,7 +267,7 @@ public partial class EntryPointTests
258
267
  },
259
268
  expectedResult: new()
260
269
  {
261
- FilePath = workspacePath,
270
+ Path = workspacePath,
262
271
  Projects = [
263
272
  new()
264
273
  {
@@ -282,69 +291,72 @@ public partial class EntryPointTests
282
291
  public async Task WithDuplicateDependenciesOfDifferentTypes()
283
292
  {
284
293
  await RunAsync(path =>
285
- [
286
- "discover",
287
- "--repo-root",
288
- path,
289
- "--workspace",
290
- "path/to",
291
- ],
292
- new[]
293
- {
294
- ("path/to/my.csproj", """
295
- <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
296
- <PropertyGroup>
297
- <TargetFramework>net8.0</TargetFramework>
298
- </PropertyGroup>
299
- <ItemGroup>
300
- <PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
301
- </ItemGroup>
302
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
303
- </Project>
304
- """),
305
- ("path/Directory.Build.props", """
306
- <Project>
307
- <ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
308
- <GlobalPackageReference Include="System.Text.Json" Version="8.0.3" />
309
- </ItemGroup>
310
- <ItemGroup Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
311
- <PackageReference Include="System.Text.Json" Version="8.0.3" />
312
- </ItemGroup>
313
- </Project>
314
- """)
315
- },
316
- expectedResult: new()
317
- {
318
- FilePath = "path/to",
319
- Projects = [
320
- new()
321
- {
322
- FilePath = "my.csproj",
323
- TargetFrameworks = ["net8.0"],
324
- ReferencedProjectPaths = [],
325
- ExpectedDependencyCount = 2,
326
- Dependencies = [
327
- new("Newtonsoft.Json", "7.0.1", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true),
328
- // $(ManagePackageVersionsCentrally) evaluates false by default, we only get a PackageReference
329
- new("System.Text.Json", "8.0.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0"])
330
- ],
331
- Properties = [
332
- new("TargetFramework", "net8.0", "path/to/my.csproj"),
333
- ],
334
- },
335
- new()
336
- {
337
- FilePath = "../Directory.Build.props",
338
- ReferencedProjectPaths = [],
339
- ExpectedDependencyCount = 2,
340
- Dependencies = [
341
- new("System.Text.Json", "8.0.3", DependencyType.PackageReference, IsDirect: true),
342
- new("System.Text.Json", "8.0.3", DependencyType.GlobalPackageReference, IsDirect: true)
343
- ],
344
- Properties = [],
345
- }
346
- ]
347
- });
294
+ [
295
+ "discover",
296
+ "--repo-root",
297
+ path,
298
+ "--workspace",
299
+ "path/to",
300
+ "--output",
301
+ Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName)
302
+ ],
303
+ new[]
304
+ {
305
+ ("path/to/my.csproj", """
306
+ <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
307
+ <PropertyGroup>
308
+ <TargetFramework>net8.0</TargetFramework>
309
+ </PropertyGroup>
310
+ <ItemGroup>
311
+ <PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
312
+ </ItemGroup>
313
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
314
+ </Project>
315
+ """),
316
+ ("path/Directory.Build.props", """
317
+ <Project>
318
+ <ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
319
+ <GlobalPackageReference Include="System.Text.Json" Version="8.0.3" />
320
+ </ItemGroup>
321
+ <ItemGroup Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
322
+ <PackageReference Include="System.Text.Json" Version="8.0.3" />
323
+ </ItemGroup>
324
+ </Project>
325
+ """)
326
+ },
327
+ expectedResult: new()
328
+ {
329
+ Path = "path/to",
330
+ Projects = [
331
+ new()
332
+ {
333
+ FilePath = "my.csproj",
334
+ TargetFrameworks = ["net8.0"],
335
+ ReferencedProjectPaths = [],
336
+ ExpectedDependencyCount = 2,
337
+ Dependencies = [
338
+ new("Newtonsoft.Json", "7.0.1", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true),
339
+ // $(ManagePackageVersionsCentrally) evaluates false by default, we only get a PackageReference
340
+ new("System.Text.Json", "8.0.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0"])
341
+ ],
342
+ Properties = [
343
+ new("TargetFramework", "net8.0", "path/to/my.csproj"),
344
+ ],
345
+ },
346
+ new()
347
+ {
348
+ FilePath = "../Directory.Build.props",
349
+ ReferencedProjectPaths = [],
350
+ ExpectedDependencyCount = 2,
351
+ Dependencies = [
352
+ new("System.Text.Json", "8.0.3", DependencyType.PackageReference, IsDirect: true),
353
+ new("System.Text.Json", "8.0.3", DependencyType.GlobalPackageReference, IsDirect: true)
354
+ ],
355
+ Properties = [],
356
+ }
357
+ ]
358
+ }
359
+ );
348
360
  }
349
361
 
350
362
  private static async Task RunAsync(
@@ -1,7 +1,3 @@
1
- using System;
2
- using System.Collections.Generic;
3
- using System.Threading.Tasks;
4
-
5
1
  using Xunit;
6
2
 
7
3
  namespace NuGetUpdater.Cli.Test;
@@ -44,19 +44,19 @@ public partial class EntryPointTests
44
44
  Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "my", "my.csproj", "{782E0C0A-10D3-444D-9640-263D03D2B20C}"
45
45
  EndProject
46
46
  Global
47
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
47
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
48
48
  Debug|Any CPU = Debug|Any CPU
49
49
  Release|Any CPU = Release|Any CPU
50
- EndGlobalSection
51
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
50
+ EndGlobalSection
51
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
52
52
  {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53
53
  {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.Build.0 = Debug|Any CPU
54
54
  {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.ActiveCfg = Release|Any CPU
55
55
  {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.Build.0 = Release|Any CPU
56
- EndGlobalSection
57
- GlobalSection(SolutionProperties) = preSolution
56
+ EndGlobalSection
57
+ GlobalSection(SolutionProperties) = preSolution
58
58
  HideSolutionNode = FALSE
59
- EndGlobalSection
59
+ EndGlobalSection
60
60
  EndGlobal
61
61
  """),
62
62
  ("path/to/my.csproj", """
@@ -82,7 +82,7 @@ public partial class EntryPointTests
82
82
  <package id="Some.Package" version="7.0.1" targetFramework="net45" />
83
83
  </packages>
84
84
  """)
85
- ],
85
+ ],
86
86
  expectedFiles:
87
87
  [
88
88
  ("path/to/my.csproj", """
@@ -253,7 +253,7 @@ public partial class EntryPointTests
253
253
  """),
254
254
  ("other-dir/Directory.Build.props", """
255
255
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
256
-
256
+
257
257
  <ItemGroup>
258
258
  <PackageReference Include="Some.Package" Version="6.1.0" />
259
259
  </ItemGroup>
@@ -271,8 +271,7 @@ public partial class EntryPointTests
271
271
  </ItemGroup>
272
272
  </Project>
273
273
  """),
274
- ("some-dir/project1/project.csproj",
275
- """
274
+ ("some-dir/project1/project.csproj", """
276
275
  <Project Sdk="Microsoft.NET.Sdk">
277
276
  <PropertyGroup>
278
277
  <OutputType>Exe</OutputType>
@@ -300,7 +299,7 @@ public partial class EntryPointTests
300
299
  """),
301
300
  ("other-dir/Directory.Build.props", """
302
301
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
303
-
302
+
304
303
  <ItemGroup>
305
304
  <PackageReference Include="Some.Package" Version="6.1.0" />
306
305
  </ItemGroup>
@@ -0,0 +1,11 @@
1
+ using System.Collections.Immutable;
2
+
3
+ namespace NuGetUpdater.Core.Analyze;
4
+
5
+ public record AnalysisResult
6
+ {
7
+ public required string UpdatedVersion { get; init; }
8
+ public bool CanUpdate { get; init; }
9
+ public bool VersionComesFromMultiDependencyProperty { get; init; }
10
+ public required ImmutableArray<Dependency> UpdatedDependencies { get; init; }
11
+ }