From b43deb9cb882f05eb77250ec28187a6d24acfdba Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Thu, 27 Jan 2022 23:04:05 +0200 Subject: [PATCH] Target netstandard2.1 and net5.0 in ImageCore --- ConsoleInterface/ConsoleInterface.csproj | 4 ++-- ImageCore.Tests/ImageCore.Tests.csproj | 5 +++-- ImageCore.Tests/TestKeepFilenameFormatter.cs | 1 - ImageCore/Compressor/ICompressor.cs | 2 +- ImageCore/Compressor/LosslessCompressor.cs | 2 +- ImageCore/Compressor/NullCompressor.cs | 2 +- ImageCore/ImageCore.csproj | 4 ++-- ImageCore/Output/KeepFilenameFormatter.cs | 9 +++++---- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ConsoleInterface/ConsoleInterface.csproj b/ConsoleInterface/ConsoleInterface.csproj index ac39ed4..6e3dcff 100644 --- a/ConsoleInterface/ConsoleInterface.csproj +++ b/ConsoleInterface/ConsoleInterface.csproj @@ -1,13 +1,13 @@ - Exe - net5.0 metadata_remover true true win-x64 true + net5.0;netstandard2.1 + 7.3 diff --git a/ImageCore.Tests/ImageCore.Tests.csproj b/ImageCore.Tests/ImageCore.Tests.csproj index 5481d75..be62934 100644 --- a/ImageCore.Tests/ImageCore.Tests.csproj +++ b/ImageCore.Tests/ImageCore.Tests.csproj @@ -1,9 +1,10 @@ - net5.0 - false + Library + 8 + net5.0 diff --git a/ImageCore.Tests/TestKeepFilenameFormatter.cs b/ImageCore.Tests/TestKeepFilenameFormatter.cs index a109882..266d64f 100644 --- a/ImageCore.Tests/TestKeepFilenameFormatter.cs +++ b/ImageCore.Tests/TestKeepFilenameFormatter.cs @@ -1,5 +1,4 @@ using System; -using Image; using Image.Output; using Xunit; diff --git a/ImageCore/Compressor/ICompressor.cs b/ImageCore/Compressor/ICompressor.cs index a729151..c72044e 100644 --- a/ImageCore/Compressor/ICompressor.cs +++ b/ImageCore/Compressor/ICompressor.cs @@ -9,6 +9,6 @@ /// The method compresses an image in place. /// /// The file name of the image to be compressed. - public void Compress(string fileName); + void Compress(string fileName); } } \ No newline at end of file diff --git a/ImageCore/Compressor/LosslessCompressor.cs b/ImageCore/Compressor/LosslessCompressor.cs index c1d9c6e..789a963 100644 --- a/ImageCore/Compressor/LosslessCompressor.cs +++ b/ImageCore/Compressor/LosslessCompressor.cs @@ -7,7 +7,7 @@ namespace Image.Compressor /// public class LosslessCompressor : ICompressor { - public static readonly LosslessCompressor Instance = new(); + public static readonly LosslessCompressor Instance; private readonly ImageOptimizer _imageOptimizer; public LosslessCompressor() diff --git a/ImageCore/Compressor/NullCompressor.cs b/ImageCore/Compressor/NullCompressor.cs index b3f52ba..0966626 100644 --- a/ImageCore/Compressor/NullCompressor.cs +++ b/ImageCore/Compressor/NullCompressor.cs @@ -5,7 +5,7 @@ /// public class NullCompressor : ICompressor { - public static readonly NullCompressor Instance = new(); + public static readonly NullCompressor Instance; /// /// diff --git a/ImageCore/ImageCore.csproj b/ImageCore/ImageCore.csproj index 5bfe816..d325666 100644 --- a/ImageCore/ImageCore.csproj +++ b/ImageCore/ImageCore.csproj @@ -1,12 +1,12 @@ - net5.0 Image + net5.0;netstandard2.1 - + diff --git a/ImageCore/Output/KeepFilenameFormatter.cs b/ImageCore/Output/KeepFilenameFormatter.cs index d132ea1..1f4c337 100644 --- a/ImageCore/Output/KeepFilenameFormatter.cs +++ b/ImageCore/Output/KeepFilenameFormatter.cs @@ -1,5 +1,5 @@ using System.IO; -using GuardNet; +using Ardalis.GuardClauses; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -35,9 +35,10 @@ namespace Image.Output public string GetOutputPath(string initialFilePath) { Logger.LogDebug($"KeepFilenameFormatter - {_outputDirectory} - {initialFilePath}"); - Guard.NotNullOrEmpty(initialFilePath, nameof(initialFilePath)); - var fileName = Path.GetFileName(initialFilePath)?.Split(".")[0]; - var path = Path.Join(_outputDirectory, $"{fileName}.jpg"); + Guard.Against.NullOrEmpty(initialFilePath, nameof(initialFilePath)); + var fileName = Path.GetFileName(initialFilePath)?.Split('.')[0]; + var path = Path.Combine(_outputDirectory, $"{fileName}.jpg"); + return path; }