dependabot-nuget 0.242.1 → 0.243.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/.editorconfig +37 -28
  3. data/helpers/lib/NuGetUpdater/.gitignore +1 -0
  4. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.CommandLine/AssemblyMetadataExtractor.cs +2 -1
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +2 -2
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +178 -176
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -1
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs +1 -0
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs +5 -4
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +1 -0
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs +10 -5
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs +16 -12
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +18 -17
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs +7 -7
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +13 -20
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +9 -3
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +32 -16
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +42 -22
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +32 -13
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/WebApplicationTargetsConditionPatcher.cs +47 -0
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/XmlFilePreAndPostProcessor.cs +55 -0
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +12 -9
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +49 -42
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +16 -3
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +6 -6
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/XmlExtensions.cs +11 -0
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs +18 -9
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs +2 -2
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/FrameworkCompatibilityServiceFacts.cs +7 -7
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/SupportedFrameworkFacts.cs +1 -1
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +9 -9
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorker.DirsProj.cs +81 -80
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +22 -9
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +140 -104
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +25 -25
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +8 -9
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +198 -22
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +401 -399
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs +17 -15
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +111 -42
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterTests.cs +103 -87
  42. data/lib/dependabot/nuget/file_parser/project_file_parser.rb +45 -19
  43. data/lib/dependabot/nuget/file_parser.rb +21 -3
  44. data/lib/dependabot/nuget/file_updater.rb +42 -6
  45. data/lib/dependabot/nuget/native_helpers.rb +27 -8
  46. data/lib/dependabot/nuget/nuget_client.rb +66 -23
  47. data/lib/dependabot/nuget/nuget_config_credential_helpers.rb +7 -3
  48. data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +63 -59
  49. data/lib/dependabot/nuget/update_checker/dependency_finder.rb +2 -2
  50. data/lib/dependabot/nuget/update_checker/nupkg_fetcher.rb +1 -1
  51. data/lib/dependabot/nuget/update_checker/nuspec_fetcher.rb +22 -17
  52. data/lib/dependabot/nuget/update_checker/repository_finder.rb +292 -270
  53. data/lib/dependabot/nuget/update_checker/tfm_comparer.rb +11 -13
  54. data/lib/dependabot/nuget/update_checker/tfm_finder.rb +80 -82
  55. data/lib/dependabot/nuget/update_checker/version_finder.rb +3 -2
  56. data/lib/dependabot/nuget/version.rb +18 -7
  57. data/lib/dependabot/nuget.rb +0 -2
  58. metadata +7 -5
@@ -41,11 +41,11 @@ public class FrameworkCompatibilityServiceFacts
41
41
  public void UnknownSupportedPackageReturnsSetWithSameFramework()
42
42
  {
43
43
  var framework = NuGetFramework.Parse("net45-client");
44
- var frameworks = new List<NuGetFramework>() { framework };
44
+ var frameworks = new List<NuGetFramework> { framework };
45
45
  var compatible = _service.GetCompatibleFrameworks(frameworks);
46
46
 
47
47
  Assert.False(framework.IsUnsupported);
48
- Assert.Equal(expected: 1, compatible.Count);
48
+ Assert.Single(compatible);
49
49
  Assert.Contains(framework, compatible);
50
50
  }
51
51
 
@@ -57,10 +57,10 @@ public class FrameworkCompatibilityServiceFacts
57
57
  {
58
58
  var unsupportedFramework = NuGetFramework.Parse(unsupportedFrameworkName);
59
59
 
60
- var result = _service.GetCompatibleFrameworks(new List<NuGetFramework>() { unsupportedFramework });
60
+ var result = _service.GetCompatibleFrameworks([unsupportedFramework]);
61
61
 
62
62
  Assert.True(unsupportedFramework.IsUnsupported);
63
- Assert.Equal(expected: 0, actual: result.Count);
63
+ Assert.Empty(result);
64
64
  }
65
65
 
66
66
  [Theory]
@@ -71,10 +71,10 @@ public class FrameworkCompatibilityServiceFacts
71
71
  {
72
72
  var portableFramework = NuGetFramework.Parse(pclFrameworkName);
73
73
 
74
- var result = _service.GetCompatibleFrameworks(new List<NuGetFramework>() { portableFramework });
74
+ var result = _service.GetCompatibleFrameworks([portableFramework]);
75
75
 
76
76
  Assert.True(portableFramework.IsPCL);
77
- Assert.Equal(expected: 0, actual: result.Count);
77
+ Assert.Empty(result);
78
78
  }
79
79
 
