dependabot-nuget 0.308.0 → 0.310.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.
Files changed (20) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/NuGetUpdater.Cli.csproj +19 -0
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +5 -0
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +6 -6
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +6 -0
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/HttpApiHandler.cs +12 -3
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +23 -3
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SpecialImportsConditionPatcher.cs +14 -2
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/BOMHandling.cs +35 -0
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +0 -8
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +3 -3
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/EndToEndTests.cs +355 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +703 -550
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestDiscoveryWorker.cs +3 -4
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestHttpServer.cs +16 -6
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/SpecialFilePatcherTests.cs +19 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/BOMHandlingTests.cs +66 -0
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/EOLHandlingTests.cs +227 -13
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +331 -164
  20. metadata +8 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b510a9d8fdeba70a85b5eeab842a16642ec8e7beab71caa0e99f7e39bab6fd97
4
- data.tar.gz: c7ef1903b20b5eda9eb1e02153cedc3972a00c574e0acb4ad212cbaf16e673e4
3
+ metadata.gz: 60d194f7c1aa9c0a61df000bad1d3030110a66a73cb86615c97fe0a3d053cc56
4
+ data.tar.gz: d87118a0fb76c9b571b27ec5a66a3ae65d808e17daa9d68cb734962ee3aa5fd7
5
5
  SHA512:
6
- metadata.gz: '077584f16e3e95b98e69e74c67e3105dbf09455c19674bbc21929a91236fd5ba18b465f90103557e046ea867227bd6209e52d2faa958296234b020b0b24d09dc'
7
- data.tar.gz: b55391c84e09601c30a4046cf4b29263ea40f17360de2f70d7830978d7a8dca8994aec472bc92fcf5c813ceac235c003c0b449b3e08759d2e99f507c275df64e
6
+ metadata.gz: 6d9fcc54e90b7c3ea93eedab675ce512a989176b02c676d442f9b9edcbbb5653dd9bacc777d77c52f1061ede4048523dfc9693a50c01ce089c5205dcf1cdfddb
7
+ data.tar.gz: 12abc6e3b3c04933d6d341ea9532d9dbae1cc121310c1f4252e0f7d9f2776861c1b3cb696d813a1c37717363c219c4196743665001ecf7ade03d8bf40aaf58bc
@@ -3,6 +3,7 @@
3
3
  <PropertyGroup>
4
4
  <TargetFramework>$(CommonTargetFramework)</TargetFramework>
5
5
  <OutputType>Exe</OutputType>
6
+ <_NETFrameworkTargetingPacksVersion>[1.0.3]</_NETFrameworkTargetingPacksVersion>
6
7
  </PropertyGroup>
7
8
 
8
9
  <ItemGroup>
@@ -13,6 +14,24 @@
13
14
  <PackageReference Include="System.CommandLine" />
14
15
  </ItemGroup>
15
16
 
17
+ <ItemGroup Label="Targeting packs required for .NET Framework in SDK-style projects">
18
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies" Version="$(_NETFrameworkTargetingPacksVersion)" />
19
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net20" Version="$(_NETFrameworkTargetingPacksVersion)" />
20
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net35" Version="$(_NETFrameworkTargetingPacksVersion)" />
21
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net40" Version="$(_NETFrameworkTargetingPacksVersion)" />
22
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net45" Version="$(_NETFrameworkTargetingPacksVersion)" />
23
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net451" Version="$(_NETFrameworkTargetingPacksVersion)" />
24
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net452" Version="$(_NETFrameworkTargetingPacksVersion)" />
25
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net46" Version="$(_NETFrameworkTargetingPacksVersion)" />
26
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="$(_NETFrameworkTargetingPacksVersion)" />
27
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net462" Version="$(_NETFrameworkTargetingPacksVersion)" />
28
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net47" Version="$(_NETFrameworkTargetingPacksVersion)" />
29
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net471" Version="$(_NETFrameworkTargetingPacksVersion)" />
30
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net472" Version="$(_NETFrameworkTargetingPacksVersion)" />
31
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net48" Version="$(_NETFrameworkTargetingPacksVersion)" />
32
+ <PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net481" Version="$(_NETFrameworkTargetingPacksVersion)" />
33
+ </ItemGroup>
34
+
16
35
  <ItemGroup>
17
36
  <InternalsVisibleTo Include="NuGetUpdater.Cli.Test"/>
18
37
  </ItemGroup>
