diff --git a/src/Imageflow/Bindings/NativeLibraryLoading.cs b/src/Imageflow/Bindings/NativeLibraryLoading.cs index c17849f..fbf6453 100644 --- a/src/Imageflow/Bindings/NativeLibraryLoading.cs +++ b/src/Imageflow/Bindings/NativeLibraryLoading.cs @@ -4,6 +4,7 @@ using System.Runtime.InteropServices; using System.Security; using System.Text; +using Imageflow.Internal.Helpers; #if !NET8_0_OR_GREATER using System.Reflection; #endif @@ -31,6 +32,7 @@ private struct LogEntry public void NotifyAttempt(string basename, string? fullPath, bool fileExists, bool previouslyLoaded, int? loadErrorCode) { + Argument.ThrowIfNull(basename); _log.Add(new LogEntry { Basename = basename, @@ -43,7 +45,7 @@ public void NotifyAttempt(string basename, string? fullPath, bool fileExists, bo internal void RaiseException() { - var sb = new StringBuilder(_log.Select((e) => e.Basename?.Length ?? 0 + e.FullPath?.Length ?? 0 + 20) + var sb = new StringBuilder(_log.Select((e) => e.Basename.Length + (e.FullPath?.Length ?? 0) + 20) .Sum()); sb.AppendFormat(CultureInfo.InvariantCulture, "Looking for \"{0}\" RID=\"{1}-{2}\", IsUnix={3}, IsDotNetCore={4} RelativeSearchPath=\"{5}\"\n", Filename, @@ -368,10 +370,7 @@ private static string GetFilenameWithoutDirectory(string basename) => RuntimeFil internal static bool TryLoadByBasename(string basename, ILibraryLoadLogger log, out string? exePath, IEnumerable? customSearchDirectories = null) { - if (string.IsNullOrEmpty(basename)) - { - throw new ArgumentNullException(nameof(basename)); - } + Argument.ThrowIfNull(basename); if (ExecutablePathsByName.Value.TryGetValue(basename, out exePath)) { diff --git a/src/Imageflow/IO/ProcessEx.cs b/src/Imageflow/IO/ProcessEx.cs index 00b0b4f..efafb14 100644 --- a/src/Imageflow/IO/ProcessEx.cs +++ b/src/Imageflow/IO/ProcessEx.cs @@ -100,9 +100,9 @@ public static async Task RunAsync(ProcessStartInfo processStartI } }; - process.Exited += (sender, args) => + process.Exited += (_, args) => { - // Since the Exited event can happen asynchronously to the output and error events, + // Since the Exited event can happen asynchronously to the output and error events, // we use the task results for stdout/stderr to ensure they both closed tcs.TrySetResult(new ProcessResults(process, standardOutputResults.Task.Result, standardErrorResults.Task.Result)); }; diff --git a/tests/Imageflow.Test/TestApi.cs b/tests/Imageflow.Test/TestApi.cs index 6aeed4b..cba1968 100644 --- a/tests/Imageflow.Test/TestApi.cs +++ b/tests/Imageflow.Test/TestApi.cs @@ -402,7 +402,7 @@ public async Task TestFilesystemJobPrep() else { #pragma warning disable CA1416 - using (var file = System.IO.MemoryMappedFiles.MemoryMappedFile.OpenExisting(jsonPath)) + using (var _ = System.IO.MemoryMappedFiles.MemoryMappedFile.OpenExisting(jsonPath)) #pragma warning restore CA1416 { } // Will throw filenotfoundexception if missing @@ -416,11 +416,11 @@ public async Task TestFilesystemJobPrep() else { - Assert.Throws(delegate () + Assert.Throws(delegate { #pragma warning disable CA1416 - using (var file = System.IO.MemoryMappedFiles.MemoryMappedFile.OpenExisting(jsonPath)) + using (var _ = System.IO.MemoryMappedFiles.MemoryMappedFile.OpenExisting(jsonPath)) #pragma warning restore CA1416 { } @@ -473,7 +473,7 @@ public async Task TestCustomDownscalingAndDecodeEncodeResults() Assert.Equal(5, r.First!.Width); Assert.True(r.First.TryGetBytes().HasValue); - Assert.Equal(1, r.DecodeResults.First()!.Width); + Assert.Equal(1, r.DecodeResults.First().Width); Assert.Equal(1, r.DecodeResults.First().Height); Assert.Equal("png", r.DecodeResults.First().PreferredExtension); Assert.Equal("image/png", r.DecodeResults.First().PreferredMimeType); diff --git a/tests/Imageflow.TestWebAOT/Program.cs b/tests/Imageflow.TestWebAOT/Program.cs index cf3edbe..1d7c928 100644 --- a/tests/Imageflow.TestWebAOT/Program.cs +++ b/tests/Imageflow.TestWebAOT/Program.cs @@ -32,7 +32,7 @@ using var c = new JobContext(); var _ = c.GetVersionInfo(); var t = Helpers.SizeIcon(10); -var _2 = t.Result; +var unused = t.Result; app.Run();