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
@@ -16,14 +16,13 @@ internal class TestDiscoveryWorker : IDiscoveryWorker
16
16
  return _getResult((repoRootPath, workspacePath));
17
17
  }
18
18
 
19
- public static TestDiscoveryWorker FromResults(params (string RepoRootPath, string WorkspacePath, WorkspaceDiscoveryResult Result)[] results)
19
+ public static TestDiscoveryWorker FromResults(params (string WorkspacePath, WorkspaceDiscoveryResult Result)[] results)
20
20
  {
21
- return new TestDiscoveryWorker(((string RepoRootPath, string WorkspacePath) input) =>
21
+ return new TestDiscoveryWorker(((string _RepoRootPath, string WorkspacePath) input) =>
22
22
  {
23
23
  foreach (var set in results)
24
24
  {
25
- if (set.RepoRootPath == input.RepoRootPath &&
26
- set.WorkspacePath == input.WorkspacePath)
25
+ if (set.WorkspacePath == input.WorkspacePath)
27
26
  {
28
27
  return Task.FromResult(set.Result);
29
28
  }
@@ -10,13 +10,13 @@ namespace NuGetUpdater.Core.Test
10
10
  {
11
11
  public class TestHttpServer : IDisposable
12
12
  {
13
- private readonly Func<string, (int, byte[])> _requestHandler;
13
+ private readonly Func<string, string, (int, byte[])> _requestHandler;
14
14
  private readonly HttpListener _listener;
15
15
  private bool _runServer = true;
16
16
 
17
17
  public string BaseUrl { get; }
18
18
 
19
- private TestHttpServer(string baseurl, Func<string, (int, byte[])> requestHandler)
19
+ private TestHttpServer(string baseurl, Func<string, string, (int, byte[])> requestHandler)
20
20
  {
21
21
  BaseUrl = baseurl;
22
22
  _requestHandler = requestHandler;
@@ -43,7 +43,7 @@ namespace NuGetUpdater.Core.Test
43
43
  while (_runServer)
44
44
  {
45
45
  var context = await _listener.GetContextAsync();
46
- var (statusCode, response) = _requestHandler(context.Request.Url!.AbsoluteUri);
46
+ var (statusCode, response) = _requestHandler(context.Request.HttpMethod, context.Request.Url!.AbsoluteUri);
47
47
  context.Response.StatusCode = statusCode;
48
48
  await context.Response.OutputStream.WriteAsync(response);
49
49
  context.Response.Close();
@@ -53,6 +53,11 @@ namespace NuGetUpdater.Core.Test
53
53
  private static readonly object PortGate = new();
54
54
 
55
55
  public static TestHttpServer CreateTestServer(Func<string, (int, byte[])> requestHandler)
56
+ {
57
+ return CreateTestServer((method, url) => requestHandler(url));
58
+ }
59
+
60
+ public static TestHttpServer CreateTestServer(Func<string, string, (int, byte[])> requestHandler)
56
61
  {
57
62
  // static lock to ensure the port is not recycled after `FindFreePort()` and before we can start the real server
58
63
  lock (PortGate)
@@ -67,9 +72,14 @@ namespace NuGetUpdater.Core.Test
67
72
 
68
73
  public static TestHttpServer CreateTestStringServer(Func<string, (int, string)> requestHandler)
69
74
  {
70
- Func<string, (int, byte[])> bytesRequestHandler = url =>
75
+ return CreateTestStringServer((method, url) => requestHandler(url));
76
+ }
77
+
78
+ public static TestHttpServer CreateTestStringServer(Func<string, string, (int, string)> requestHandler)
79
+ {
80
+ Func<string, string, (int, byte[])> bytesRequestHandler = (method, url) =>
71
81
  {
72
- var (statusCode, response) = requestHandler(url);
82
+ var (statusCode, response) = requestHandler(method, url);
73
83
  return (statusCode, Encoding.UTF8.GetBytes(response));
74
84
  };
75
85
  return CreateTestServer(bytesRequestHandler);
@@ -170,7 +180,7 @@ namespace NuGetUpdater.Core.Test
170
180
  return (404, Encoding.UTF8.GetBytes("{}"));
171
181
  }
172
182
 
173
- var server = TestHttpServer.CreateTestServer(HttpHandler);
183
+ var server = CreateTestServer((method, url) => HttpHandler(url));
174
184
  return server;
175
185
  }
176
186
 
@@ -31,6 +31,8 @@ public class SpecialFilePatcherTests
31
31
 
32
32
  public static IEnumerable<object[]> SpecialImportsConditionPatcherTestData()
33
33
  {
34
+ // magic file names
35
+
34
36
  // one-off test to verify namespaces don't interfere
35
37
  yield return
36
38
  [
@@ -95,5 +97,22 @@ public class SpecialFilePatcherTests
95
97
  </Project>
96
98
  """
97
99
  ];
100
+
101
+ // magic property segments
102
+ yield return
103
+ [
104
+ // fileContent
105
+ """
106
+ <Project>
107
+ <Import Project="$(PkgSome_Package)\build\Some.Package.targets" />
108
+ </Project>
109
+ """,
110
+ // expectedPatchedContent
111
+ """
112
+ <Project>
113
+ <Import Project="$(PkgSome_Package)\build\Some.Package.targets" Condition="false" />
114
+ </Project>
115
+ """
116
+ ];
98
117
  }
99
118
  }
@@ -0,0 +1,66 @@
1
+ using NuGetUpdater.Core.Utilities;
2
+
3
+ using Xunit;
4
+
5
+ namespace NuGetUpdater.Core.Test.Utilities;
6
+
7
+ public class BOMHandlingTests
8
+ {
9
+ [Theory]
10
+ [MemberData(nameof(HasBOMTestData))]
11
+ public void HasBOM(byte[] content, bool expectedHasBOM)
12
+ {
13
+ var actualHasBOM = content.HasBOM();
14
+ Assert.Equal(expectedHasBOM, actualHasBOM);
15
+ }
16
+
17
+ [Theory]
18
+ [MemberData(nameof(SetBOMTestData))]
19
+ public void SetBOM(string content, bool setBOM, byte[] expectedBytes)
20
+ {
21
+ var actualBytes = content.SetBOM(setBOM);
22
+ AssertEx.Equal(expectedBytes, actualBytes);
23
+ }
24
+
25
+ public static IEnumerable<object[]> HasBOMTestData()
26
+ {
27
+ yield return
28
+ [
29
+ // content
30
+ new byte[] { 0xEF, 0xBB, 0xBF, (byte)'A' },
31
+ // expectedHasBOM
32
+ true
33
+ ];
34
+
35
+ yield return
36
+ [
37
+ // content
38
+ new byte[] { (byte)'A' },
39
+ // expectedHasBOM
40
+ false
41
+ ];
42
+ }
43
+
44
+ public static IEnumerable<object[]> SetBOMTestData()
45
+ {
46
+ yield return
47
+ [
48
+ // content
49
+ "A",
50
+ // setBOM
51
+ true,
52
+ // expectedBytes
53
+ new byte[] { 0xEF, 0xBB, 0xBF, (byte)'A' }
54
+ ];
55
+
56
+ yield return
57
+ [
58
+ // content
59
+ "A",
60
+ // setBOM
61
+ false,
62
+ // expectedBytes
63
+ new byte[] { (byte)'A' }
64
+ ];
65
+ }
66
+ }
@@ -4,20 +4,234 @@ using Xunit;
4
4
 
5
5
  using static NuGetUpdater.Core.Utilities.EOLHandling;
6
6
 
7
- namespace NuGetUpdater.Core.Test.Utilities
7
+ namespace NuGetUpdater.Core.Test.Utilities;
8
+
9
+ public class EOLHandlingTests
8
10
  {
9
- public class EOLHandlingTests
11
+ [Theory]
12
+ [InlineData(EOLType.LF, "\n")]
13
+ [InlineData(EOLType.CR, "\r")]
14
+ [InlineData(EOLType.CRLF, "\r\n")]
15
+ public void ValidateEOLNormalizesFromLF(EOLType eolType, string literal)
16
+ {
17
+ var teststring = "this\ris\na\r\nstring\rwith\nmixed\r\nline\rendings\n.";
18
+ var changed = teststring.SetEOL(eolType);
19
+ var lineEndings = Regex.Split(changed, "\\S+");
20
+ Assert.All(lineEndings, lineEnding => lineEnding.Equals(literal));
21
+ }
22
+
23
+ [Theory]
24
+ [MemberData(nameof(GetPredominantEOLTestData))]
25
+ public void GetPredominantEOL(string fileContent, EOLType expectedEOL)
26
+ {
27
+ var actualEOL = fileContent.GetPredominantEOL();
28
+ Assert.Equal(expectedEOL, actualEOL);
29
+ }
30
+
31
+ [Theory]
32
+ [MemberData(nameof(SetEOLTestData))]
33
+ public void SetEOL(string currentFileContent, EOLType desiredEOL, string expectedFileContent)
34
+ {
35
+ var actualFileContent = currentFileContent.SetEOL(desiredEOL);
36
+ Assert.Equal(expectedFileContent, actualFileContent);
37
+ }
38
+
39
+ public static IEnumerable<object[]> GetPredominantEOLTestData()
10
40
  {
11
- [Theory]
12
- [InlineData(EOLType.LF, "\n")]
13
- [InlineData(EOLType.CR, "\r")]
14
- [InlineData(EOLType.CRLF, "\r\n")]
15
- public void ValidateEOLNormalizesFromLF(EOLType eolType, string literal)
16
- {
17
- var teststring = "this\ris\na\r\nstring\rwith\nmixed\r\nline\rendings\n.";
18
- var changed = teststring.SetEOL(eolType);
19
- var lineEndings = Regex.Split(changed, "\\S+");
20
- Assert.All(lineEndings, lineEnding => lineEnding.Equals(literal));
21
- }
41
+ // purely CR
42
+ yield return
43
+ [
44
+ // fileContent
45
+ string.Concat(
46
+ "line1\r",
47
+ "line2\r",
48
+ "line3\r"
49
+ ),
50
+ // expectedEOL
51
+ EOLType.CR
52
+ ];
53
+
54
+ // purely LF
55
+ yield return
56
+ [
57
+ // fileContent
58
+ string.Concat(
59
+ "line1\n",
60
+ "line2\n",
61
+ "line3\n"
62
+ ),
63
+ // expectedEOL
64
+ EOLType.LF
65
+ ];
66
+
67
+ // purely CRLF
68
+ yield return
69
+ [
70
+ // fileContent
71
+ string.Concat(
72
+ "line1\r\n",
73
+ "line2\r\n",
74
+ "line3\r\n"
75
+ ),
76
+ // expectedEOL
77
+ EOLType.CRLF
78
+ ];
79
+
80
+ // mostly CR
81
+ yield return
82
+ [
83
+ // fileContent
84
+ string.Concat(
85
+ "line1\r",
86
+ "line2\n",
87
+ "line3\r"
88
+ ),
89
+ // expectedEOL
90
+ EOLType.CR
91
+ ];
92
+
93
+ // mostly LF
94
+ yield return
95
+ [
96
+ // fileContent
97
+ string.Concat(
98
+ "line1\n",
99
+ "line2\r",
100
+ "line3\n"
101
+ ),
102
+ // expectedEOL
103
+ EOLType.LF
104
+ ];
105
+
106
+ // mostly CRLF
107
+ yield return
108
+ [
109
+ // fileContent
110
+ string.Concat(
111
+ "line1\r\n",
112
+ "line2\n",
113
+ "line3\r",
114
+ "line4\r\n"
115
+ ),
116
+ // expectedEOL
117
+ EOLType.CRLF
118
+ ];
119
+ }
120
+
121
+ public static IEnumerable<object[]> SetEOLTestData()
122
+ {
123
+ // CR to CR
124
+ yield return
125
+ [
126
+ // currentFileContent
127
+ string.Concat(
128
+ "line1\r",
129
+ "line2\r",
130
+ "line3\r"
131
+ ),
132
+ // desiredEOL
133
+ EOLType.CR,
134
+ // expectedFileContent
135
+ string.Concat(
136
+ "line1\r",
137
+ "line2\r",
138
+ "line3\r"
139
+ )
140
+ ];
141
+
142
+ // LF to LF
143
+ yield return
144
+ [
145
+ // currentFileContent
146
+ string.Concat(
147
+ "line1\n",
148
+ "line2\n",
149
+ "line3\n"
150
+ ),
151
+ // desiredEOL
152
+ EOLType.LF,
153
+ // expectedFileContent
154
+ string.Concat(
155
+ "line1\n",
156
+ "line2\n",
157
+ "line3\n"
158
+ )
159
+ ];
160
+
161
+ // CRLF to CRLF
162
+ yield return
163
+ [
164
+ // currentFileContent
165
+ string.Concat(
166
+ "line1\r\n",
167
+ "line2\r\n",
168
+ "line3\r\n"
169
+ ),
170
+ // desiredEOL
171
+ EOLType.CRLF,
172
+ // expectedFileContent
173
+ string.Concat(
174
+ "line1\r\n",
175
+ "line2\r\n",
176
+ "line3\r\n"
177
+ )
178
+ ];
179
+
180
+ // mixed to CR
181
+ yield return
182
+ [
183
+ // currentFileContent
184
+ string.Concat(
185
+ "line1\r",
186
+ "line2\n",
187
+ "line3\r\n"
188
+ ),
189
+ // desiredEOL
190
+ EOLType.CR,
191
+ // expectedFileContent
192
+ string.Concat(
193
+ "line1\r",
194
+ "line2\r",
195
+ "line3\r"
196
+ )
197
+ ];
198
+
199
+ // mixed to LF
200
+ yield return
201
+ [
202
+ // currentFileContent
203
+ string.Concat(
204
+ "line1\r",
205
+ "line2\n",
206
+ "line3\r\n"
207
+ ),
208
+ // desiredEOL
209
+ EOLType.LF,
210
+ // expectedFileContent
211
+ string.Concat(
212
+ "line1\n",
213
+ "line2\n",
214
+ "line3\n"
215
+ )
216
+ ];
217
+
218
+ // mixed to CRLF
219
+ yield return
220
+ [
221
+ // currentFileContent
222
+ string.Concat(
223
+ "line1\r",
224
+ "line2\n",
225
+ "line3\r\n"
226
+ ),
227
+ // desiredEOL
228
+ EOLType.CRLF,
229
+ // expectedFileContent
230
+ string.Concat(
231
+ "line1\r\n",
232
+ "line2\r\n",
233
+ "line3\r\n"
234
+ )
235
+ ];
22
236
  }
23
237
  }