@@ -1,4 +1,5 @@
1
1
  using System.CommandLine;
2
+ using System.Text;
2
3
 
3
4
  using NuGetUpdater.Cli.Commands;
4
5
 
@@ -8,6 +9,10 @@ internal sealed class Program
8
9
  {
9
10
  internal static async Task<int> Main(string[] args)
10
11
  {
12
+ // Allow loading of legacy code pages. This is useful for being able to load XML files with
13
+ // <?xml version="1.0" encoding="windows-1252"?>
14
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
15
+
11
16
  var exitCode = 0;
12
17
  Action<int> setExitCode = code => exitCode = code;
13
18
 
@@ -50,10 +50,10 @@ public partial class EntryPointTests
50
50
  },
51
51
  expectedUrls:
52
52
  [
53
- "/update_jobs/TEST-ID/update_dependency_list",
54
- "/update_jobs/TEST-ID/increment_metric",
55
- "/update_jobs/TEST-ID/create_pull_request",
56
- "/update_jobs/TEST-ID/mark_as_processed",
53
+ "POST /update_jobs/TEST-ID/update_dependency_list",
54
+ "POST /update_jobs/TEST-ID/increment_metric",
55
+ "POST /update_jobs/TEST-ID/create_pull_request",
56
+ "PATCH /update_jobs/TEST-ID/mark_as_processed",
57
57
  ]
58
58
  );
59
59
  }
@@ -79,9 +79,9 @@ public partial class EntryPointTests
79
79
  await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, tempDirectory.DirectoryPath);
80
80
 
81
81
  var actualUrls = new List<string>();
82
- using var http = TestHttpServer.CreateTestStringServer(url =>
82
+ using var http = TestHttpServer.CreateTestStringServer((method, url) =>
83
83
  {
84
- actualUrls.Add(new Uri(url).PathAndQuery);
84
+ actualUrls.Add($"{method} {new Uri(url).PathAndQuery}");
85
85
  return (200, "ok");
86
86
  });
87
87
  var args = new List<string>()
@@ -652,6 +652,12 @@ internal static class SdkProjectDiscovery
652
652
  projectEvaluation = build.FindEvaluation(project.EvaluationId);
653
653
  }
654
654
 
655
+ if (!File.Exists(projectEvaluation?.ProjectFile))
656
+ {
657
+ // WPF creates temporary projects during evaluation that no longer exist on disk for analysis, but they're not necessary for our purposes.
658
+ return null;
659
+ }
660
+
655
661
  return projectEvaluation;
656
662
  }
657
663
 
@@ -57,7 +57,7 @@ public class HttpApiHandler : IApiHandler
57
57
 
58
58
  public async Task MarkAsProcessed(MarkAsProcessed markAsProcessed)
59
59
  {
60
- await PostAsJson("mark_as_processed", markAsProcessed);
60
+ await PatchAsJson("mark_as_processed", markAsProcessed);
61
61
  }
62
62
 
63
63
  internal static string Serialize(object body)
@@ -70,11 +70,20 @@ public class HttpApiHandler : IApiHandler
70
70
  return payload;
71
71
  }
72
72
 
73
- private async Task PostAsJson(string endpoint, object body)
73
+ private Task PostAsJson(string endpoint, object body) => SendAsJson(endpoint, body, "POST");
74
+ private Task PatchAsJson(string endpoint, object body) => SendAsJson(endpoint, body, "PATCH");
75
+
76
+ private async Task SendAsJson(string endpoint, object body, string method)
74
77
  {
78
+ var uri = $"{_apiUrl}/update_jobs/{_jobId}/{endpoint}";
75
79
  var payload = Serialize(body);
76
80
  var content = new StringContent(payload, Encoding.UTF8, "application/json");
77
- var response = await HttpClient.PostAsync($"{_apiUrl}/update_jobs/{_jobId}/{endpoint}", content);
81
+ var httpMethod = new HttpMethod(method);
82
+ var message = new HttpRequestMessage(httpMethod, uri)
83
+ {
84
+ Content = content
85
+ };
86
+ var response = await HttpClient.SendAsync(message);
78
87
  var _ = response.EnsureSuccessStatusCode();
79
88
  }
80
89
  }
@@ -125,6 +125,7 @@ public class RunWorker
125
125
  // TODO: pull out relevant dependencies, then check each for updates and track the changes
126
126
  var originalDependencyFileContents = new Dictionary<string, string>();
