diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 9e760c4b23..67259c04f7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -14,6 +14,18 @@ jobs: strategy: matrix: options: + - os: ubuntu-latest + framework: net5.0 + runtime: -x64 + codecov: false + - os: macos-latest + framework: net5.0 + runtime: -x64 + codecov: false + - os: windows-latest + framework: net5.0 + runtime: -x64 + codecov: false - os: ubuntu-latest framework: netcoreapp3.1 runtime: -x64 @@ -67,12 +79,14 @@ jobs: - name: Build shell: pwsh run: ./ci-build.ps1 "${{matrix.options.framework}}" + env: + SIXLABORS_TESTING: True - name: Test shell: pwsh run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}" env: - CI: True + SIXLABORS_TESTING: True XUNIT_PATH: .\tests\ImageSharp.Tests # Required for xunit - name: Export Failed Output diff --git a/shared-infrastructure b/shared-infrastructure index b7b9a2755e..af824b8bad 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit b7b9a2755e456a96acbf103494228226d92eddf3 +Subproject commit af824b8bad7307b735662e3eeab39d401c41741c diff --git a/src/ImageSharp/Image.WrapMemory.cs b/src/ImageSharp/Image.WrapMemory.cs index 383f643969..b0efdb60db 100644 --- a/src/ImageSharp/Image.WrapMemory.cs +++ b/src/ImageSharp/Image.WrapMemory.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp { /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(metadata, nameof(metadata)); - Guard.IsTrue(pixelMemory.Length == width * height, nameof(pixelMemory), "The length of the input memory doesn't match the specified image size"); + Guard.IsTrue(pixelMemory.Length >= width * height, nameof(pixelMemory), "The length of the input memory is less than the specified image size"); var memorySource = MemoryGroup.Wrap(pixelMemory); return new Image(configuration, memorySource, width, height, metadata); @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp => WrapMemory(Configuration.Default, pixelMemory, width, height); /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels, + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, /// allowing to view/manipulate it as an instance. /// The ownership of the is being transferred to the new instance, /// meaning that the caller is not allowed to dispose . @@ -147,14 +147,14 @@ namespace SixLabors.ImageSharp { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(metadata, nameof(metadata)); - Guard.IsTrue(pixelMemoryOwner.Memory.Length == width * height, nameof(pixelMemoryOwner), "The length of the input memory doesn't match the specified image size"); + Guard.IsTrue(pixelMemoryOwner.Memory.Length >= width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); var memorySource = MemoryGroup.Wrap(pixelMemoryOwner); return new Image(configuration, memorySource, width, height, metadata); } /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels, + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, /// allowing to view/manipulate it as an instance. /// The ownership of the is being transferred to the new instance, /// meaning that the caller is not allowed to dispose . @@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp => WrapMemory(configuration, pixelMemoryOwner, width, height, new ImageMetadata()); /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels, + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, /// allowing to view/manipulate it as an instance. /// The ownership of the is being transferred to the new instance, /// meaning that the caller is not allowed to dispose . @@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -234,7 +234,7 @@ namespace SixLabors.ImageSharp var memoryManager = new ByteMemoryManager(byteMemory); - Guard.IsTrue(memoryManager.Memory.Length == width * height, nameof(byteMemory), "The length of the input memory doesn't match the specified image size"); + Guard.IsTrue(memoryManager.Memory.Length >= width * height, nameof(byteMemory), "The length of the input memory is less than the specified image size"); var memorySource = MemoryGroup.Wrap(memoryManager.Memory); return new Image(configuration, memorySource, width, height, metadata); @@ -242,7 +242,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -275,7 +275,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -305,7 +305,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -355,7 +355,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// @@ -393,7 +393,7 @@ namespace SixLabors.ImageSharp /// /// - /// Wraps an existing contiguous memory area of 'width' x 'height' pixels allowing viewing/manipulation as + /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as /// an instance. /// /// diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index a90aaf715a..ca6ca16898 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -12,9 +12,21 @@ $(RepositoryUrl) Image Resize Crop Gif Jpg Jpeg Bitmap Png Tga NetCore A new, fully featured, fully managed, cross-platform, 2D graphics API for .NET - netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 + + + + net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 + + + + + netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472 + + + + diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index 2a209683ba..d89cf79fc9 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -5,7 +5,7 @@ ImageSharp.Benchmarks Exe SixLabors.ImageSharp.Benchmarks - netcoreapp3.1;netcoreapp2.1;net472 + net5.0;netcoreapp3.1;netcoreapp2.1;net472 false false diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj b/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj index b71b5ebf2f..220780c58e 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj +++ b/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj @@ -8,7 +8,7 @@ false SixLabors.ImageSharp.Tests.ProfilingSandbox win7-x64 - netcoreapp3.1;netcoreapp2.1;net472 + net5.0;netcoreapp3.1;netcoreapp2.1;net472 SixLabors.ImageSharp.Tests.ProfilingSandbox.Program false diff --git a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs index 02a8381808..16d0baff39 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs @@ -355,8 +355,6 @@ namespace SixLabors.ImageSharp.Tests [Theory] [InlineData(0, 5, 5)] [InlineData(20, 5, 5)] - [InlineData(26, 5, 5)] - [InlineData(2, 1, 1)] [InlineData(1023, 32, 32)] public void WrapMemory_MemoryOfT_InvalidSize(int size, int height, int width) { @@ -366,6 +364,20 @@ namespace SixLabors.ImageSharp.Tests Assert.Throws(() => Image.WrapMemory(memory, height, width)); } + [Theory] + [InlineData(25, 5, 5)] + [InlineData(26, 5, 5)] + [InlineData(2, 1, 1)] + [InlineData(1024, 32, 32)] + [InlineData(2048, 32, 32)] + public void WrapMemory_MemoryOfT_ValidSize(int size, int height, int width) + { + var array = new Rgba32[size]; + var memory = new Memory(array); + + Image.WrapMemory(memory, height, width); + } + private class TestMemoryOwner : IMemoryOwner { public Memory Memory { get; set; } @@ -378,8 +390,6 @@ namespace SixLabors.ImageSharp.Tests [Theory] [InlineData(0, 5, 5)] [InlineData(20, 5, 5)] - [InlineData(26, 5, 5)] - [InlineData(2, 1, 1)] [InlineData(1023, 32, 32)] public void WrapMemory_IMemoryOwnerOfT_InvalidSize(int size, int height, int width) { @@ -390,10 +400,22 @@ namespace SixLabors.ImageSharp.Tests } [Theory] - [InlineData(0, 5, 5)] - [InlineData(20, 5, 5)] + [InlineData(25, 5, 5)] [InlineData(26, 5, 5)] [InlineData(2, 1, 1)] + [InlineData(1024, 32, 32)] + [InlineData(2048, 32, 32)] + public void WrapMemory_IMemoryOwnerOfT_ValidSize(int size, int height, int width) + { + var array = new Rgba32[size]; + var memory = new TestMemoryOwner { Memory = array }; + + Image.WrapMemory(memory, height, width); + } + + [Theory] + [InlineData(0, 5, 5)] + [InlineData(20, 5, 5)] [InlineData(1023, 32, 32)] public void WrapMemory_MemoryOfByte_InvalidSize(int size, int height, int width) { @@ -403,6 +425,20 @@ namespace SixLabors.ImageSharp.Tests Assert.Throws(() => Image.WrapMemory(memory, height, width)); } + [Theory] + [InlineData(25, 5, 5)] + [InlineData(26, 5, 5)] + [InlineData(2, 1, 1)] + [InlineData(1024, 32, 32)] + [InlineData(2048, 32, 32)] + public void WrapMemory_MemoryOfByte_ValidSize(int size, int height, int width) + { + var array = new byte[size * Unsafe.SizeOf()]; + var memory = new Memory(array); + + Image.WrapMemory(memory, height, width); + } + [Theory] [InlineData(0, 5, 5)] [InlineData(20, 5, 5)] diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index e9d4b031ba..f03312af88 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -2,7 +2,7 @@ - netcoreapp3.1;netcoreapp2.1;net472 + net5.0;netcoreapp3.1;netcoreapp2.1;net472 True SixLabors.ImageSharp.Tests AnyCPU;x64;x86