80
80
  [Theory]
@@ -113,7 +113,7 @@ public class FrameworkCompatibilityServiceFacts
113
113
  projectFrameworks.Add(NuGetFramework.Parse(frameworkName));
114
114
  }
115
115
 
116
- var compatibleFrameworks = _service.GetCompatibleFrameworks(new HashSet<NuGetFramework>() { packageFramework });
116
+ var compatibleFrameworks = _service.GetCompatibleFrameworks([packageFramework]);
117
117
  Assert.Equal(windowsProjectFrameworks.Length, compatibleFrameworks.Count);
118
118
 
119
119
  var containsAllCompatibleFrameworks = compatibleFrameworks.All(cf => projectFrameworks.Contains(cf));
@@ -49,7 +49,7 @@ public class SupportedFrameworksFacts
49
49
 
50
50
  foreach (var field in fields)
51
51
  {
52
- var framework = (NuGetFramework)field.GetValue(null);
52
+ var framework = (NuGetFramework)field.GetValue(null)!;
53
53
 
54
54
  if (DeprecatedFrameworks.Contains(framework))
55
55
  {
@@ -23,8 +23,8 @@ public class PackagesConfigUpdaterTests
23
23
  public static IEnumerable<object[]> PackagesDirectoryPathTestData()
24
24
  {
25
25
  // project with namespace
26
- yield return new object[]
27
- {
26
+ yield return
27
+ [
28
28
  """
29
29
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
30
30
  <ItemGroup>
@@ -38,11 +38,11 @@ public class PackagesConfigUpdaterTests
38
38
  "Newtonsoft.Json",
39
39
  "7.0.1",
40
40
  @"..\packages"
41
- };
41
+ ];
42
42
 
43
43
  // project without namespace
44
- yield return new object[]
45
- {
44
+ yield return
45
+ [
46
46
  """
47
47
  <Project>
48
48
  <ItemGroup>
@@ -56,11 +56,11 @@ public class PackagesConfigUpdaterTests
56
56
  "Newtonsoft.Json",
57
57
  "7.0.1",
58
58
  @"..\packages"
59
- };
59
+ ];
60
60
 
61
61
  // project with non-standard packages path
62
- yield return new object[]
63
- {
62
+ yield return
63
+ [
64
64
  """
65
65
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
66
66
  <ItemGroup>
@@ -74,6 +74,6 @@ public class PackagesConfigUpdaterTests
74
74
  "Newtonsoft.Json",
75
75
  "7.0.1",
76
76
  @"..\not-a-path-you-would-expect"
77
- };
77
+ ];
78
78
  }
79
79
  }
@@ -1,4 +1,5 @@
1
1
  using System;
2
+ using System.Collections.Generic;
2
3
  using System.IO;
3
4
  using System.Linq;
4
5
  using System.Threading.Tasks;
@@ -23,53 +24,53 @@ public partial class UpdateWorkerTests
23
24
  // initial
24
25
  projectContents: """
25
26
  <Project Sdk="Microsoft.Build.NoTargets">
26
-
27
+
27
28
  <ItemGroup>
28
29
  <ProjectReference Include="src/test-project.csproj" />
29
30
  </ItemGroup>
30
31
 
31
32
  </Project>
32
33
  """,
33
- additionalFiles: new (string Path, string Content)[]
34
- {
34
+ additionalFiles:
35
+ [
35
36
  ("src/test-project.csproj",
36
- """
37
- <Project Sdk="Microsoft.NET.Sdk">
38
- <PropertyGroup>
39
- <TargetFramework>netstandard2.0</TargetFramework>
40
- </PropertyGroup>
41
-
42
- <ItemGroup>
43
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
44
- </ItemGroup>
45
- </Project>
46
- """)
47
- },
37
+ """
38
+ <Project Sdk="Microsoft.NET.Sdk">
39
+ <PropertyGroup>
40
+ <TargetFramework>netstandard2.0</TargetFramework>
41
+ </PropertyGroup>
42
+
43
+ <ItemGroup>
44
+ <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
45
+ </ItemGroup>
46
+ </Project>
47
+ """)
48
+ ],
48
49
  // expected
49
50
  expectedProjectContents: """
50
51
  <Project Sdk="Microsoft.Build.NoTargets">
51
-
52
+
52
53
  <ItemGroup>
53
54
  <ProjectReference Include="src/test-project.csproj" />
54
55
  </ItemGroup>
55
56
 
56
57
  </Project>
57
58
  """,
58
- additionalFilesExpected: new (string Path, string Content)[]
59
- {
59
+ additionalFilesExpected:
60
+ [
60
61
  ("src/test-project.csproj",
61
- """
62
- <Project Sdk="Microsoft.NET.Sdk">
63
- <PropertyGroup>
64
- <TargetFramework>netstandard2.0</TargetFramework>
65
- </PropertyGroup>
66
-
67
- <ItemGroup>
68
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
69
- </ItemGroup>
70
- </Project>
71
- """)
72
- });
62
+ """
63
+ <Project Sdk="Microsoft.NET.Sdk">
64
+ <PropertyGroup>
65
+ <TargetFramework>netstandard2.0</TargetFramework>
66
+ </PropertyGroup>
67
+
68
+ <ItemGroup>
69
+ <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
70
+ </ItemGroup>
71
+ </Project>
72
+ """)
73
+ ]);
73
74
  }
74
75
 
75
76
  [Fact]
@@ -100,73 +101,73 @@ public partial class UpdateWorkerTests
100
101
  // initial
101
102
  projectContents: """
102
103
  <Project Sdk="Microsoft.Build.NoTargets">
103
-
104
+
104
105
  <ItemGroup>
105
106
  <ProjectReference Include="src/dirs.proj" />
106
107
  </ItemGroup>
107
108
 
108
109
  </Project>
109
110
  """,
110
- additionalFiles: new (string Path, string Content)[]
111
- {
111
+ additionalFiles:
112
+ [
112
113
  ("src/dirs.proj",
113
- """
114
- <Project Sdk="Microsoft.Build.NoTargets">
115
-
116
- <ItemGroup>
117
- <ProjectReference Include="test-project/test-project.csproj" />
118
- </ItemGroup>
119
-
120
- </Project>
121
- """),
114
+ """
115
+ <Project Sdk="Microsoft.Build.NoTargets">
116
+
117
+ <ItemGroup>
118
+ <ProjectReference Include="test-project/test-project.csproj" />
119
+ </ItemGroup>
120
+
121
+ </Project>
122
+ """),
122
123
  ("src/test-project/test-project.csproj",
123
- """
124
- <Project Sdk="Microsoft.NET.Sdk">
125
- <PropertyGroup>
126
- <TargetFramework>netstandard2.0</TargetFramework>
127
- </PropertyGroup>
128
-
129
- <ItemGroup>
130
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
131
- </ItemGroup>
132
- </Project>
133
- """)
134
- },
124
+ """
125
+ <Project Sdk="Microsoft.NET.Sdk">
126
+ <PropertyGroup>
127
+ <TargetFramework>netstandard2.0</TargetFramework>
128
+ </PropertyGroup>
129
+
130
+ <ItemGroup>
131
+ <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
132
+ </ItemGroup>
133
+ </Project>
134
+ """)
135
+ ],
135
136
  // expected
136
137
  expectedProjectContents: """
137
138
  <Project Sdk="Microsoft.Build.NoTargets">
138
-
139
+
139
140
  <ItemGroup>
140
141
  <ProjectReference Include="src/dirs.proj" />
141
142
  </ItemGroup>
142
143
 
143
144
  </Project>
144
145
  """,
145
- additionalFilesExpected: new (string Path, string Content)[]
146
- {
146
+ additionalFilesExpected:
147
+ [
147
148
  ("src/dirs.proj",
148
- """
149
- <Project Sdk="Microsoft.Build.NoTargets">
150
-
151
- <ItemGroup>
152
- <ProjectReference Include="test-project/test-project.csproj" />
153
- </ItemGroup>
154
-
155
- </Project>
156
- """),
149
+ """
150
+ <Project Sdk="Microsoft.Build.NoTargets">
151
+
152
+ <ItemGroup>
153
+ <ProjectReference Include="test-project/test-project.csproj" />
154
+ </ItemGroup>
155
+
156
+ </Project>
157
+ """),
157
158
  ("src/test-project/test-project.csproj",
158
- """
159
- <Project Sdk="Microsoft.NET.Sdk">
160
- <PropertyGroup>
161
- <TargetFramework>netstandard2.0</TargetFramework>
162
- </PropertyGroup>
163
-
164
- <ItemGroup>
165
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
166
- </ItemGroup>
167
- </Project>
168
- """)
169
- });
159
+ """
160
+ <Project Sdk="Microsoft.NET.Sdk">
161
+ <PropertyGroup>
162
+ <TargetFramework>netstandard2.0</TargetFramework>
163
+ </PropertyGroup>
164
+
165
+ <ItemGroup>
166
+ <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
167
+ </ItemGroup>
168
+ </Project>
169
+ """)
170
+ ]);
170
171
  }
171
172
 
172
173
  static async Task TestUpdateForDirsProj(
@@ -179,8 +180,8 @@ public partial class UpdateWorkerTests
179
180
  (string Path, string Content)[]? additionalFiles = null,
180
181
  (string Path, string Content)[]? additionalFilesExpected = null)
181
182
  {
182
- additionalFiles ??= Array.Empty<(string Path, string Content)>();
183
- additionalFilesExpected ??= Array.Empty<(string Path, string Content)>();
183
+ additionalFiles ??= [];
184
+ additionalFilesExpected ??= [];
184
185
 
185
186
  var projectName = "dirs";
186
187
  var projectFileName = $"{projectName}.proj";
@@ -18,7 +18,15 @@ public abstract class UpdateWorkerTestBase
18
18
  bool isTransitive = false,
19
19
  (string Path, string Content)[]? additionalFiles = null,
20
20
  string projectFilePath = "test-project.csproj")
21
- => TestUpdateForProject(dependencyName, oldVersion, newVersion, (projectFilePath, projectContents), expectedProjectContents: projectContents, isTransitive, additionalFiles, additionalFilesExpected: additionalFiles);
21
+ => TestUpdateForProject(
22
+ dependencyName,
23
+ oldVersion,
24
+ newVersion,
25
+ (projectFilePath, projectContents),
26
+ expectedProjectContents: projectContents,
27
+ isTransitive,
28
+ additionalFiles,
29
+ additionalFilesExpected: additionalFiles);
22
30
 
23
31
  protected static Task TestUpdateForProject(
24
32
  string dependencyName,
@@ -30,10 +38,15 @@ public abstract class UpdateWorkerTestBase
30
38
  (string Path, string Content)[]? additionalFiles = null,
31
39
  (string Path, string Content)[]? additionalFilesExpected = null,
32
40
  string projectFilePath = "test-project.csproj")
33
- {
34
- var projectFile = (Path: projectFilePath, Content: projectContents);
35
- return TestUpdateForProject(dependencyName, oldVersion, newVersion, projectFile, expectedProjectContents, isTransitive, additionalFiles, additionalFilesExpected);
36
- }
41
+ => TestUpdateForProject(
42
+ dependencyName,
43
+ oldVersion,
44
+ newVersion,
45
+ (Path: projectFilePath, Content: projectContents),
46
+ expectedProjectContents,
47
+ isTransitive,
48
+ additionalFiles,
49
+ additionalFilesExpected);
37
50
 
38
51
  protected static async Task TestUpdateForProject(
39
52
  string dependencyName,
@@ -45,8 +58,8 @@ public abstract class UpdateWorkerTestBase
45
58
  (string Path, string Content)[]? additionalFiles = null,
46
59
  (string Path, string Content)[]? additionalFilesExpected = null)
47
60
  {
48
- additionalFiles ??= Array.Empty<(string Path, string Content)>();
49
- additionalFilesExpected ??= Array.Empty<(string Path, string Content)>();
61
+ additionalFiles ??= [];
62
+ additionalFilesExpected ??= [];
50
63
 
51
64
  var projectFilePath = projectFile.Path;
52
65
  var projectName = Path.GetFileNameWithoutExtension(projectFilePath);
@@ -76,7 +89,7 @@ public abstract class UpdateWorkerTestBase
76
89
  """;
77
90
  var testFiles = new[] { (slnName, slnContent), projectFile }.Concat(additionalFiles).ToArray();
78
91
 
79
- var actualResult = await RunUpdate(testFiles, async (temporaryDirectory) =>
92
+ var actualResult = await RunUpdate(testFiles, async temporaryDirectory =>
80
93
  {
81
94
  var slnPath = Path.Combine(temporaryDirectory, slnName);
82
95
  var worker = new UpdaterWorker(new Logger(verbose: true));
@@ -94,7 +107,7 @@ public abstract class UpdateWorkerTestBase
94
107
  using var tempDir = new TemporaryDirectory();
95
108
  foreach (var file in files)
96
109
  {
97
- var localPath = file.Path.StartsWith("/") ? file.Path[1..] : file.Path; // remove path rooting character
110
+ var localPath = file.Path.StartsWith('/') ? file.Path[1..] : file.Path; // remove path rooting character
98
111
  var filePath = Path.Combine(tempDir.DirectoryPath, localPath);
99
112
  var directoryPath = Path.GetDirectoryName(filePath);
100
113
  Directory.CreateDirectory(directoryPath!);