dependabot-nuget 0.323.0 → 0.325.0
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.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +0 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +1 -31
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyFinder.cs +0 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyInfo.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +64 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencySolver/MSBuildDependencySolver.cs +10 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +31 -41
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +3 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Cooldown.cs +83 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +2 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ModifiedFilesTracker.cs +9 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/DetailedPullRequestBodyGenerator.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +8 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +79 -67
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/FileWriterWorker.cs +10 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/XmlFileWriter.cs +245 -125
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +4 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +4 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +14 -31
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +3 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +12 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/XmlExtensions.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +78 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/VersionFinderTests.cs +126 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/CloneWorkerTests.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolver/MSBuildDependencySolverTests.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +0 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +2 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/ApiModel/CooldownTests.cs +99 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +168 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestBodyGenerator/DetailedPullRequestBodyGeneratorTests.cs +71 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +71 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/GroupUpdateAllVersionsHandlerTests.cs +70 -39
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests.cs +43 -30
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests.cs +76 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackageReferenceUpdaterTests.cs +0 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +11 -27
- data/lib/dependabot/nuget.rb +3 -11
- metadata +8 -54
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +0 -49
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +0 -60
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +0 -35
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +0 -58
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +0 -380
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +0 -557
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.FrameworkCheck.cs +0 -37
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +0 -226
- data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +0 -65
- data/lib/dependabot/nuget/analysis/dependency_analysis.rb +0 -66
- data/lib/dependabot/nuget/cache_manager.rb +0 -29
- data/lib/dependabot/nuget/discovery/dependency_details.rb +0 -102
- data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +0 -122
- data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +0 -266
- data/lib/dependabot/nuget/discovery/evaluation_details.rb +0 -63
- data/lib/dependabot/nuget/discovery/project_discovery.rb +0 -104
- data/lib/dependabot/nuget/discovery/property_details.rb +0 -43
- data/lib/dependabot/nuget/discovery/workspace_discovery.rb +0 -61
- data/lib/dependabot/nuget/file_fetcher.rb +0 -46
- data/lib/dependabot/nuget/file_parser.rb +0 -153
- data/lib/dependabot/nuget/file_updater.rb +0 -256
- data/lib/dependabot/nuget/language.rb +0 -98
- data/lib/dependabot/nuget/metadata_finder.rb +0 -197
- data/lib/dependabot/nuget/native_helpers.rb +0 -364
- data/lib/dependabot/nuget/nuget_config_credential_helpers.rb +0 -88
- data/lib/dependabot/nuget/package_manager.rb +0 -51
- data/lib/dependabot/nuget/update_checker/requirements_updater.rb +0 -105
- data/lib/dependabot/nuget/update_checker.rb +0 -210
@@ -1,58 +0,0 @@
|
|
1
|
-
using System.CommandLine;
|
2
|
-
|
3
|
-
using NuGetUpdater.Core;
|
4
|
-
|
5
|
-
namespace NuGetUpdater.Cli.Commands;
|
6
|
-
|
7
|
-
internal static class UpdateCommand
|
8
|
-
{
|
9
|
-
internal static readonly Option<string> JobIdOption = new("--job-id") { Required = true };
|
10
|
-
internal static readonly Option<FileInfo> JobPathOption = new("--job-path") { Required = true };
|
11
|
-
internal static readonly Option<DirectoryInfo> RepoRootOption = new("--repo-root") { DefaultValueFactory = _ => new DirectoryInfo(Environment.CurrentDirectory), Required = false };
|
12
|
-
internal static readonly Option<FileInfo> SolutionOrProjectFileOption = new("--solution-or-project") { Required = true };
|
13
|
-
internal static readonly Option<string> DependencyNameOption = new("--dependency") { Required = true };
|
14
|
-
internal static readonly Option<string> NewVersionOption = new("--new-version") { Required = true };
|
15
|
-
internal static readonly Option<string> PreviousVersionOption = new("--previous-version") { Required = true };
|
16
|
-
internal static readonly Option<bool> IsTransitiveOption = new("--transitive") { DefaultValueFactory = _ => false };
|
17
|
-
internal static readonly Option<string?> ResultOutputPathOption = new("--result-output-path") { DefaultValueFactory = _ => null };
|
18
|
-
|
19
|
-
internal static Command GetCommand(Action<int> setExitCode)
|
20
|
-
{
|
21
|
-
Command command = new("update", "Applies the changes from an analysis report to update a dependency.")
|
22
|
-
{
|
23
|
-
JobIdOption,
|
24
|
-
JobPathOption,
|
25
|
-
RepoRootOption,
|
26
|
-
SolutionOrProjectFileOption,
|
27
|
-
DependencyNameOption,
|
28
|
-
NewVersionOption,
|
29
|
-
PreviousVersionOption,
|
30
|
-
IsTransitiveOption,
|
31
|
-
ResultOutputPathOption
|
32
|
-
};
|
33
|
-
|
34
|
-
command.TreatUnmatchedTokensAsErrors = true;
|
35
|
-
command.SetAction(async (parseResult, cancellationToken) =>
|
36
|
-
{
|
37
|
-
// since we have more than 8 arguments, we have to pull them out manually
|
38
|
-
var jobId = parseResult.GetValue(JobIdOption)!;
|
39
|
-
var jobPath = parseResult.GetValue(JobPathOption)!;
|
40
|
-
var repoRoot = parseResult.GetValue(RepoRootOption)!;
|
41
|
-
var solutionOrProjectFile = parseResult.GetValue(SolutionOrProjectFileOption)!;
|
42
|
-
var dependencyName = parseResult.GetValue(DependencyNameOption)!;
|
43
|
-
var newVersion = parseResult.GetValue(NewVersionOption)!;
|
44
|
-
var previousVersion = parseResult.GetValue(PreviousVersionOption)!;
|
45
|
-
var isTransitive = parseResult.GetValue(IsTransitiveOption);
|
46
|
-
var resultOutputPath = parseResult.GetValue(ResultOutputPathOption);
|
47
|
-
|
48
|
-
var (experimentsManager, _error) = await ExperimentsManager.FromJobFileAsync(jobId, jobPath.FullName);
|
49
|
-
var logger = new OpenTelemetryLogger();
|
50
|
-
var worker = new UpdaterWorker(jobId, experimentsManager, logger);
|
51
|
-
await worker.RunAsync(repoRoot.FullName, solutionOrProjectFile.FullName, dependencyName, previousVersion, newVersion, isTransitive, resultOutputPath);
|
52
|
-
setExitCode(0);
|
53
|
-
return 0;
|
54
|
-
});
|
55
|
-
|
56
|
-
return command;
|
57
|
-
}
|
58
|
-
}
|
@@ -1,380 +0,0 @@
|
|
1
|
-
using System.Text;
|
2
|
-
using System.Text.Json;
|
3
|
-
using System.Xml.Linq;
|
4
|
-
|
5
|
-
using NuGetUpdater.Core;
|
6
|
-
using NuGetUpdater.Core.Analyze;
|
7
|
-
using NuGetUpdater.Core.Discover;
|
8
|
-
using NuGetUpdater.Core.Test;
|
9
|
-
using NuGetUpdater.Core.Test.Analyze;
|
10
|
-
using NuGetUpdater.Core.Test.Update;
|
11
|
-
|
12
|
-
using Xunit;
|
13
|
-
|
14
|
-
namespace NuGetUpdater.Cli.Test;
|
15
|
-
|
16
|
-
using TestFile = (string Path, string Content);
|
17
|
-
|
18
|
-
public partial class EntryPointTests
|
19
|
-
{
|
20
|
-
public class Analyze : AnalyzeWorkerTestBase
|
21
|
-
{
|
22
|
-
[Fact]
|
23
|
-
public async Task FindsUpdatedPackageAndReturnsTheCorrectData()
|
24
|
-
{
|
25
|
-
var repositoryXml = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some.package" />""");
|
26
|
-
await RunAsync(path =>
|
27
|
-
[
|
28
|
-
"analyze",
|
29
|
-
"--job-id",
|
30
|
-
"TEST-JOB-ID",
|
31
|
-
"--job-path",
|
32
|
-
Path.Combine(path, "job.json"),
|
33
|
-
"--repo-root",
|
34
|
-
path,
|
35
|
-
"--discovery-file-path",
|
36
|
-
Path.Join(path, "discovery.json"),
|
37
|
-
"--dependency-file-path",
|
38
|
-
Path.Join(path, "Some.Package.json"),
|
39
|
-
"--analysis-folder-path",
|
40
|
-
Path.Join(path, AnalyzeWorker.AnalysisDirectoryName),
|
41
|
-
],
|
42
|
-
packages: [
|
43
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", additionalMetadata: [repositoryXml]),
|
44
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.1", "net8.0", additionalMetadata: [repositoryXml]),
|
45
|
-
],
|
46
|
-
dependencyName: "Some.Package",
|
47
|
-
initialFiles:
|
48
|
-
[
|
49
|
-
("discovery.json", """
|
50
|
-
{
|
51
|
-
"Path": "",
|
52
|
-
"IsSuccess": true,
|
53
|
-
"Projects": [
|
54
|
-
{
|
55
|
-
"FilePath": "project.csproj",
|
56
|
-
"Dependencies": [
|
57
|
-
{
|
58
|
-
"Name": "Microsoft.NET.Sdk",
|
59
|
-
"Version": null,
|
60
|
-
"Type": "MSBuildSdk",
|
61
|
-
"EvaluationResult": null,
|
62
|
-
"TargetFrameworks": null,
|
63
|
-
"IsDevDependency": false,
|
64
|
-
"IsDirect": false,
|
65
|
-
"IsTransitive": false,
|
66
|
-
"IsOverride": false,
|
67
|
-
"IsUpdate": false
|
68
|
-
},
|
69
|
-
{
|
70
|
-
"Name": "Some.Package",
|
71
|
-
"Version": "1.0.0",
|
72
|
-
"Type": "PackageReference",
|
73
|
-
"EvaluationResult": {
|
74
|
-
"ResultType": "Success",
|
75
|
-
"OriginalValue": "1.0.0",
|
76
|
-
"EvaluatedValue": "1.0.0",
|
77
|
-
"RootPropertyName": null,
|
78
|
-
"ErrorMessage": null
|
79
|
-
},
|
80
|
-
"TargetFrameworks": [
|
81
|
-
"net8.0"
|
82
|
-
],
|
83
|
-
"IsDevDependency": false,
|
84
|
-
"IsDirect": true,
|
85
|
-
"IsTransitive": false,
|
86
|
-
"IsOverride": false,
|
87
|
-
"IsUpdate": false
|
88
|
-
}
|
89
|
-
],
|
90
|
-
"IsSuccess": true,
|
91
|
-
"Properties": [
|
92
|
-
{
|
93
|
-
"Name": "TargetFramework",
|
94
|
-
"Value": "net8.0",
|
95
|
-
"SourceFilePath": "project.csproj"
|
96
|
-
}
|
97
|
-
],
|
98
|
-
"TargetFrameworks": [
|
99
|
-
"net8.0"
|
100
|
-
],
|
101
|
-
"ReferencedProjectPaths": [],
|
102
|
-
"ImportedFiles": [],
|
103
|
-
"AdditionalFiles": []
|
104
|
-
}
|
105
|
-
],
|
106
|
-
"DirectoryPackagesProps": null,
|
107
|
-
"GlobalJson": null,
|
108
|
-
"DotNetToolsJson": null
|
109
|
-
}
|
110
|
-
"""),
|
111
|
-
("Some.Package.json", """
|
112
|
-
{
|
113
|
-
"Name": "Some.Package",
|
114
|
-
"Version": "1.0.0",
|
115
|
-
"IsVulnerable": false,
|
116
|
-
"IgnoredVersions": [],
|
117
|
-
"Vulnerabilities": []
|
118
|
-
}
|
119
|
-
"""),
|
120
|
-
("project.csproj", """
|
121
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
122
|
-
<PropertyGroup>
|
123
|
-
<TargetFramework>net8.0</TargetFramework>
|
124
|
-
</PropertyGroup>
|
125
|
-
<ItemGroup>
|
126
|
-
<PackageReference Include="Some.Package" Version="1.0.0" />
|
127
|
-
</ItemGroup>
|
128
|
-
</Project>
|
129
|
-
"""),
|
130
|
-
],
|
131
|
-
expectedResult: new()
|
132
|
-
{
|
133
|
-
UpdatedVersion = "1.0.1",
|
134
|
-
CanUpdate = true,
|
135
|
-
VersionComesFromMultiDependencyProperty = false,
|
136
|
-
UpdatedDependencies =
|
137
|
-
[
|
138
|
-
new Dependency("Some.Package", "1.0.1", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true, InfoUrl: "https://nuget.example.com/some.package")
|
139
|
-
],
|
140
|
-
}
|
141
|
-
);
|
142
|
-
}
|
143
|
-
|
144
|
-
[Fact]
|
145
|
-
public async Task DotNetToolsJsonCanBeAnalyzed()
|
146
|
-
{
|
147
|
-
var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-global-tool" />""");
|
148
|
-
await RunAsync(path =>
|
149
|
-
[
|
150
|
-
"analyze",
|
151
|
-
"--job-id",
|
152
|
-
"TEST-JOB-ID",
|
153
|
-
"--job-path",
|
154
|
-
Path.Combine(path, "job.json"),
|
155
|
-
"--repo-root",
|
156
|
-
path,
|
157
|
-
"--discovery-file-path",
|
158
|
-
Path.Join(path, "discovery.json"),
|
159
|
-
"--dependency-file-path",
|
160
|
-
Path.Join(path, "some-global-tool.json"),
|
161
|
-
"--analysis-folder-path",
|
162
|
-
Path.Join(path, AnalyzeWorker.AnalysisDirectoryName),
|
163
|
-
],
|
164
|
-
packages:
|
165
|
-
[
|
166
|
-
MockNuGetPackage.CreateDotNetToolPackage("some-global-tool", "1.0.0", "net8.0", additionalMetadata: [repoMetadata]),
|
167
|
-
MockNuGetPackage.CreateDotNetToolPackage("some-global-tool", "1.1.0", "net8.0", additionalMetadata: [repoMetadata]),
|
168
|
-
],
|
169
|
-
dependencyName: "some-global-tool",
|
170
|
-
initialFiles:
|
171
|
-
[
|
172
|
-
(".config/dotnet-tools.json", """
|
173
|
-
{
|
174
|
-
"version": 1,
|
175
|
-
"isRoot": true,
|
176
|
-
"tools": {
|
177
|
-
"some-global-tool": {
|
178
|
-
"version": "1.0.0",
|
179
|
-
"commands": [
|
180
|
-
"some-global-tool"
|
181
|
-
]
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}
|
185
|
-
"""),
|
186
|
-
("discovery.json", """
|
187
|
-
{
|
188
|
-
"Path": "",
|
189
|
-
"IsSuccess": true,
|
190
|
-
"Projects": [],
|
191
|
-
"DotNetToolsJson": {
|
192
|
-
"FilePath": ".config/dotnet-tools.json",
|
193
|
-
"IsSuccess": true,
|
194
|
-
"Dependencies": [
|
195
|
-
{
|
196
|
-
"Name": "some-global-tool",
|
197
|
-
"Version": "1.0.0",
|
198
|
-
"Type": "DotNetTool",
|
199
|
-
"EvaluationResult": null,
|
200
|
-
"TargetFrameworks": null,
|
201
|
-
"IsDevDependency": false,
|
202
|
-
"IsDirect": false,
|
203
|
-
"IsTransitive": false,
|
204
|
-
"IsOverride": false,
|
205
|
-
"IsUpdate": false,
|
206
|
-
"InfoUrl": null
|
207
|
-
}
|
208
|
-
]
|
209
|
-
}
|
210
|
-
}
|
211
|
-
"""),
|
212
|
-
("some-global-tool.json", """
|
213
|
-
{
|
214
|
-
"Name": "some-global-tool",
|
215
|
-
"Version": "1.0.0",
|
216
|
-
"IsVulnerable": false,
|
217
|
-
"IgnoredVersions": [],
|
218
|
-
"Vulnerabilities": []
|
219
|
-
}
|
220
|
-
"""),
|
221
|
-
],
|
222
|
-
expectedResult: new()
|
223
|
-
{
|
224
|
-
UpdatedVersion = "1.1.0",
|
225
|
-
CanUpdate = true,
|
226
|
-
VersionComesFromMultiDependencyProperty = false,
|
227
|
-
UpdatedDependencies =
|
228
|
-
[
|
229
|
-
new Dependency("some-global-tool", "1.1.0", DependencyType.DotNetTool, TargetFrameworks: null, IsDirect: true, InfoUrl: "https://nuget.example.com/some-global-tool")
|
230
|
-
],
|
231
|
-
}
|
232
|
-
);
|
233
|
-
}
|
234
|
-
|
235
|
-
[Fact]
|
236
|
-
public async Task GlobalJsonCanBeAnalyzed()
|
237
|
-
{
|
238
|
-
var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some.msbuild.sdk" />""");
|
239
|
-
await RunAsync(path =>
|
240
|
-
[
|
241
|
-
"analyze",
|
242
|
-
"--job-id",
|
243
|
-
"TEST-JOB-ID",
|
244
|
-
"--job-path",
|
245
|
-
Path.Combine(path, "job.json"),
|
246
|
-
"--repo-root",
|
247
|
-
path,
|
248
|
-
"--discovery-file-path",
|
249
|
-
Path.Join(path, "discovery.json"),
|
250
|
-
"--dependency-file-path",
|
251
|
-
Path.Join(path, "Some.MSBuild.Sdk.json"),
|
252
|
-
"--analysis-folder-path",
|
253
|
-
Path.Join(path, AnalyzeWorker.AnalysisDirectoryName),
|
254
|
-
],
|
255
|
-
packages:
|
256
|
-
[
|
257
|
-
MockNuGetPackage.CreateMSBuildSdkPackage("Some.MSBuild.Sdk", "1.0.0", "net8.0", additionalMetadata: [repoMetadata]),
|
258
|
-
MockNuGetPackage.CreateMSBuildSdkPackage("Some.MSBuild.Sdk", "1.1.0", "net8.0", additionalMetadata: [repoMetadata]),
|
259
|
-
],
|
260
|
-
dependencyName: "Some.MSBuild.Sdk",
|
261
|
-
initialFiles:
|
262
|
-
[
|
263
|
-
("global.json", """
|
264
|
-
{
|
265
|
-
"sdk": {
|
266
|
-
"version": "8.0.300",
|
267
|
-
"rollForward": "latestPatch"
|
268
|
-
},
|
269
|
-
"msbuild-sdks": {
|
270
|
-
"Some.MSBuild.Sdk": "1.0.0"
|
271
|
-
}
|
272
|
-
}
|
273
|
-
"""),
|
274
|
-
("discovery.json", """
|
275
|
-
{
|
276
|
-
"Path": "",
|
277
|
-
"IsSuccess": true,
|
278
|
-
"Projects": [],
|
279
|
-
"GlobalJson": {
|
280
|
-
"FilePath": "global.json",
|
281
|
-
"IsSuccess": true,
|
282
|
-
"Dependencies": [
|
283
|
-
{
|
284
|
-
"Name": "Some.MSBuild.Sdk",
|
285
|
-
"Version": "1.0.0",
|
286
|
-
"Type": "MSBuildSdk",
|
287
|
-
"EvaluationResult": null,
|
288
|
-
"TargetFrameworks": null,
|
289
|
-
"IsDevDependency": false,
|
290
|
-
"IsDirect": false,
|
291
|
-
"IsTransitive": false,
|
292
|
-
"IsOverride": false,
|
293
|
-
"IsUpdate": false,
|
294
|
-
"InfoUrl": null
|
295
|
-
}
|
296
|
-
]
|
297
|
-
}
|
298
|
-
}
|
299
|
-
"""),
|
300
|
-
("Some.MSBuild.Sdk.json", """
|
301
|
-
{
|
302
|
-
"Name": "Some.MSBuild.Sdk",
|
303
|
-
"Version": "1.0.0",
|
304
|
-
"IsVulnerable": false,
|
305
|
-
"IgnoredVersions": [],
|
306
|
-
"Vulnerabilities": []
|
307
|
-
}
|
308
|
-
"""),
|
309
|
-
],
|
310
|
-
expectedResult: new()
|
311
|
-
{
|
312
|
-
UpdatedVersion = "1.1.0",
|
313
|
-
CanUpdate = true,
|
314
|
-
VersionComesFromMultiDependencyProperty = false,
|
315
|
-
UpdatedDependencies =
|
316
|
-
[
|
317
|
-
new Dependency("Some.MSBuild.Sdk", "1.1.0", DependencyType.MSBuildSdk, TargetFrameworks: null, IsDirect: true, InfoUrl: "https://nuget.example.com/some.msbuild.sdk")
|
318
|
-
],
|
319
|
-
}
|
320
|
-
);
|
321
|
-
}
|
322
|
-
|
323
|
-
private static async Task RunAsync(
|
324
|
-
Func<string, string[]> getArgs,
|
325
|
-
string dependencyName,
|
326
|
-
TestFile[] initialFiles,
|
327
|
-
ExpectedAnalysisResult expectedResult,
|
328
|
-
MockNuGetPackage[]? packages = null,
|
329
|
-
ExperimentsManager? experimentsManager = null
|
330
|
-
)
|
331
|
-
{
|
332
|
-
experimentsManager ??= new ExperimentsManager();
|
333
|
-
var actualResult = await RunAnalyzerAsync(dependencyName, initialFiles, async path =>
|
334
|
-
{
|
335
|
-
var sb = new StringBuilder();
|
336
|
-
var writer = new StringWriter(sb);
|
337
|
-
|
338
|
-
var originalOut = Console.Out;
|
339
|
-
var originalErr = Console.Error;
|
340
|
-
Console.SetOut(writer);
|
341
|
-
Console.SetError(writer);
|
342
|
-
|
343
|
-
try
|
344
|
-
{
|
345
|
-
await UpdateWorkerTestBase.MockJobFileInDirectory(path, experimentsManager);
|
346
|
-
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, path);
|
347
|
-
var args = getArgs(path);
|
348
|
-
|
349
|
-
// manually pull out the experiments manager for the validate step below
|
350
|
-
for (int i = 0; i < args.Length - 1; i++)
|
351
|
-
{
|
352
|
-
if (args[i] == "--job-path")
|
353
|
-
{
|
354
|
-
var experimentsResult = await ExperimentsManager.FromJobFileAsync("TEST-JOB-ID", args[i + 1]);
|
355
|
-
experimentsManager = experimentsResult.ExperimentsManager;
|
356
|
-
}
|
357
|
-
}
|
358
|
-
|
359
|
-
var result = await Program.Main(args);
|
360
|
-
if (result != 0)
|
361
|
-
{
|
362
|
-
throw new Exception($"Program exited with code {result}.\nOutput:\n\n{sb}");
|
363
|
-
}
|
364
|
-
}
|
365
|
-
finally
|
366
|
-
{
|
367
|
-
Console.SetOut(originalOut);
|
368
|
-
Console.SetError(originalErr);
|
369
|
-
}
|
370
|
-
|
371
|
-
var resultPath = Path.Join(path, AnalyzeWorker.AnalysisDirectoryName, $"{dependencyName}.json");
|
372
|
-
var resultJson = await File.ReadAllTextAsync(resultPath);
|
373
|
-
var resultObject = JsonSerializer.Deserialize<AnalysisResult>(resultJson, DiscoveryWorker.SerializerOptions);
|
374
|
-
return resultObject!;
|
375
|
-
});
|
376
|
-
|
377
|
-
ValidateAnalysisResult(expectedResult, actualResult);
|
378
|
-
}
|
379
|
-
}
|
380
|
-
}
|