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,557 +0,0 @@
|
|
1
|
-
using System.Text;
|
2
|
-
using System.Text.Json;
|
3
|
-
using System.Text.Json.Serialization;
|
4
|
-
|
5
|
-
using NuGetUpdater.Core;
|
6
|
-
using NuGetUpdater.Core.Discover;
|
7
|
-
using NuGetUpdater.Core.Test;
|
8
|
-
using NuGetUpdater.Core.Test.Discover;
|
9
|
-
using NuGetUpdater.Core.Test.Update;
|
10
|
-
|
11
|
-
using Xunit;
|
12
|
-
|
13
|
-
namespace NuGetUpdater.Cli.Test;
|
14
|
-
|
15
|
-
using TestFile = (string Path, string Content);
|
16
|
-
|
17
|
-
public partial class EntryPointTests
|
18
|
-
{
|
19
|
-
public class Discover : DiscoveryWorkerTestBase
|
20
|
-
{
|
21
|
-
[Fact]
|
22
|
-
public async Task PathWithSpaces()
|
23
|
-
{
|
24
|
-
await RunAsync(path =>
|
25
|
-
[
|
26
|
-
"discover",
|
27
|
-
"--job-id",
|
28
|
-
"TEST-JOB-ID",
|
29
|
-
"--job-path",
|
30
|
-
Path.Combine(path, "job.json"),
|
31
|
-
"--repo-root",
|
32
|
-
path,
|
33
|
-
"--workspace",
|
34
|
-
"path/to/some directory with spaces",
|
35
|
-
"--output",
|
36
|
-
Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName),
|
37
|
-
],
|
38
|
-
packages:
|
39
|
-
[
|
40
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.2.3", "net8.0"),
|
41
|
-
],
|
42
|
-
initialFiles:
|
43
|
-
[
|
44
|
-
("path/to/some directory with spaces/project.csproj", """
|
45
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
46
|
-
<PropertyGroup>
|
47
|
-
<TargetFramework>net8.0</TargetFramework>
|
48
|
-
</PropertyGroup>
|
49
|
-
<ItemGroup>
|
50
|
-
<PackageReference Include="Some.Package" Version="1.2.3" />
|
51
|
-
</ItemGroup>
|
52
|
-
</Project>
|
53
|
-
""")
|
54
|
-
],
|
55
|
-
expectedResult: new()
|
56
|
-
{
|
57
|
-
Path = "path/to/some directory with spaces",
|
58
|
-
Projects = [
|
59
|
-
new()
|
60
|
-
{
|
61
|
-
FilePath = "project.csproj",
|
62
|
-
TargetFrameworks = ["net8.0"],
|
63
|
-
Dependencies = [
|
64
|
-
new("Some.Package", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true),
|
65
|
-
],
|
66
|
-
Properties = [
|
67
|
-
new("TargetFramework", "net8.0", "path/to/some directory with spaces/project.csproj"),
|
68
|
-
],
|
69
|
-
ReferencedProjectPaths = [],
|
70
|
-
ImportedFiles = [],
|
71
|
-
AdditionalFiles = [],
|
72
|
-
}
|
73
|
-
]
|
74
|
-
}
|
75
|
-
);
|
76
|
-
}
|
77
|
-
|
78
|
-
[Fact]
|
79
|
-
public async Task WithSolution()
|
80
|
-
{
|
81
|
-
await RunAsync(path =>
|
82
|
-
[
|
83
|
-
"discover",
|
84
|
-
"--job-id",
|
85
|
-
"TEST-JOB-ID",
|
86
|
-
"--job-path",
|
87
|
-
Path.Combine(path, "job.json"),
|
88
|
-
"--repo-root",
|
89
|
-
path,
|
90
|
-
"--workspace",
|
91
|
-
"/",
|
92
|
-
"--output",
|
93
|
-
Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName),
|
94
|
-
],
|
95
|
-
packages:
|
96
|
-
[
|
97
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net45"),
|
98
|
-
],
|
99
|
-
initialFiles:
|
100
|
-
new[]
|
101
|
-
{
|
102
|
-
("solution.sln", """
|
103
|
-
Microsoft Visual Studio Solution File, Format Version 12.00
|
104
|
-
# Visual Studio 14
|
105
|
-
VisualStudioVersion = 14.0.22705.0
|
106
|
-
MinimumVisualStudioVersion = 10.0.40219.1
|
107
|
-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "my", "path/to/my.csproj", "{782E0C0A-10D3-444D-9640-263D03D2B20C}"
|
108
|
-
EndProject
|
109
|
-
Global
|
110
|
-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
111
|
-
Debug|Any CPU = Debug|Any CPU
|
112
|
-
Release|Any CPU = Release|Any CPU
|
113
|
-
EndGlobalSection
|
114
|
-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
115
|
-
{782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
116
|
-
{782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
117
|
-
{782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
118
|
-
{782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.Build.0 = Release|Any CPU
|
119
|
-
EndGlobalSection
|
120
|
-
GlobalSection(SolutionProperties) = preSolution
|
121
|
-
HideSolutionNode = FALSE
|
122
|
-
EndGlobalSection
|
123
|
-
EndGlobal
|
124
|
-
"""),
|
125
|
-
("path/to/my.csproj", """
|
126
|
-
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
127
|
-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
128
|
-
<PropertyGroup>
|
129
|
-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
130
|
-
</PropertyGroup>
|
131
|
-
<ItemGroup>
|
132
|
-
<None Include="packages.config" />
|
133
|
-
</ItemGroup>
|
134
|
-
<ItemGroup>
|
135
|
-
<Reference Include="Some.Package">
|
136
|
-
<HintPath>packages\Some.Package.7.0.1\lib\net45\Some.Package.dll</HintPath>
|
137
|
-
<Private>True</Private>
|
138
|
-
</Reference>
|
139
|
-
</ItemGroup>
|
140
|
-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
141
|
-
</Project>
|
142
|
-
"""),
|
143
|
-
("path/to/packages.config", """
|
144
|
-
<packages>
|
145
|
-
<package id="Some.Package" version="7.0.1" targetFramework="net45" />
|
146
|
-
</packages>
|
147
|
-
""")
|
148
|
-
},
|
149
|
-
expectedResult: new()
|
150
|
-
{
|
151
|
-
Path = "",
|
152
|
-
Projects = [
|
153
|
-
new()
|
154
|
-
{
|
155
|
-
FilePath = "path/to/my.csproj",
|
156
|
-
TargetFrameworks = ["net45"],
|
157
|
-
Dependencies = [
|
158
|
-
new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"]),
|
159
|
-
],
|
160
|
-
Properties = [],
|
161
|
-
ReferencedProjectPaths = [],
|
162
|
-
ImportedFiles = [],
|
163
|
-
AdditionalFiles = [
|
164
|
-
"packages.config"
|
165
|
-
],
|
166
|
-
}
|
167
|
-
]
|
168
|
-
}
|
169
|
-
);
|
170
|
-
}
|
171
|
-
|
172
|
-
[Fact]
|
173
|
-
public async Task WithProject()
|
174
|
-
{
|
175
|
-
await RunAsync(path =>
|
176
|
-
[
|
177
|
-
"discover",
|
178
|
-
"--job-id",
|
179
|
-
"TEST-JOB-ID",
|
180
|
-
"--job-path",
|
181
|
-
Path.Combine(path, "job.json"),
|
182
|
-
"--repo-root",
|
183
|
-
path,
|
184
|
-
"--workspace",
|
185
|
-
"path/to",
|
186
|
-
"--output",
|
187
|
-
Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName),
|
188
|
-
],
|
189
|
-
packages:
|
190
|
-
[
|
191
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net45"),
|
192
|
-
],
|
193
|
-
initialFiles:
|
194
|
-
new[]
|
195
|
-
{
|
196
|
-
("path/to/my.csproj", """
|
197
|
-
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
198
|
-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
199
|
-
<PropertyGroup>
|
200
|
-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
201
|
-
</PropertyGroup>
|
202
|
-
<ItemGroup>
|
203
|
-
<None Include="packages.config" />
|
204
|
-
</ItemGroup>
|
205
|
-
<ItemGroup>
|
206
|
-
<Reference Include="Some.Package">
|
207
|
-
<HintPath>packages\Some.Package.7.0.1\lib\net45\Some.Package.dll</HintPath>
|
208
|
-
<Private>True</Private>
|
209
|
-
</Reference>
|
210
|
-
</ItemGroup>
|
211
|
-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
212
|
-
</Project>
|
213
|
-
"""),
|
214
|
-
("path/to/packages.config", """
|
215
|
-
<packages>
|
216
|
-
<package id="Some.Package" version="7.0.1" targetFramework="net45" />
|
217
|
-
</packages>
|
218
|
-
""")
|
219
|
-
},
|
220
|
-
expectedResult: new()
|
221
|
-
{
|
222
|
-
Path = "path/to",
|
223
|
-
Projects = [
|
224
|
-
new()
|
225
|
-
{
|
226
|
-
FilePath = "my.csproj",
|
227
|
-
TargetFrameworks = ["net45"],
|
228
|
-
Dependencies = [
|
229
|
-
new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
|
230
|
-
],
|
231
|
-
Properties = [],
|
232
|
-
ReferencedProjectPaths = [],
|
233
|
-
ImportedFiles = [],
|
234
|
-
AdditionalFiles = [
|
235
|
-
"packages.config"
|
236
|
-
],
|
237
|
-
}
|
238
|
-
]
|
239
|
-
}
|
240
|
-
);
|
241
|
-
}
|
242
|
-
|
243
|
-
[Fact]
|
244
|
-
public async Task WithDirectory()
|
245
|
-
{
|
246
|
-
var workspacePath = "path/to/";
|
247
|
-
await RunAsync(path =>
|
248
|
-
[
|
249
|
-
"discover",
|
250
|
-
"--job-id",
|
251
|
-
"TEST-JOB-ID",
|
252
|
-
"--job-path",
|
253
|
-
Path.Combine(path, "job.json"),
|
254
|
-
"--repo-root",
|
255
|
-
path,
|
256
|
-
"--workspace",
|
257
|
-
workspacePath,
|
258
|
-
"--output",
|
259
|
-
Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName),
|
260
|
-
],
|
261
|
-
packages:
|
262
|
-
[
|
263
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net45"),
|
264
|
-
],
|
265
|
-
initialFiles:
|
266
|
-
new[]
|
267
|
-
{
|
268
|
-
("path/to/my.csproj", """
|
269
|
-
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
270
|
-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
271
|
-
<PropertyGroup>
|
272
|
-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
273
|
-
</PropertyGroup>
|
274
|
-
<ItemGroup>
|
275
|
-
<None Include="packages.config" />
|
276
|
-
</ItemGroup>
|
277
|
-
<ItemGroup>
|
278
|
-
<Reference Include="Some.Package">
|
279
|
-
<HintPath>packages\Some.Package.7.0.1\lib\net45\Some.Package.dll</HintPath>
|
280
|
-
<Private>True</Private>
|
281
|
-
</Reference>
|
282
|
-
</ItemGroup>
|
283
|
-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
284
|
-
</Project>
|
285
|
-
"""),
|
286
|
-
("path/to/packages.config", """
|
287
|
-
<packages>
|
288
|
-
<package id="Some.Package" version="7.0.1" targetFramework="net45" />
|
289
|
-
</packages>
|
290
|
-
""")
|
291
|
-
},
|
292
|
-
expectedResult: new()
|
293
|
-
{
|
294
|
-
Path = workspacePath,
|
295
|
-
Projects = [
|
296
|
-
new()
|
297
|
-
{
|
298
|
-
FilePath = "my.csproj",
|
299
|
-
TargetFrameworks = ["net45"],
|
300
|
-
Dependencies = [
|
301
|
-
new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
|
302
|
-
],
|
303
|
-
Properties = [],
|
304
|
-
ReferencedProjectPaths = [],
|
305
|
-
ImportedFiles = [],
|
306
|
-
AdditionalFiles = [
|
307
|
-
"packages.config"
|
308
|
-
],
|
309
|
-
}
|
310
|
-
]
|
311
|
-
}
|
312
|
-
);
|
313
|
-
}
|
314
|
-
|
315
|
-
[Fact]
|
316
|
-
public async Task WithDuplicateDependenciesOfDifferentTypes()
|
317
|
-
{
|
318
|
-
await RunAsync(path =>
|
319
|
-
[
|
320
|
-
"discover",
|
321
|
-
"--job-id",
|
322
|
-
"TEST-JOB-ID",
|
323
|
-
"--job-path",
|
324
|
-
Path.Combine(path, "job.json"),
|
325
|
-
"--repo-root",
|
326
|
-
path,
|
327
|
-
"--workspace",
|
328
|
-
"path/to",
|
329
|
-
"--output",
|
330
|
-
Path.Combine(path, DiscoveryWorker.DiscoveryResultFileName)
|
331
|
-
],
|
332
|
-
new[]
|
333
|
-
{
|
334
|
-
("path/to/my.csproj", """
|
335
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
336
|
-
<PropertyGroup>
|
337
|
-
<TargetFramework>net8.0</TargetFramework>
|
338
|
-
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
339
|
-
</PropertyGroup>
|
340
|
-
<ItemGroup>
|
341
|
-
<PackageReference Include="Package.A" Version="1.2.3" />
|
342
|
-
</ItemGroup>
|
343
|
-
</Project>
|
344
|
-
"""),
|
345
|
-
("path/Directory.Build.props", """
|
346
|
-
<Project>
|
347
|
-
<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
|
348
|
-
<PackageReference Include="Package.B" Version="4.5.6" />
|
349
|
-
</ItemGroup>
|
350
|
-
<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
|
351
|
-
<GlobalPackageReference Include="Package.B" Version="7.8.9" />
|
352
|
-
</ItemGroup>
|
353
|
-
</Project>
|
354
|
-
""")
|
355
|
-
},
|
356
|
-
packages:
|
357
|
-
[
|
358
|
-
MockNuGetPackage.CreateSimplePackage("Package.A", "1.2.3", "net8.0"),
|
359
|
-
MockNuGetPackage.CreateSimplePackage("Package.B", "4.5.6", "net8.0"),
|
360
|
-
],
|
361
|
-
expectedResult: new()
|
362
|
-
{
|
363
|
-
Path = "path/to",
|
364
|
-
Projects = [
|
365
|
-
new()
|
366
|
-
{
|
367
|
-
FilePath = "my.csproj",
|
368
|
-
TargetFrameworks = ["net8.0"],
|
369
|
-
ExpectedDependencyCount = 2,
|
370
|
-
Dependencies = [
|
371
|
-
new("Package.A", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true),
|
372
|
-
new("Package.B", "4.5.6", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true),
|
373
|
-
],
|
374
|
-
Properties = [
|
375
|
-
new("ManagePackageVersionsCentrally", "false", "path/to/my.csproj"),
|
376
|
-
new("TargetFramework", "net8.0", "path/to/my.csproj"),
|
377
|
-
],
|
378
|
-
ReferencedProjectPaths = [],
|
379
|
-
ImportedFiles = [
|
380
|
-
"../Directory.Build.props"
|
381
|
-
],
|
382
|
-
AdditionalFiles = [],
|
383
|
-
}
|
384
|
-
],
|
385
|
-
}
|
386
|
-
);
|
387
|
-
}
|
388
|
-
|
389
|
-
[Fact]
|
390
|
-
public async Task JobFileParseErrorIsReported_InvalidJson()
|
391
|
-
{
|
392
|
-
using var testDirectory = new TemporaryDirectory();
|
393
|
-
var jobFilePath = Path.Combine(testDirectory.DirectoryPath, "job.json");
|
394
|
-
var resultFilePath = Path.Combine(testDirectory.DirectoryPath, DiscoveryWorker.DiscoveryResultFileName);
|
395
|
-
await File.WriteAllTextAsync(jobFilePath, "not json", TestContext.Current.CancellationToken);
|
396
|
-
await RunAsync(path =>
|
397
|
-
[
|
398
|
-
"discover",
|
399
|
-
"--job-id",
|
400
|
-
"TEST-JOB-ID",
|
401
|
-
"--job-path",
|
402
|
-
jobFilePath,
|
403
|
-
"--repo-root",
|
404
|
-
path,
|
405
|
-
"--workspace",
|
406
|
-
"/",
|
407
|
-
"--output",
|
408
|
-
resultFilePath
|
409
|
-
],
|
410
|
-
initialFiles: [],
|
411
|
-
expectedResult: new()
|
412
|
-
{
|
413
|
-
Path = "/",
|
414
|
-
Projects = [],
|
415
|
-
ErrorRegex = "Error deserializing job file contents",
|
416
|
-
}
|
417
|
-
);
|
418
|
-
}
|
419
|
-
|
420
|
-
[Fact]
|
421
|
-
public async Task JobFileParseErrorIsReported_BadRequirement()
|
422
|
-
{
|
423
|
-
using var testDirectory = new TemporaryDirectory();
|
424
|
-
var jobFilePath = Path.Combine(testDirectory.DirectoryPath, "job.json");
|
425
|
-
var resultFilePath = Path.Combine(testDirectory.DirectoryPath, DiscoveryWorker.DiscoveryResultFileName);
|
426
|
-
|
427
|
-
// write a job file with a valid shape, but invalid requirement
|
428
|
-
await File.WriteAllTextAsync(jobFilePath, """
|
429
|
-
{
|
430
|
-
"job": {
|
431
|
-
"source": {
|
432
|
-
"provider": "github",
|
433
|
-
"repo": "test/repo"
|
434
|
-
},
|
435
|
-
"security-advisories": [
|
436
|
-
{
|
437
|
-
"dependency-name": "Some.Dependency",
|
438
|
-
"affected-versions": ["not a valid requirement"]
|
439
|
-
}
|
440
|
-
]
|
441
|
-
}
|
442
|
-
}
|
443
|
-
""", TestContext.Current.CancellationToken);
|
444
|
-
await RunAsync(path =>
|
445
|
-
[
|
446
|
-
"discover",
|
447
|
-
"--job-id",
|
448
|
-
"TEST-JOB-ID",
|
449
|
-
"--job-path",
|
450
|
-
jobFilePath,
|
451
|
-
"--repo-root",
|
452
|
-
path,
|
453
|
-
"--workspace",
|
454
|
-
"/",
|
455
|
-
"--output",
|
456
|
-
resultFilePath
|
457
|
-
],
|
458
|
-
initialFiles: [],
|
459
|
-
expectedResult: new()
|
460
|
-
{
|
461
|
-
Path = "/",
|
462
|
-
Projects = [],
|
463
|
-
Error = new Core.Run.ApiModel.BadRequirement("not a valid requirement"),
|
464
|
-
}
|
465
|
-
);
|
466
|
-
}
|
467
|
-
|
468
|
-
private static async Task RunAsync(
|
469
|
-
Func<string, string[]> getArgs,
|
470
|
-
TestFile[] initialFiles,
|
471
|
-
ExpectedWorkspaceDiscoveryResult expectedResult,
|
472
|
-
MockNuGetPackage[]? packages = null,
|
473
|
-
ExperimentsManager? experimentsManager = null
|
474
|
-
)
|
475
|
-
{
|
476
|
-
experimentsManager ??= new ExperimentsManager();
|
477
|
-
var actualResult = await RunDiscoveryAsync(initialFiles, async path =>
|
478
|
-
{
|
479
|
-
var sb = new StringBuilder();
|
480
|
-
var writer = new StringWriter(sb);
|
481
|
-
|
482
|
-
var originalOut = Console.Out;
|
483
|
-
var originalErr = Console.Error;
|
484
|
-
Console.SetOut(writer);
|
485
|
-
Console.SetError(writer);
|
486
|
-
string? resultPath = null;
|
487
|
-
|
488
|
-
try
|
489
|
-
{
|
490
|
-
await UpdateWorkerTestBase.MockJobFileInDirectory(path, experimentsManager);
|
491
|
-
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, path);
|
492
|
-
var args = getArgs(path);
|
493
|
-
|
494
|
-
// manually pull out the experiments manager for the validate step below
|
495
|
-
for (int i = 0; i < args.Length - 1; i++)
|
496
|
-
{
|
497
|
-
switch (args[i])
|
498
|
-
{
|
499
|
-
case "--job-path":
|
500
|
-
var experimentsResult = await ExperimentsManager.FromJobFileAsync("TEST-JOB-ID", args[i + 1]);
|
501
|
-
experimentsManager = experimentsResult.ExperimentsManager;
|
502
|
-
break;
|
503
|
-
case "--output":
|
504
|
-
resultPath = args[i + 1];
|
505
|
-
break;
|
506
|
-
}
|
507
|
-
}
|
508
|
-
|
509
|
-
var result = await Program.Main(args);
|
510
|
-
if (result != 0)
|
511
|
-
{
|
512
|
-
throw new Exception($"Program exited with code {result}.\nOutput:\n\n{sb}");
|
513
|
-
}
|
514
|
-
}
|
515
|
-
finally
|
516
|
-
{
|
517
|
-
Console.SetOut(originalOut);
|
518
|
-
Console.SetError(originalErr);
|
519
|
-
}
|
520
|
-
|
521
|
-
resultPath ??= Path.Join(path, DiscoveryWorker.DiscoveryResultFileName);
|
522
|
-
var resultJson = await File.ReadAllTextAsync(resultPath);
|
523
|
-
var serializerOptions = new JsonSerializerOptions()
|
524
|
-
{
|
525
|
-
Converters = { new TestJobErrorBaseConverter() }
|
526
|
-
};
|
527
|
-
foreach (var converter in DiscoveryWorker.SerializerOptions.Converters)
|
528
|
-
{
|
529
|
-
serializerOptions.Converters.Add(converter);
|
530
|
-
}
|
531
|
-
var resultObject = JsonSerializer.Deserialize<WorkspaceDiscoveryResult>(resultJson, serializerOptions);
|
532
|
-
return resultObject!;
|
533
|
-
});
|
534
|
-
|
535
|
-
ValidateWorkspaceResult(expectedResult, actualResult, experimentsManager);
|
536
|
-
}
|
537
|
-
|
538
|
-
private class TestJobErrorBaseConverter : JsonConverter<Core.Run.ApiModel.JobErrorBase>
|
539
|
-
{
|
540
|
-
public override Core.Run.ApiModel.JobErrorBase? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
541
|
-
{
|
542
|
-
var dict = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(ref reader, options)!;
|
543
|
-
return dict["error-type"].GetString() switch
|
544
|
-
{
|
545
|
-
"illformed_requirement" => new Core.Run.ApiModel.BadRequirement(dict["error-details"].GetProperty("message").GetString()!),
|
546
|
-
"unknown_error" => new Core.Run.ApiModel.UnknownError(new Exception("Error deserializing job file contents"), "TEST-JOB-ID"),
|
547
|
-
_ => throw new NotImplementedException($"Unknown error type: {dict["error-type"]}"),
|
548
|
-
};
|
549
|
-
}
|
550
|
-
|
551
|
-
public override void Write(Utf8JsonWriter writer, Core.Run.ApiModel.JobErrorBase value, JsonSerializerOptions options)
|
552
|
-
{
|
553
|
-
throw new NotImplementedException();
|
554
|
-
}
|
555
|
-
}
|
556
|
-
}
|
557
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
using Xunit;
|
2
|
-
|
3
|
-
namespace NuGetUpdater.Cli.Test;
|
4
|
-
|
5
|
-
public partial class EntryPointTests
|
6
|
-
{
|
7
|
-
public class FrameworkCheck
|
8
|
-
{
|
9
|
-
[Theory]
|
10
|
-
[InlineData("net7.0", "net5.0")]
|
11
|
-
[InlineData("net7.0 net472", "net5.0 net461")]
|
12
|
-
[InlineData("net7.0 net472", "netstandard2.0")]
|
13
|
-
public Task Compatible(string projectTfms, string packageTfms)
|
14
|
-
=> Run(projectTfms, packageTfms, expectedExitCode: 0);
|
15
|
-
|
16
|
-
[Theory]
|
17
|
-
[InlineData("net5.0", "net7.0")]
|
18
|
-
[InlineData("net5.0 net461", "net7.0 net472")]
|
19
|
-
[InlineData("net5.0 net45", "netstandard2.0")]
|
20
|
-
public Task Incompatible(string projectTfms, string packageTfms)
|
21
|
-
=> Run(projectTfms, packageTfms, expectedExitCode: 1);
|
22
|
-
|
23
|
-
private static async Task Run(string projectTfms, string packageTfms, int expectedExitCode)
|
24
|
-
{
|
25
|
-
var args = new List<string>();
|
26
|
-
args.Add("framework-check");
|
27
|
-
args.Add("--project-tfms");
|
28
|
-
args.AddRange(projectTfms.Split(' ', StringSplitOptions.TrimEntries));
|
29
|
-
args.Add("--package-tfms");
|
30
|
-
args.AddRange(packageTfms.Split(' ', StringSplitOptions.TrimEntries));
|
31
|
-
|
32
|
-
var actual = await Program.Main(args.ToArray());
|
33
|
-
|
34
|
-
Assert.Equal(expectedExitCode, actual);
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|