dependabot-nuget 0.251.0 → 0.253.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/Directory.Common.props +1 -0
- data/helpers/lib/NuGetUpdater/Directory.Packages.props +26 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +35 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/NuGetUpdater.Cli.csproj +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +4 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +251 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +27 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Dependency.cs +56 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyType.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs +69 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscoveryResult.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +217 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +30 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscoveryResult.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +30 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscoveryResult.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/IDiscoveryResult.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +29 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +13 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +128 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +13 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResult.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResultType.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/BuildFile.cs +6 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs +4 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +24 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs +8 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs +100 -19
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/XmlBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj +6 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Property.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +23 -36
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +59 -26
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +5 -20
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/HashSetExtensions.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ImmutableArrayExtensions.cs +18 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +281 -140
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +27 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +18 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +135 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +91 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +71 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +67 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +405 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +306 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +36 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +2 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/PackagesConfigBuildFileTests.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs +6 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +4 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +38 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestBase.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +1 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +13 -41
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +30 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +272 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/DiffUtil.cs +266 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +239 -161
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs +7 -11
- data/lib/dependabot/nuget/discovery/dependency_details.rb +95 -0
- data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +126 -0
- data/lib/dependabot/nuget/discovery/directory_packages_props_discovery.rb +43 -0
- data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +83 -0
- data/lib/dependabot/nuget/discovery/evaluation_details.rb +63 -0
- data/lib/dependabot/nuget/discovery/project_discovery.rb +71 -0
- data/lib/dependabot/nuget/discovery/property_details.rb +43 -0
- data/lib/dependabot/nuget/discovery/workspace_discovery.rb +66 -0
- data/lib/dependabot/nuget/file_parser.rb +19 -128
- data/lib/dependabot/nuget/file_updater.rb +28 -60
- data/lib/dependabot/nuget/native_helpers.rb +55 -0
- data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +3 -8
- data/lib/dependabot/nuget/update_checker/dependency_finder.rb +1 -0
- data/lib/dependabot/nuget/update_checker/property_updater.rb +1 -0
- data/lib/dependabot/nuget/update_checker/tfm_finder.rb +17 -152
- data/lib/dependabot/nuget/update_checker/version_finder.rb +1 -6
- data/lib/dependabot/nuget/update_checker.rb +4 -1
- metadata +44 -25
- data/lib/dependabot/nuget/file_parser/dotnet_tools_json_parser.rb +0 -71
- data/lib/dependabot/nuget/file_parser/global_json_parser.rb +0 -68
- data/lib/dependabot/nuget/file_parser/packages_config_parser.rb +0 -92
- data/lib/dependabot/nuget/file_parser/project_file_parser.rb +0 -620
- data/lib/dependabot/nuget/file_parser/property_value_finder.rb +0 -225
- data/lib/dependabot/nuget/file_updater/property_value_updater.rb +0 -81
@@ -1,4 +1,4 @@
|
|
1
|
-
using System.
|
1
|
+
using System.Diagnostics.CodeAnalysis;
|
2
2
|
|
3
3
|
namespace NuGetUpdater.Core;
|
4
4
|
|
@@ -6,10 +6,33 @@ internal static class NuGetHelper
|
|
6
6
|
{
|
7
7
|
internal const string PackagesConfigFileName = "packages.config";
|
8
8
|
|
9
|
-
public static bool
|
9
|
+
public static bool TryGetPackagesConfigFile(string projectPath, [NotNullWhen(returnValue: true)] out string? packagesConfigPath)
|
10
10
|
{
|
11
11
|
var projectDirectory = Path.GetDirectoryName(projectPath);
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
packagesConfigPath = PathHelper.JoinPath(projectDirectory, PackagesConfigFileName);
|
14
|
+
if (File.Exists(packagesConfigPath))
|
15
|
+
{
|
16
|
+
return true;
|
17
|
+
}
|
18
|
+
|
19
|
+
packagesConfigPath = null;
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
|
23
|
+
internal static async Task<bool> DownloadNuGetPackagesAsync(string repoRoot, string projectPath, IReadOnlyCollection<Dependency> packages, Logger logger)
|
24
|
+
{
|
25
|
+
var tempDirectory = Directory.CreateTempSubdirectory("msbuild_sdk_restore_");
|
26
|
+
try
|
27
|
+
{
|
28
|
+
var tempProjectPath = await MSBuildHelper.CreateTempProjectAsync(tempDirectory, repoRoot, projectPath, "netstandard2.0", packages, usePackageDownload: true);
|
29
|
+
var (exitCode, stdOut, stdErr) = await ProcessEx.RunAsync("dotnet", $"restore \"{tempProjectPath}\"");
|
30
|
+
|
31
|
+
return exitCode == 0;
|
32
|
+
}
|
33
|
+
finally
|
34
|
+
{
|
35
|
+
tempDirectory.Delete(recursive: true);
|
36
|
+
}
|
14
37
|
}
|
15
38
|
}
|
@@ -34,20 +34,11 @@ internal static class PathHelper
|
|
34
34
|
public static string GetFullPathFromRelative(string rootPath, string relativePath)
|
35
35
|
=> Path.GetFullPath(JoinPath(rootPath, relativePath.NormalizePathToUnix()));
|
36
36
|
|
37
|
-
|
38
|
-
/// Check in every directory from <paramref name="initialPath"/> up to <paramref name="rootPath"/> for the file specified in <paramref name="fileName"/>.
|
39
|
-
/// </summary>
|
40
|
-
/// <returns>The path of the found file or null.</returns>
|
41
|
-
public static string? GetFileInDirectoryOrParent(string initialPath, string rootPath, string fileName, bool caseSensitive = true)
|
37
|
+
public static string[] GetAllDirectoriesToRoot(string initialDirectoryPath, string rootDirectoryPath)
|
42
38
|
{
|
43
|
-
if (File.Exists(initialPath))
|
44
|
-
{
|
45
|
-
initialPath = Path.GetDirectoryName(initialPath)!;
|
46
|
-
}
|
47
|
-
|
48
39
|
var candidatePaths = new List<string>();
|
49
|
-
var rootDirectory = new DirectoryInfo(
|
50
|
-
var candidateDirectory = new DirectoryInfo(
|
40
|
+
var rootDirectory = new DirectoryInfo(rootDirectoryPath);
|
41
|
+
var candidateDirectory = new DirectoryInfo(initialDirectoryPath);
|
51
42
|
while (candidateDirectory.FullName != rootDirectory.FullName)
|
52
43
|
{
|
53
44
|
candidatePaths.Add(candidateDirectory.FullName);
|
@@ -58,8 +49,22 @@ internal static class PathHelper
|
|
58
49
|
}
|
59
50
|
}
|
60
51
|
|
61
|
-
candidatePaths.Add(
|
52
|
+
candidatePaths.Add(rootDirectoryPath);
|
53
|
+
return candidatePaths.ToArray();
|
54
|
+
}
|
55
|
+
|
56
|
+
/// <summary>
|
57
|
+
/// Check in every directory from <paramref name="initialPath"/> up to <paramref name="rootPath"/> for the file specified in <paramref name="fileName"/>.
|
58
|
+
/// </summary>
|
59
|
+
/// <returns>The path of the found file or null.</returns>
|
60
|
+
public static string? GetFileInDirectoryOrParent(string initialPath, string rootPath, string fileName, bool caseSensitive = true)
|
61
|
+
{
|
62
|
+
if (File.Exists(initialPath))
|
63
|
+
{
|
64
|
+
initialPath = Path.GetDirectoryName(initialPath)!;
|
65
|
+
}
|
62
66
|
|
67
|
+
var candidatePaths = GetAllDirectoriesToRoot(initialPath, rootPath);
|
63
68
|
foreach (var candidatePath in candidatePaths)
|
64
69
|
{
|
65
70
|
try
|
@@ -0,0 +1,135 @@
|
|
1
|
+
using System.Collections.Immutable;
|
2
|
+
using System.Diagnostics.CodeAnalysis;
|
3
|
+
using System.Text.Json;
|
4
|
+
|
5
|
+
using NuGetUpdater.Core.Discover;
|
6
|
+
using NuGetUpdater.Core.Test.Utilities;
|
7
|
+
|
8
|
+
using Xunit;
|
9
|
+
|
10
|
+
namespace NuGetUpdater.Core.Test.Discover;
|
11
|
+
|
12
|
+
using TestFile = (string Path, string Content);
|
13
|
+
|
14
|
+
public class DiscoveryWorkerTestBase
|
15
|
+
{
|
16
|
+
protected static async Task TestDiscoveryAsync(
|
17
|
+
string workspacePath,
|
18
|
+
TestFile[] files,
|
19
|
+
ExpectedWorkspaceDiscoveryResult expectedResult)
|
20
|
+
{
|
21
|
+
var actualResult = await RunDiscoveryAsync(files, async directoryPath =>
|
22
|
+
{
|
23
|
+
var worker = new DiscoveryWorker(new Logger(verbose: true));
|
24
|
+
await worker.RunAsync(directoryPath, workspacePath, DiscoveryWorker.DiscoveryResultFileName);
|
25
|
+
});
|
26
|
+
|
27
|
+
ValidateWorkspaceResult(expectedResult, actualResult);
|
28
|
+
}
|
29
|
+
|
30
|
+
protected static void ValidateWorkspaceResult(ExpectedWorkspaceDiscoveryResult expectedResult, WorkspaceDiscoveryResult actualResult)
|
31
|
+
{
|
32
|
+
Assert.NotNull(actualResult);
|
33
|
+
Assert.Equal(expectedResult.FilePath.NormalizePathToUnix(), actualResult.FilePath.NormalizePathToUnix());
|
34
|
+
ValidateDirectoryPackagesProps(expectedResult.DirectoryPackagesProps, actualResult.DirectoryPackagesProps);
|
35
|
+
ValidateResultWithDependencies(expectedResult.GlobalJson, actualResult.GlobalJson);
|
36
|
+
ValidateResultWithDependencies(expectedResult.DotNetToolsJson, actualResult.DotNetToolsJson);
|
37
|
+
ValidateProjectResults(expectedResult.Projects, actualResult.Projects);
|
38
|
+
Assert.Equal(expectedResult.ExpectedProjectCount ?? expectedResult.Projects.Length, actualResult.Projects.Length);
|
39
|
+
|
40
|
+
return;
|
41
|
+
|
42
|
+
void ValidateResultWithDependencies(ExpectedDependencyDiscoveryResult? expectedResult, IDiscoveryResultWithDependencies? actualResult)
|
43
|
+
{
|
44
|
+
if (expectedResult is null)
|
45
|
+
{
|
46
|
+
Assert.Null(actualResult);
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
else
|
50
|
+
{
|
51
|
+
Assert.NotNull(actualResult);
|
52
|
+
}
|
53
|
+
|
54
|
+
Assert.Equal(expectedResult.FilePath.NormalizePathToUnix(), actualResult.FilePath.NormalizePathToUnix());
|
55
|
+
ValidateDependencies(expectedResult.Dependencies, actualResult.Dependencies);
|
56
|
+
Assert.Equal(expectedResult.ExpectedDependencyCount ?? expectedResult.Dependencies.Length, actualResult.Dependencies.Length);
|
57
|
+
}
|
58
|
+
|
59
|
+
void ValidateProjectResults(ImmutableArray<ExpectedSdkProjectDiscoveryResult> expectedProjects, ImmutableArray<ProjectDiscoveryResult> actualProjects)
|
60
|
+
{
|
61
|
+
if (expectedProjects.IsDefaultOrEmpty)
|
62
|
+
{
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
|
66
|
+
foreach (var expectedProject in expectedProjects)
|
67
|
+
{
|
68
|
+
var actualProject = actualProjects.Single(p => p.FilePath.NormalizePathToUnix() == expectedProject.FilePath.NormalizePathToUnix());
|
69
|
+
|
70
|
+
Assert.Equal(expectedProject.FilePath.NormalizePathToUnix(), actualProject.FilePath.NormalizePathToUnix());
|
71
|
+
AssertEx.Equal(expectedProject.Properties, actualProject.Properties, PropertyComparer.Instance);
|
72
|
+
AssertEx.Equal(expectedProject.TargetFrameworks, actualProject.TargetFrameworks);
|
73
|
+
AssertEx.Equal(expectedProject.ReferencedProjectPaths.Select(PathHelper.NormalizePathToUnix), actualProject.ReferencedProjectPaths.Select(PathHelper.NormalizePathToUnix));
|
74
|
+
ValidateDependencies(expectedProject.Dependencies, actualProject.Dependencies);
|
75
|
+
Assert.Equal(expectedProject.ExpectedDependencyCount ?? expectedProject.Dependencies.Length, actualProject.Dependencies.Length);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
void ValidateDirectoryPackagesProps(ExpectedDirectoryPackagesPropsDiscovertyResult? expected, DirectoryPackagesPropsDiscoveryResult? actual)
|
80
|
+
{
|
81
|
+
ValidateResultWithDependencies(expected, actual);
|
82
|
+
Assert.Equal(expected?.IsTransitivePinningEnabled, actual?.IsTransitivePinningEnabled);
|
83
|
+
}
|
84
|
+
|
85
|
+
void ValidateDependencies(ImmutableArray<Dependency> expectedDependencies, ImmutableArray<Dependency> actualDependencies)
|
86
|
+
{
|
87
|
+
if (expectedDependencies.IsDefault)
|
88
|
+
{
|
89
|
+
return;
|
90
|
+
}
|
91
|
+
|
92
|
+
foreach (var expectedDependency in expectedDependencies)
|
93
|
+
{
|
94
|
+
var actualDependency = actualDependencies.Single(d => d.Name == expectedDependency.Name);
|
95
|
+
Assert.Equal(expectedDependency.Name, actualDependency.Name);
|
96
|
+
Assert.Equal(expectedDependency.Version, actualDependency.Version);
|
97
|
+
Assert.Equal(expectedDependency.Type, actualDependency.Type);
|
98
|
+
AssertEx.Equal(expectedDependency.TargetFrameworks, actualDependency.TargetFrameworks);
|
99
|
+
Assert.Equal(expectedDependency.IsDirect, actualDependency.IsDirect);
|
100
|
+
Assert.Equal(expectedDependency.IsTransitive, actualDependency.IsTransitive);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
protected static async Task<WorkspaceDiscoveryResult> RunDiscoveryAsync(TestFile[] files, Func<string, Task> action)
|
106
|
+
{
|
107
|
+
// write initial files
|
108
|
+
using var temporaryDirectory = await TemporaryDirectory.CreateWithContentsAsync(files);
|
109
|
+
|
110
|
+
// run discovery
|
111
|
+
await action(temporaryDirectory.DirectoryPath);
|
112
|
+
|
113
|
+
// gather results
|
114
|
+
var resultPath = Path.Join(temporaryDirectory.DirectoryPath, DiscoveryWorker.DiscoveryResultFileName);
|
115
|
+
var resultJson = await File.ReadAllTextAsync(resultPath);
|
116
|
+
return JsonSerializer.Deserialize<WorkspaceDiscoveryResult>(resultJson, DiscoveryWorker.SerializerOptions)!;
|
117
|
+
}
|
118
|
+
|
119
|
+
internal class PropertyComparer : IEqualityComparer<Property>
|
120
|
+
{
|
121
|
+
public static PropertyComparer Instance { get; } = new();
|
122
|
+
|
123
|
+
public bool Equals(Property? x, Property? y)
|
124
|
+
{
|
125
|
+
return x?.Name == y?.Name &&
|
126
|
+
x?.Value == y?.Value &&
|
127
|
+
x?.SourceFilePath.NormalizePathToUnix() == y?.SourceFilePath.NormalizePathToUnix();
|
128
|
+
}
|
129
|
+
|
130
|
+
public int GetHashCode([DisallowNull] Property obj)
|
131
|
+
{
|
132
|
+
throw new NotImplementedException();
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
using Xunit;
|
2
|
+
|
3
|
+
namespace NuGetUpdater.Core.Test.Discover;
|
4
|
+
|
5
|
+
public partial class DiscoveryWorkerTests
|
6
|
+
{
|
7
|
+
public class DotNetToolsJson : DiscoveryWorkerTestBase
|
8
|
+
{
|
9
|
+
[Fact]
|
10
|
+
public async Task DiscoversDependencies()
|
11
|
+
{
|
12
|
+
await TestDiscoveryAsync(
|
13
|
+
workspacePath: "",
|
14
|
+
files: [
|
15
|
+
(".config/dotnet-tools.json", """
|
16
|
+
{
|
17
|
+
"version": 1,
|
18
|
+
"isRoot": true,
|
19
|
+
"tools": {
|
20
|
+
"botsay": {
|
21
|
+
"version": "1.0.0",
|
22
|
+
"commands": [
|
23
|
+
"botsay"
|
24
|
+
]
|
25
|
+
},
|
26
|
+
"dotnetsay": {
|
27
|
+
"version": "1.0.0",
|
28
|
+
"commands": [
|
29
|
+
"dotnetsay"
|
30
|
+
]
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
"""),
|
35
|
+
],
|
36
|
+
expectedResult: new()
|
37
|
+
{
|
38
|
+
FilePath = "",
|
39
|
+
DotNetToolsJson = new()
|
40
|
+
{
|
41
|
+
FilePath = ".config/dotnet-tools.json",
|
42
|
+
Dependencies = [
|
43
|
+
new("botsay", "1.0.0", DependencyType.DotNetTool),
|
44
|
+
new("dotnetsay", "1.0.0", DependencyType.DotNetTool),
|
45
|
+
]
|
46
|
+
},
|
47
|
+
ExpectedProjectCount = 0,
|
48
|
+
});
|
49
|
+
}
|
50
|
+
|
51
|
+
[Fact]
|
52
|
+
public async Task ReportsFailure()
|
53
|
+
{
|
54
|
+
await TestDiscoveryAsync(
|
55
|
+
workspacePath: "",
|
56
|
+
files: [
|
57
|
+
(".config/dotnet-tools.json", """
|
58
|
+
{
|
59
|
+
"version": 1,
|
60
|
+
"isRoot": true,
|
61
|
+
"tools": {
|
62
|
+
"botsay": {
|
63
|
+
"version": "1.0.0",
|
64
|
+
"commands": [
|
65
|
+
"botsay"
|
66
|
+
],
|
67
|
+
},
|
68
|
+
"dotnetsay": {
|
69
|
+
"version": "1.0.0",
|
70
|
+
"commands": [
|
71
|
+
"dotnetsay"
|
72
|
+
]
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
"""),
|
77
|
+
],
|
78
|
+
expectedResult: new()
|
79
|
+
{
|
80
|
+
FilePath = "",
|
81
|
+
DotNetToolsJson = new()
|
82
|
+
{
|
83
|
+
FilePath = ".config/dotnet-tools.json",
|
84
|
+
IsSuccess = false,
|
85
|
+
ExpectedDependencyCount = 0,
|
86
|
+
},
|
87
|
+
ExpectedProjectCount = 0,
|
88
|
+
});
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
using Xunit;
|
2
|
+
|
3
|
+
namespace NuGetUpdater.Core.Test.Discover;
|
4
|
+
|
5
|
+
public partial class DiscoveryWorkerTests
|
6
|
+
{
|
7
|
+
public class GlobalJson : DiscoveryWorkerTestBase
|
8
|
+
{
|
9
|
+
[Fact]
|
10
|
+
public async Task DiscoversDependencies()
|
11
|
+
{
|
12
|
+
await TestDiscoveryAsync(
|
13
|
+
workspacePath: "",
|
14
|
+
files: [
|
15
|
+
("global.json", """
|
16
|
+
{
|
17
|
+
"sdk": {
|
18
|
+
"version": "2.2.104"
|
19
|
+
},
|
20
|
+
"msbuild-sdks": {
|
21
|
+
"Microsoft.Build.Traversal": "1.0.45"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
"""),
|
25
|
+
],
|
26
|
+
expectedResult: new()
|
27
|
+
{
|
28
|
+
FilePath = "",
|
29
|
+
GlobalJson = new()
|
30
|
+
{
|
31
|
+
FilePath = "global.json",
|
32
|
+
Dependencies = [
|
33
|
+
new("Microsoft.NET.Sdk", "2.2.104", DependencyType.MSBuildSdk),
|
34
|
+
new("Microsoft.Build.Traversal", "1.0.45", DependencyType.MSBuildSdk),
|
35
|
+
]
|
36
|
+
},
|
37
|
+
ExpectedProjectCount = 0,
|
38
|
+
});
|
39
|
+
}
|
40
|
+
|
41
|
+
[Fact]
|
42
|
+
public async Task ReportsFailure()
|
43
|
+
{
|
44
|
+
await TestDiscoveryAsync(
|
45
|
+
workspacePath: "",
|
46
|
+
files: [
|
47
|
+
("global.json", """
|
48
|
+
{
|
49
|
+
"sdk": {
|
50
|
+
"version": "2.2.104",
|
51
|
+
},
|
52
|
+
"msbuild-sdks": {
|
53
|
+
"Microsoft.Build.Traversal": "1.0.45"
|
54
|
+
}
|
55
|
+
}
|
56
|
+
"""),
|
57
|
+
],
|
58
|
+
expectedResult: new()
|
59
|
+
{
|
60
|
+
FilePath = "",
|
61
|
+
GlobalJson = new()
|
62
|
+
{
|
63
|
+
FilePath = "global.json",
|
64
|
+
IsSuccess = false,
|
65
|
+
ExpectedDependencyCount = 0,
|
66
|
+
},
|
67
|
+
ExpectedProjectCount = 0,
|
68
|
+
});
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
using System.Collections.Immutable;
|
2
|
+
|
3
|
+
using Xunit;
|
4
|
+
|
5
|
+
namespace NuGetUpdater.Core.Test.Discover;
|
6
|
+
|
7
|
+
public partial class DiscoveryWorkerTests
|
8
|
+
{
|
9
|
+
public class PackagesConfig : DiscoveryWorkerTestBase
|
10
|
+
{
|
11
|
+
[Fact]
|
12
|
+
public async Task DiscoversDependencies()
|
13
|
+
{
|
14
|
+
await TestDiscoveryAsync(
|
15
|
+
workspacePath: "",
|
16
|
+
files: [
|
17
|
+
("packages.config", """
|
18
|
+
<?xml version="1.0" encoding="utf-8"?>
|
19
|
+
<packages>
|
20
|
+
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net46" />
|
21
|
+
<package id="Microsoft.Net.Compilers" version="1.0.1" targetFramework="net46" developmentDependency="true" />
|
22
|
+
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" />
|
23
|
+
<package id="Microsoft.Web.Xdt" version="2.1.1" targetFramework="net46" />
|
24
|
+
<package id="Newtonsoft.Json" version="8.0.3" allowedVersions="[8,10)" targetFramework="net46" />
|
25
|
+
<package id="NuGet.Core" version="2.11.1" targetFramework="net46" />
|
26
|
+
<package id="NuGet.Server" version="2.11.2" targetFramework="net46" />
|
27
|
+
<package id="RouteMagic" version="1.3" targetFramework="net46" />
|
28
|
+
<package id="WebActivatorEx" version="2.1.0" targetFramework="net46" />
|
29
|
+
</packages>
|
30
|
+
"""),
|
31
|
+
("myproj.csproj", """
|
32
|
+
<Project>
|
33
|
+
<PropertyGroup>
|
34
|
+
<TargetFramework>net46</TargetFramework>
|
35
|
+
</PropertyGroup>
|
36
|
+
</Project>
|
37
|
+
""")
|
38
|
+
],
|
39
|
+
expectedResult: new()
|
40
|
+
{
|
41
|
+
FilePath = "",
|
42
|
+
Projects = [
|
43
|
+
new()
|
44
|
+
{
|
45
|
+
FilePath = "myproj.csproj",
|
46
|
+
Properties = [
|
47
|
+
new("TargetFramework", "net46", "myproj.csproj"),
|
48
|
+
],
|
49
|
+
TargetFrameworks = ["net46"],
|
50
|
+
Dependencies = [
|
51
|
+
new("Microsoft.NETFramework.ReferenceAssemblies", "1.0.3", DependencyType.Unknown, TargetFrameworks: ["net46"], IsTransitive: true),
|
52
|
+
new("Microsoft.CodeDom.Providers.DotNetCompilerPlatform", "1.0.0", DependencyType.PackagesConfig, TargetFrameworks: ["net46"]),
|
53
|
+
new("Microsoft.Net.Compilers", "1.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net46"]),
|
54
|
+
new("Microsoft.Web.Infrastructure", "1.0.0.0", DependencyType.PackagesConfig, TargetFrameworks: ["net46"]),
|
55
|
+
new("Microsoft.Web.Xdt", "2.1.1", DependencyType.PackagesConfig, TargetFrameworks: ["net46"]),
|
56
|
+
new("Newtonsoft.Json", "8.0.3", DependencyType.PackagesConfig, TargetFrameworks: ["net46"]),
|
57
|
+
new("NuGet.Core", "2.11.1", DependencyType.PackagesConfig, TargetFrameworks: ["net46"]),
|
58
|
+
new("NuGet.Server", "2.11.2", DependencyType.PackagesConfig, TargetFrameworks: ["net46"]),
|
59
|
+
new("RouteMagic", "1.3", DependencyType.PackagesConfig, TargetFrameworks: ["net46"]),
|
60
|
+
new("WebActivatorEx", "2.1.0", DependencyType.PackagesConfig, TargetFrameworks: ["net46"]),
|
61
|
+
],
|
62
|
+
}
|
63
|
+
],
|
64
|
+
});
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|