diff --git a/appveyor.yml b/appveyor.yml index d98fa9c6a..3e6b79bfc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,18 +1,16 @@ version: 1.0.0.{build} -image: Visual Studio 2017 Preview +image: Visual Studio 2017 # prevent the double build when a branch has an active PR skip_branch_with_pr: true environment: matrix: - ### TODO: Enable the netcoreapp2.1 target when RC2 has been released! - - #- target_framework: netcoreapp2.1 - # is_32bit: False + - target_framework: netcoreapp2.1 + is_32bit: False - #- target_framework: netcoreapp2.1 - # is_32bit: True + - target_framework: netcoreapp2.1 + is_32bit: True - target_framework: netcoreapp2.0 is_32bit: False diff --git a/run-tests.ps1 b/run-tests.ps1 index d774f7a61..3218d9d67 100644 --- a/run-tests.ps1 +++ b/run-tests.ps1 @@ -75,6 +75,11 @@ else { $xunitArgs += " --fx-version 2.0.0" } + if ($targetFramework -eq "netcoreapp2.1") { + # There were issues matching the correct installed runtime if we do not specify it explicitly: + $xunitArgs += " --fx-version 2.1.0" + } + if ($is32Bit -eq "True") { $xunitArgs += " -x86" } diff --git a/src/ImageSharp/Common/Extensions/StreamExtensions.cs b/src/ImageSharp/Common/Extensions/StreamExtensions.cs index 7a9a34ac1..d11ba8ca5 100644 --- a/src/ImageSharp/Common/Extensions/StreamExtensions.cs +++ b/src/ImageSharp/Common/Extensions/StreamExtensions.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Buffers; +using System; using System.IO; namespace SixLabors.ImageSharp @@ -11,6 +11,33 @@ namespace SixLabors.ImageSharp /// internal static class StreamExtensions { +#if NETCOREAPP2_1 + /// + /// Writes data from a stream into the provided buffer. + /// + /// The stream. + /// The buffer. + /// The offset within the buffer to begin writing. + /// The number of bytes to write to the stream. + public static void Write(this Stream stream, Span buffer, int offset, int count) + { + stream.Write(buffer.Slice(offset, count)); + } + + /// + /// Reads data from a stream into the provided buffer. + /// + /// The stream. + /// The buffer.. + /// The offset within the buffer where the bytes are read into. + /// The number of bytes, if available, to read. + /// The actual number of bytes read. + public static int Read(this Stream stream, Span buffer, int offset, int count) + { + return stream.Read(buffer.Slice(offset, count)); + } +#endif + /// /// Skips the number of bytes in the given stream. /// diff --git a/src/ImageSharp/Common/Helpers/TestHelpers.cs b/src/ImageSharp/Common/Helpers/TestHelpers.cs new file mode 100644 index 000000000..14e5835b4 --- /dev/null +++ b/src/ImageSharp/Common/Helpers/TestHelpers.cs @@ -0,0 +1,24 @@ +// Copyright(c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.Common.Helpers +{ + /// + /// Internal utilities intended to be only used in tests. + /// + internal static class TestHelpers + { + /// + /// This constant is useful to verify the target framework ImageSharp has been built against. + /// Only intended to be used in tests! + /// + internal const string ImageSharpBuiltAgainst = +#if NETSTANDARD1_1 + "netstandard1.1"; +#elif NETCOREAPP2_1 + "netcoreapp2.1"; +#else + "netstandard2.0"; +#endif + } +} \ No newline at end of file diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index dd092e643..2ddf4ace4 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System; +using System.Buffers.Binary; using System.IO; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.MetaData; @@ -251,7 +252,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// Buffer for uncompressed data. private void UncompressRle8(int w, Span buffer) { +#if NETCOREAPP2_1 + Span cmd = stackalloc byte[2]; +#else byte[] cmd = new byte[2]; +#endif int count = 0; while (count < buffer.Length) @@ -475,12 +480,14 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// private void ReadInfoHeader() { +#if NETCOREAPP2_1 + Span buffer = stackalloc byte[BmpInfoHeader.MaxHeaderSize]; +#else byte[] buffer = new byte[BmpInfoHeader.MaxHeaderSize]; +#endif + this.stream.Read(buffer, 0, BmpInfoHeader.HeaderSizeSize); // read the header size - // read header size - this.stream.Read(buffer, 0, BmpInfoHeader.HeaderSizeSize); - - int headerSize = BitConverter.ToInt32(buffer, 0); + int headerSize = BinaryPrimitives.ReadInt32LittleEndian(buffer); if (headerSize < BmpInfoHeader.CoreSize) { throw new NotSupportedException($"ImageSharp does not support this BMP file. HeaderSize: {headerSize}."); @@ -504,7 +511,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp else if (headerSize >= BmpInfoHeader.Size) { // >= 40 bytes - this.infoHeader = BmpInfoHeader.Parse(buffer.AsSpan(0, 40)); + this.infoHeader = BmpInfoHeader.Parse(buffer); } else { @@ -520,8 +527,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// private void ReadFileHeader() { +#if NETCOREAPP2_1 + Span buffer = stackalloc byte[BmpFileHeader.Size]; +#else byte[] buffer = new byte[BmpFileHeader.Size]; - +#endif this.stream.Read(buffer, 0, BmpFileHeader.Size); this.fileHeader = BmpFileHeader.Parse(buffer); diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 1864737c8..a4e61f910 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -66,8 +66,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp reserved: 0, fileSize: 54 + infoHeader.ImageSize); - byte[] buffer = new byte[40]; // TODO: stackalloc - +#if NETCOREAPP2_1 + Span buffer = stackalloc byte[40]; +#else + byte[] buffer = new byte[40]; +#endif fileHeader.WriteTo(buffer); stream.Write(buffer, 0, BmpFileHeader.Size); diff --git a/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs b/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs index a70716a85..4dd63a962 100644 --- a/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs +++ b/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs @@ -132,6 +132,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// public static BmpInfoHeader Parse(ReadOnlySpan data) { + if (data.Length != Size) + { + throw new ArgumentException(nameof(data), $"Must be {Size} bytes. Was {data.Length} bytes."); + } + return MemoryMarshal.Cast(data)[0]; } diff --git a/src/ImageSharp/Formats/Gif/LzwDecoder.cs b/src/ImageSharp/Formats/Gif/LzwDecoder.cs index 977870936..35eb43a8a 100644 --- a/src/ImageSharp/Formats/Gif/LzwDecoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwDecoder.cs @@ -112,7 +112,12 @@ namespace SixLabors.ImageSharp.Formats.Gif Unsafe.Add(ref suffixRef, code) = (byte)code; } +#if NETCOREAPP2_1 + Span buffer = stackalloc byte[255]; +#else byte[] buffer = new byte[255]; +#endif + while (xyz < length) { if (top == 0) @@ -221,15 +226,21 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] +#if NETCOREAPP2_1 + private int ReadBlock(Span buffer) +#else private int ReadBlock(byte[] buffer) +#endif { int bufferSize = this.stream.ReadByte(); + if (bufferSize < 1) { return 0; } int count = this.stream.Read(buffer, 0, bufferSize); + return count != bufferSize ? 0 : bufferSize; } diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index 37279d526..9ffd40c93 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System; using System.IO; using System.Runtime.CompilerServices; @@ -736,16 +737,16 @@ namespace SixLabors.ImageSharp.Formats.Jpeg private void WriteStartOfFrame(int width, int height, int componentCount) { // "default" to 4:2:0 - byte[] subsamples = { 0x22, 0x11, 0x11 }; - byte[] chroma = { 0x00, 0x01, 0x01 }; + Span subsamples = stackalloc byte[] { 0x22, 0x11, 0x11 }; + Span chroma = stackalloc byte[] { 0x00, 0x01, 0x01 }; switch (this.subsample) { case JpegSubsample.Ratio444: - subsamples = new byte[] { 0x11, 0x11, 0x11 }; + subsamples = stackalloc byte[] { 0x11, 0x11, 0x11 }; break; case JpegSubsample.Ratio420: - subsamples = new byte[] { 0x22, 0x11, 0x11 }; + subsamples = stackalloc byte[] { 0x22, 0x11, 0x11 }; break; } diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 777c5016c..b40884f4b 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -5,7 +5,7 @@ $(packageversion) 0.0.1 Six Labors and contributors - netstandard1.1;netstandard1.3;netstandard2.0 + netstandard1.1;netstandard1.3;netstandard2.0;netcoreapp2.1 true true SixLabors.ImageSharp @@ -29,7 +29,7 @@ portable True IOperation - 7.2 + 7.3 @@ -40,13 +40,21 @@ All + + + + + + + - - + + + diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifConstants.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifConstants.cs new file mode 100644 index 000000000..cca53ba43 --- /dev/null +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifConstants.cs @@ -0,0 +1,21 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.MetaData.Profiles.Exif +{ + internal static class ExifConstants + { + public static readonly byte[] Header = { + (byte)'E', + (byte)'x', + (byte)'i', + (byte)'f', + 0x00, + 0x00, + (byte)'I', + (byte)'I', + 0x2A, + 0x00, + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs index 4f28449d6..d3ea9743f 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs @@ -140,26 +140,25 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif private unsafe string ConvertToString(ReadOnlySpan buffer) { -#if NETSTANDARD1_1 - byte[] bytes = buffer.ToArray(); + Span nullChar = stackalloc byte[1] { 0 }; - string result = Encoding.UTF8.GetString(bytes, 0, buffer.Length); + int nullCharIndex = buffer.IndexOf(nullChar); -#else - string result; + if (nullCharIndex > -1) + { + buffer = buffer.Slice(0, nullCharIndex); + } +#if NETSTANDARD1_1 + return Encoding.UTF8.GetString(buffer.ToArray(), 0, buffer.Length); +#elif NETCOREAPP2_1 + return Encoding.UTF8.GetString(buffer); +#else fixed (byte* pointer = &MemoryMarshal.GetReference(buffer)) { - result = Encoding.UTF8.GetString(pointer, buffer.Length); + return Encoding.UTF8.GetString(pointer, buffer.Length); } #endif - int nullCharIndex = result.IndexOf('\0'); - if (nullCharIndex != -1) - { - result = result.Substring(0, nullCharIndex); - } - - return result; } /// diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs index f7363ef31..8749c0755 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs @@ -90,16 +90,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif byte[] result = new byte[length]; - result[0] = (byte)'E'; - result[1] = (byte)'x'; - result[2] = (byte)'i'; - result[3] = (byte)'f'; - result[4] = 0x00; - result[5] = 0x00; - result[6] = (byte)'I'; - result[7] = (byte)'I'; - result[8] = 0x2A; - result[9] = 0x00; + ExifConstants.Header.AsSpan().CopyTo(result); // 0-9 int i = 10; uint ifdOffset = ((uint)i - StartIndex) + 4; @@ -250,7 +241,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif return length; } - private int WriteArray(ExifValue value, byte[] destination, int offset) + private int WriteArray(ExifValue value, Span destination, int offset) { if (value.DataType == ExifDataType.Ascii) { @@ -266,7 +257,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif return newOffset; } - private int WriteData(List indexes, byte[] destination, int offset) + private int WriteData(List indexes, Span destination, int offset) { if (this.dataOffsets.Count == 0) { @@ -289,7 +280,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif return newOffset; } - private int WriteHeaders(List indexes, byte[] destination, int offset) + private int WriteHeaders(List indexes, Span destination, int offset) { this.dataOffsets = new List(); @@ -370,7 +361,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif } } - private int WriteValue(ExifValue value, byte[] destination, int offset) + private int WriteValue(ExifValue value, Span destination, int offset) { if (value.IsArray && value.DataType != ExifDataType.Ascii) { diff --git a/src/ImageSharp/PixelFormats/Rgba1010102.cs b/src/ImageSharp/PixelFormats/Rgba1010102.cs index 166936d5e..ee4865e4e 100644 --- a/src/ImageSharp/PixelFormats/Rgba1010102.cs +++ b/src/ImageSharp/PixelFormats/Rgba1010102.cs @@ -188,7 +188,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// public override bool Equals(object obj) { - return (obj is Rgba1010102) && this.Equals((Rgba1010102)obj); + return obj is Rgba1010102 other && this.Equals(other); } /// diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs index f6979aad8..bd014a58f 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.cs @@ -387,7 +387,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// public override bool Equals(object obj) { - return (obj is Rgba32) && this.Equals((Rgba32)obj); + return obj is Rgba32 other && this.Equals(other); } /// diff --git a/src/ImageSharp/PixelFormats/Rgba64.cs b/src/ImageSharp/PixelFormats/Rgba64.cs index 5d1aa0067..6b891a7c0 100644 --- a/src/ImageSharp/PixelFormats/Rgba64.cs +++ b/src/ImageSharp/PixelFormats/Rgba64.cs @@ -187,7 +187,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// public override bool Equals(object obj) { - return (obj is Rgba64) && this.Equals((Rgba64)obj); + return obj is Rgba64 other && this.Equals(other); } /// diff --git a/src/ImageSharp/Primitives/DenseMatrix{T}.cs b/src/ImageSharp/Primitives/DenseMatrix{T}.cs index 5f3defd11..ef1abc897 100644 --- a/src/ImageSharp/Primitives/DenseMatrix{T}.cs +++ b/src/ImageSharp/Primitives/DenseMatrix{T}.cs @@ -89,6 +89,11 @@ namespace SixLabors.ImageSharp.Primitives } } + /// + /// Gets a Span wrapping the Data. + /// + internal Span Span => new Span(this.Data); + /// /// Gets or sets the item at the specified position. /// @@ -146,19 +151,13 @@ namespace SixLabors.ImageSharp.Primitives /// /// The value to fill each item with [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Fill(T value) - { - for (int i = 0; i < this.Data.Length; i++) - { - this.Data[i] = value; - } - } + public void Fill(T value) => this.Span.Fill(value); /// /// Clears the matrix setting each value to the default value for the element type /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Clear() => Array.Clear(this.Data, 0, this.Data.Length); + public void Clear() => this.Span.Clear(); /// /// Checks the coordinates to ensure they are within bounds. @@ -183,28 +182,10 @@ namespace SixLabors.ImageSharp.Primitives } /// - public bool Equals(DenseMatrix other) - { - if (this.Columns != other.Columns) - { - return false; - } - - if (this.Rows != other.Rows) - { - return false; - } - - for (int i = 0; i < this.Data.Length; i++) - { - if (!this.Data[i].Equals(other.Data[i])) - { - return false; - } - } - - return true; - } + public bool Equals(DenseMatrix other) => + this.Columns == other.Columns && + this.Rows == other.Rows && + this.Span.SequenceEqual(other.Span); /// public override bool Equals(object obj) => obj is DenseMatrix other && this.Equals(other); diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs index 3ceba0838..7c04d090b 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs @@ -1,29 +1,22 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; - +using System; +using System.Linq; +using System.Text; using SixLabors.Fonts; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.ImageSharp.Processing.Text; +using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; +using SixLabors.Primitives; using Xunit; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Drawing.Text { - using System; - using System.Linq; - using System.Text; - using SixLabors.ImageSharp.Processing.Drawing.Brushes; - using SixLabors.ImageSharp.Processing.Drawing.Brushes.GradientBrushes; - using SixLabors.ImageSharp.Processing.Drawing.Pens; - using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; - using SixLabors.Primitives; - using SixLabors.Shapes; - [GroupOutput("Drawing/Text")] public class DrawTextOnImageTests { diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index fa165de5f..0188824f9 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -25,6 +25,7 @@ + diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index 4cee650e8..b07a383b7 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -30,6 +30,13 @@ namespace SixLabors.ImageSharp.Tests return Boolean.TryParse(Environment.GetEnvironmentVariable("CI"), out isCi) && isCi; }); + private static readonly Lazy NetCoreVersionLazy = new Lazy(GetNetCoreVersion); + + /// + /// Gets the .NET Core version, if running on .NET Core, otherwise returns an empty string. + /// + internal static string NetCoreVersion => NetCoreVersionLazy.Value; + // ReSharper disable once InconsistentNaming /// /// Gets a value indicating whether test execution runs on CI. @@ -123,5 +130,19 @@ namespace SixLabors.ImageSharp.Tests return path; } + + /// + /// Solution borrowed from: + /// https://github.com/dotnet/BenchmarkDotNet/issues/448#issuecomment-308424100 + /// + private static string GetNetCoreVersion() + { + Assembly assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; + string[] assemblyPath = assembly.CodeBase.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); + int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App"); + if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) + return assemblyPath[netCoreAppIndex + 1]; + return ""; + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs index 9db55281e..4a2c63beb 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs @@ -4,6 +4,7 @@ using System; using System.IO; +using SixLabors.ImageSharp.Common.Helpers; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Gif; @@ -13,9 +14,11 @@ using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; using Xunit; using Xunit.Abstractions; +// ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests { + public class TestEnvironmentTests { public TestEnvironmentTests(ITestOutputHelper output) @@ -31,6 +34,29 @@ namespace SixLabors.ImageSharp.Tests Assert.True(Directory.Exists(path)); } + /// + /// We need this test to make sure that the netcoreapp2.1 test execution actually covers the netcoreapp2.1 build configuration of ImageSharp. + /// + [Fact] + public void ImageSharpAssemblyUnderTest_MatchesExpectedTargetFramework() + { + this.Output.WriteLine("NetCoreVersion: " + TestEnvironment.NetCoreVersion); + this.Output.WriteLine("ImageSharpBuiltAgainst: " + TestHelpers.ImageSharpBuiltAgainst); + + if (string.IsNullOrEmpty(TestEnvironment.NetCoreVersion)) + { + this.Output.WriteLine("Not running under .NET Core!"); + } + else if (TestEnvironment.NetCoreVersion.StartsWith("2.1")) + { + Assert.Equal("netcoreapp2.1", TestHelpers.ImageSharpBuiltAgainst); + } + else + { + Assert.Equal("netstandard2.0", TestHelpers.ImageSharpBuiltAgainst); + } + } + [Fact] public void SolutionDirectoryFullPath() {