Skip to content

Commit

Permalink
Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Mar 8, 2024
1 parent 9b90b5f commit 7b8e19d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/Imageflow/Bindings/NativeLibraryLoading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -368,10 +370,7 @@ private static string GetFilenameWithoutDirectory(string basename) => RuntimeFil
internal static bool TryLoadByBasename(string basename, ILibraryLoadLogger log, out string? exePath,
IEnumerable<string>? customSearchDirectories = null)
{
if (string.IsNullOrEmpty(basename))
{
throw new ArgumentNullException(nameof(basename));
}
Argument.ThrowIfNull(basename);

if (ExecutablePathsByName.Value.TryGetValue(basename, out exePath))
{
Expand Down
4 changes: 2 additions & 2 deletions src/Imageflow/IO/ProcessEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public static async Task<ProcessResults> 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));
};
Expand Down
8 changes: 4 additions & 4 deletions tests/Imageflow.Test/TestApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -416,11 +416,11 @@ public async Task TestFilesystemJobPrep()
else
{

Assert.Throws<FileNotFoundException>(delegate ()
Assert.Throws<FileNotFoundException>(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
{
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Imageflow.TestWebAOT/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 7b8e19d

Please sign in to comment.