From 627c34ac02652bd63f126f435e4f24001a3e55ad Mon Sep 17 00:00:00 2001 From: Lilith River Date: Tue, 27 Feb 2024 03:08:14 -0700 Subject: [PATCH] Nullability fixes --- src/Imazen.Routing/Layers/Licensing.cs | 4 ++-- tests/Imageflow.Server.Tests/IntegrationTest.cs | 6 +++--- tests/Imageflow.Server.Tests/TempContentRoot.cs | 2 +- tests/Imageflow.Server.Tests/TestLicensing.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Imazen.Routing/Layers/Licensing.cs b/src/Imazen.Routing/Layers/Licensing.cs index b00da772..894278c8 100644 --- a/src/Imazen.Routing/Layers/Licensing.cs +++ b/src/Imazen.Routing/Layers/Licensing.cs @@ -16,12 +16,12 @@ public class LicenseOptions{ internal class Licensing : ILicenseConfig, ILicenseChecker, IHasDiagnosticPageSection { - private readonly Func? getCurrentRequestUrl; + private readonly Func? getCurrentRequestUrl; private readonly LicenseManagerSingleton mgr; private Computation? cachedResult; - internal Licensing(LicenseManagerSingleton mgr, Func? getCurrentRequestUrl = null) + internal Licensing(LicenseManagerSingleton mgr, Func? getCurrentRequestUrl = null) { this.mgr = mgr; this.getCurrentRequestUrl = getCurrentRequestUrl; diff --git a/tests/Imageflow.Server.Tests/IntegrationTest.cs b/tests/Imageflow.Server.Tests/IntegrationTest.cs index 3d2212a4..425e5e1e 100644 --- a/tests/Imageflow.Server.Tests/IntegrationTest.cs +++ b/tests/Imageflow.Server.Tests/IntegrationTest.cs @@ -106,15 +106,15 @@ await Assert.ThrowsAsync(async () => using var wrongImageExtension1 = await client.GetAsync("/wrong.webp"); wrongImageExtension1.EnsureSuccessStatusCode(); - Assert.Equal("image/png", wrongImageExtension1.Content.Headers.ContentType.MediaType); + Assert.Equal("image/png", wrongImageExtension1.Content.Headers.ContentType?.MediaType); using var wrongImageExtension2 = await client.GetAsync("/wrong.jpg"); wrongImageExtension2.EnsureSuccessStatusCode(); - Assert.Equal("image/png", wrongImageExtension2.Content.Headers.ContentType.MediaType); + Assert.Equal("image/png", wrongImageExtension2.Content.Headers.ContentType?.MediaType); using var extensionlessRequest = await client.GetAsync("/extensionless/file"); extensionlessRequest.EnsureSuccessStatusCode(); - Assert.Equal("image/png", extensionlessRequest.Content.Headers.ContentType.MediaType); + Assert.Equal("image/png", extensionlessRequest.Content.Headers.ContentType?.MediaType); using var response2 = await client.GetAsync("/fire.jpg?width=1"); diff --git a/tests/Imageflow.Server.Tests/TempContentRoot.cs b/tests/Imageflow.Server.Tests/TempContentRoot.cs index f4e524f4..89bbf162 100644 --- a/tests/Imageflow.Server.Tests/TempContentRoot.cs +++ b/tests/Imageflow.Server.Tests/TempContentRoot.cs @@ -26,7 +26,7 @@ public TempContentRoot AddResource(string relativePath, string resourceName) using var reader = embeddedProvider.GetFileInfo(resourceName).CreateReadStream(); var newFilePath = Path.Combine(PhysicalPath, relativePath.Replace('/', Path.DirectorySeparatorChar)); var parentDir = Path.GetDirectoryName(newFilePath); - if (!Directory.Exists(parentDir)) + if (parentDir != null && !Directory.Exists(parentDir)) Directory.CreateDirectory(parentDir); using var newFile = File.Create(newFilePath); reader.CopyTo(newFile); diff --git a/tests/Imageflow.Server.Tests/TestLicensing.cs b/tests/Imageflow.Server.Tests/TestLicensing.cs index 91be9006..18183ef5 100644 --- a/tests/Imageflow.Server.Tests/TestLicensing.cs +++ b/tests/Imageflow.Server.Tests/TestLicensing.cs @@ -14,8 +14,8 @@ namespace Imageflow.Server.Tests { class RequestUrlProvider { - public Uri Url { get; set; } = null; - public Uri Get() => Url; + public Uri? Url { get; set; } + public Uri? Get() => Url; } public class TestLicensing