127
127
  var originalDependencyFileEOFs = new Dictionary<string, EOLType>();
128
+ var originalDependencyFileBOMs = new Dictionary<string, bool>();
128
129
  var actualUpdatedDependencies = new List<ReportedDependency>();
129
130
 
130
131
  // track original contents for later handling
@@ -133,8 +134,10 @@ public class RunWorker
133
134
  var repoFullPath = Path.Join(directory, fileName).FullyNormalizedRootedPath();
134
135
  var localFullPath = Path.Join(repoContentsPath.FullName, repoFullPath);
135
136
  var content = await File.ReadAllTextAsync(localFullPath);
137
+ var rawContent = await File.ReadAllBytesAsync(localFullPath);
136
138
  originalDependencyFileContents[repoFullPath] = content;
137
139
  originalDependencyFileEOFs[repoFullPath] = content.GetPredominantEOL();
140
+ originalDependencyFileBOMs[repoFullPath] = rawContent.HasBOM();
138
141
  }
139
142
 
140
143
  foreach (var project in discoveryResult.Projects)
@@ -257,15 +260,25 @@ public class RunWorker
257
260
  var updatedContent = await File.ReadAllTextAsync(localFullPath);
258
261
 
259
262
  updatedContent = updatedContent.SetEOL(originalDependencyFileEOFs[repoFullPath]);
260
- await File.WriteAllTextAsync(localFullPath, updatedContent);
263
+ var updatedRawContent = updatedContent.SetBOM(originalDependencyFileBOMs[repoFullPath]);
264
+ await File.WriteAllBytesAsync(localFullPath, updatedRawContent);
261
265
 
262
266
  if (updatedContent != originalContent)
263
267
  {
268
+ var reportedContent = updatedContent;
269
+ var encoding = "utf-8";
270
+ if (originalDependencyFileBOMs[repoFullPath])
271
+ {
272
+ reportedContent = Convert.ToBase64String(updatedRawContent);
273
+ encoding = "base64";
274
+ }
275
+
264
276
  updatedDependencyFiles[localFullPath] = new DependencyFile()
265
277
  {
266
278
  Name = Path.GetFileName(repoFullPath),
267
279
  Directory = Path.GetDirectoryName(repoFullPath)!.NormalizePathToUnix(),
268
- Content = updatedContent,
280
+ Content = reportedContent,
281
+ ContentEncoding = encoding,
269
282
  };
270
283
  }
271
284
  }
@@ -331,10 +344,17 @@ public class RunWorker
331
344
  Base64DependencyFiles = originalDependencyFileContents.OrderBy(kvp => kvp.Key).Select(kvp =>
332
345
  {
333
346
  var fullPath = kvp.Key.FullyNormalizedRootedPath();
347
+ var rawContent = Encoding.UTF8.GetBytes(kvp.Value);
348
+ if (originalDependencyFileBOMs[kvp.Key])
349
+ {
350
+ rawContent = Encoding.UTF8.GetPreamble().Concat(rawContent).ToArray();
351
+ }
352
+
334
353
  return new DependencyFile()
335
354
  {
336
355
  Name = Path.GetFileName(fullPath),
337
- Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(kvp.Value)),
356
+ Content = Convert.ToBase64String(rawContent),
357
+ ContentEncoding = "base64",
338
358
  Directory = Path.GetDirectoryName(fullPath)!.NormalizePathToUnix(),
339
359
  };
340
360
  }).ToArray(),
@@ -1,3 +1,5 @@
1
+ using System.Collections.Immutable;
2
+
1
3
  using Microsoft.Language.Xml;
2
4
 
3
5
  namespace NuGetUpdater.Core.Updater
@@ -7,12 +9,19 @@ namespace NuGetUpdater.Core.Updater
7
9
  private readonly List<string?> _capturedConditions = new List<string?>();
8
10
  private readonly XmlFilePreAndPostProcessor _processor;
9
11
 
12
+ // These files only ship with a full Visual Studio install
10
13
  private readonly HashSet<string> ImportedFilesToIgnore = new(StringComparer.OrdinalIgnoreCase)
11
14
  {
12
15
  "Microsoft.TextTemplating.targets",
13
16
  "Microsoft.WebApplication.targets"
14
17
  };
15
18
 
