Skip to content

Commit 787b250

Browse files
fix compiler warnings for it project (#1950)
1 parent 3d8a737 commit 787b250

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.IntegrationTests/HttpContextExtensionsTests.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ private async Task RunApiGatewayTest<T>(HttpContextTestCase testCase, string api
172172

173173
CompareApiGatewayRequests(expectedApiGatewayRequest, actualApiGatewayRequest);
174174

175-
testCase.Assertions(actualApiGatewayRequest, emulatorMode);
175+
testCase.Assertions(actualApiGatewayRequest!, emulatorMode);
176176

177177
await Task.Delay(1000); // Small delay between requests
178178
}
179179

180180

181-
private void CompareApiGatewayRequests<T>(T expected, T actual) where T : class
181+
private void CompareApiGatewayRequests<T>(T expected, T actual) where T : class?
182182
{
183183
if (expected is APIGatewayProxyRequest v1Expected && actual is APIGatewayProxyRequest v1Actual)
184184
{
@@ -261,23 +261,25 @@ private void CompareMultiValueHeaders(IDictionary<string, IList<string>> expecte
261261
}
262262
}
263263

264-
private IDictionary<TKey, TValue> FilterHeaders<TKey, TValue>(IDictionary<TKey, TValue> headers)
264+
private IDictionary<TKey, TValue> FilterHeaders<TKey, TValue>(IDictionary<TKey, TValue> headers) where TKey : notnull
265265
{
266266
return headers.Where(kvp =>
267-
!(kvp.Key.ToString().StartsWith("x-forwarded-", StringComparison.OrdinalIgnoreCase) || // ignore these for now
268-
kvp.Key.ToString().StartsWith("cloudfront-", StringComparison.OrdinalIgnoreCase) || // ignore these for now
269-
kvp.Key.ToString().StartsWith("via-", StringComparison.OrdinalIgnoreCase) || // ignore these for now
270-
kvp.Key.ToString().Equals("x-amzn-trace-id", StringComparison.OrdinalIgnoreCase) || // this is dynamic so ignoring for now
271-
kvp.Key.ToString().Equals("cookie", StringComparison.OrdinalIgnoreCase) || // TODO may have to have api gateway v2 not set this in headers
272-
kvp.Key.ToString().Equals("host", StringComparison.OrdinalIgnoreCase))) // TODO we may want to set this
267+
!(kvp.Key.ToString()!.StartsWith("x-forwarded-", StringComparison.OrdinalIgnoreCase) || // ignore these for now
268+
kvp.Key.ToString()!.StartsWith("cloudfront-", StringComparison.OrdinalIgnoreCase) || // ignore these for now
269+
kvp.Key.ToString()!.StartsWith("via-", StringComparison.OrdinalIgnoreCase) || // ignore these for now
270+
kvp.Key.ToString()!.Equals("x-amzn-trace-id", StringComparison.OrdinalIgnoreCase) || // this is dynamic so ignoring for now
271+
kvp.Key.ToString()!.Equals("cookie", StringComparison.OrdinalIgnoreCase) || // TODO may have to have api gateway v2 not set this in headers
272+
kvp.Key.ToString()!.Equals("host", StringComparison.OrdinalIgnoreCase))) // TODO we may want to set this
273273
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
274274
}
275275

276276

277-
private void CompareDictionaries<TKey, TValue>(IDictionary<TKey, TValue> expected, IDictionary<TKey, TValue> actual)
277+
private void CompareDictionaries<TKey, TValue>(IDictionary<TKey, TValue>? expected, IDictionary<TKey, TValue>? actual)
278278
{
279279
if (expected == null && actual == null) return;
280-
Assert.Equal(expected.Count, actual.Count);
280+
if (expected == null && actual != null) Assert.Fail();
281+
if (expected != null && actual == null) Assert.Fail();
282+
Assert.Equal(expected!.Count, actual!.Count);
281283

282284
foreach (var kvp in expected)
283285
{
@@ -291,7 +293,7 @@ private void CompareStringArrays(string[] expected, string[] actual)
291293
Assert.Equal(expected?.Length, actual?.Length);
292294
if (expected != null)
293295
{
294-
Assert.Equal(expected.OrderBy(x => x), actual.OrderBy(x => x));
296+
Assert.Equal(expected.OrderBy(x => x), actual?.OrderBy(x => x));
295297
}
296298
}
297299

Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/PackagingTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void VerifyPackageContentsHasRuntimeSupport()
9494

9595
Assert.Equal(0, packProcess.ExitCode);
9696

97-
var packageDir = Path.Combine(Path.GetDirectoryName(projectPath), "bin", "Release");
97+
var packageDir = Path.Combine(Path.GetDirectoryName(projectPath)!, "bin", "Release");
9898
_output.WriteLine($"Looking for package in: {packageDir}");
9999

100100
var packageFiles = Directory.GetFiles(packageDir, "*.nupkg", SearchOption.AllDirectories);
@@ -143,7 +143,7 @@ public void VerifyPackageContentsHasRuntimeSupport()
143143
private string FindSolutionRoot()
144144
{
145145
Console.WriteLine("Looking for solution root...");
146-
string currentDirectory = Directory.GetCurrentDirectory();
146+
string? currentDirectory = Directory.GetCurrentDirectory();
147147
while (currentDirectory != null)
148148
{
149149
// Look for the aws-lambda-dotnet directory specifically

0 commit comments

Comments
 (0)