19
+ // PackageReference elements with `GeneratePathProperty="true"` will cause a special property to be created.
20
+ private readonly ImmutableArray<string> PathSegmentsToIgnore =
21
+ [
22
+ "$(Pkg"
23
+ ];
24
+
16
25
  public SpecialImportsConditionPatcher(string projectFilePath)
17
26
  {
18
27
  _processor = new XmlFilePreAndPostProcessor(
@@ -25,8 +34,11 @@ namespace NuGetUpdater.Core.Updater
25
34
  var projectPath = e.GetAttributeValue("Project");
26
35
  if (projectPath is not null)
27
36
  {
28
- var projectFileName = Path.GetFileName(projectPath.NormalizePathToUnix());
29
- return ImportedFilesToIgnore.Contains(projectFileName);
37
+ var normalizedProjectPath = projectPath.NormalizePathToUnix();
38
+ var projectFileName = Path.GetFileName(normalizedProjectPath);
39
+ var hasForbiddenFile = ImportedFilesToIgnore.Contains(projectFileName);
40
+ var hasForbiddenPathSegment = PathSegmentsToIgnore.Any(p => normalizedProjectPath.Contains(p, StringComparison.OrdinalIgnoreCase));
41
+ return hasForbiddenFile || hasForbiddenPathSegment;
30
42
  }
31
43
 
32
44
  return false;
@@ -0,0 +1,35 @@
1
+ using System.Text;
2
+
3
+ namespace NuGetUpdater.Core.Utilities;
4
+
5
+ internal static class BOMHandling
6
+ {
7
+ public static bool HasBOM(this byte[] rawContent)
8
+ {
9
+ var bom = Encoding.UTF8.GetPreamble();
10
+ if (rawContent.Length >= bom.Length)
11
+ {
12
+ for (int i = 0; i < bom.Length; i++)
13
+ {
14
+ if (rawContent[i] != bom[i])
15
+ {
16
+ return false;
17
+ }
18
+ }
19
+
20
+ return true;
21
+ }
22
+
23
+ return false;
24
+ }
25
+ public static byte[] SetBOM(this string content, bool setBOM)
26
+ {
27
+ var rawContent = Encoding.UTF8.GetBytes(content);
28
+ if (setBOM)
29
+ {
30
+ rawContent = Encoding.UTF8.GetPreamble().Concat(rawContent).ToArray();
31
+ }
32
+
33
+ return rawContent;
34
+ }
35
+ }
@@ -467,14 +467,6 @@ public class PackageManager
467
467
  // Loop from the current version to the latest version, use next patch as a limit (unless there's a limit) so it doesn't look for versions that don't exist
468
468
  for (NuGetVersion version = currentVersionParent; version <= latestVersion; version = NextPatch(version, versions))
469
469
  {
470
- NuGetVersion nextPatch = NextPatch(version, versions);
471
-
472
- // If the next patch is the same as the currentVersioon, then the update is a Success
473
- if (nextPatch == version)
474
- {
475
- return "Success";
476
- }
477
-
478
470
  string parentVersion = version.ToString();
479
471
  parent.NewVersion = parentVersion;
480
472
 
@@ -702,7 +702,7 @@ public partial class AnalyzeWorkerTests : AnalyzeWorkerTestBase
702
702
 
703
703
  // nothing else is found
704
704
  return (404, Encoding.UTF8.GetBytes("{}"));
705
- };
705
+ }
706
706
  }
707
707
  using var http1 = TestHttpServer.CreateTestServer(TestHttpHandler1);
708
708
  using var http2 = TestHttpServer.CreateTestServer(TestHttpHandler2);
@@ -874,7 +874,7 @@ public partial class AnalyzeWorkerTests : AnalyzeWorkerTestBase
874
874
 
875
875
  // nothing else is found
876
876
  return (404, Encoding.UTF8.GetBytes("{}"));
877
- };
877
+ }
878
878
  }
879
879
  using var http1 = TestHttpServer.CreateTestServer(TestHttpHandler1);
880
880
  using var http2 = TestHttpServer.CreateTestServer(TestHttpHandler2);
@@ -1064,7 +1064,7 @@ public partial class AnalyzeWorkerTests : AnalyzeWorkerTestBase
1064
1064
 
1065
1065
  // nothing else is found
1066
1066
  return (404, Encoding.UTF8.GetBytes("{}"));
1067
- };
1067
+ }
1068
1068
  }
1069
1069
  using var http = TestHttpServer.CreateTestServer(TestHttpHandler);
1070
1070
  await TestAnalyzeAsync(