Browse Source

Merge pull request #2583 from stefannikolei/sn/net8

Update to net8
pull/2611/head
James Jackson-South 2 years ago
committed by GitHub
parent
commit
3d69f21ec2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .gitattributes
  2. 39
      .github/workflows/build-and-test.yml
  3. 4
      .github/workflows/code-coverage.yml
  4. 4
      README.md
  5. 2
      shared-infrastructure
  6. 2
      src/ImageSharp.ruleset
  7. 4
      src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs
  8. 10
      src/ImageSharp/Advanced/ParallelRowIterator.cs
  9. 2
      src/ImageSharp/Common/Helpers/DebugGuard.cs
  10. 19
      src/ImageSharp/Common/Helpers/Numerics.cs
  11. 5
      src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs
  12. 3
      src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs
  13. 5
      src/ImageSharp/Configuration.cs
  14. 42
      src/ImageSharp/Diagnostics/CodeAnalysis/UnscopedRefAttribute.cs
  15. 1
      src/ImageSharp/Formats/AnimatedImageFrameMetadata.cs
  16. 1
      src/ImageSharp/Formats/AnimatedImageMetadata.cs
  17. 5
      src/ImageSharp/Formats/ImageFormatManager.cs
  18. 4
      src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegFrame.cs
  19. 5
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
  20. 3
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  21. 1
      src/ImageSharp/Formats/Qoi/QoiDecoder.cs
  22. 2
      src/ImageSharp/Formats/Tiff/Ifd/DirectoryReader.cs
  23. 13
      src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs
  24. 8
      src/ImageSharp/ImageSharp.csproj
  25. 8
      src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs
  26. 2
      src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs
  27. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs
  28. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
  29. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
  30. 2
      src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
  31. 2
      src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
  32. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
  33. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
  34. 2
      src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs
  35. 2
      src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs
  36. 2
      src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs
  37. 2
      src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs
  38. 2
      src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs
  39. 2
      src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs
  40. 2
      src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs
  41. 24
      tests/Directory.Build.targets
  42. 10
      tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj
  43. 6
      tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs
  44. 8
      tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj
  45. 10
      tests/ImageSharp.Tests/ImageSharp.Tests.csproj

3
.gitattributes

@ -133,3 +133,6 @@
*.pnm filter=lfs diff=lfs merge=lfs -text
*.wbmp filter=lfs diff=lfs merge=lfs -text
*.exr filter=lfs diff=lfs merge=lfs -text
*.ico filter=lfs diff=lfs merge=lfs -text
*.cur filter=lfs diff=lfs merge=lfs -text
*.ani filter=lfs diff=lfs merge=lfs -text

39
.github/workflows/build-and-test.yml

@ -19,42 +19,23 @@ jobs:
- ${{ contains(github.event.pull_request.labels.*.name, 'arch:arm32') || contains(github.event.pull_request.labels.*.name, 'arch:arm64') }}
options:
- os: ubuntu-latest
framework: net7.0
sdk: 7.0.x
sdk-preview: true
framework: net8.0
sdk: 8.0.x
runtime: -x64
codecov: false
- os: macos-latest
framework: net7.0
sdk: 7.0.x
sdk-preview: true
framework: net8.0
sdk: 8.0.x
runtime: -x64
codecov: false
- os: windows-latest
framework: net7.0
sdk: 7.0.x
sdk-preview: true
framework: net8.0
sdk: 8.0.x
runtime: -x64
codecov: false
- os: buildjet-4vcpu-ubuntu-2204-arm
framework: net7.0
sdk: 7.0.x
sdk-preview: true
runtime: -x64
codecov: false
- os: ubuntu-latest
framework: net6.0
sdk: 6.0.x
runtime: -x64
codecov: false
- os: macos-latest
framework: net6.0
sdk: 6.0.x
runtime: -x64
codecov: false
- os: windows-latest
framework: net6.0
sdk: 6.0.x
framework: net8.0
sdk: 8.0.x
runtime: -x64
codecov: false
exclude:
@ -111,14 +92,14 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: DotNet Setup Preview
if: ${{ matrix.options.sdk-preview == true }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
8.0.x
- name: DotNet Build
if: ${{ matrix.options.sdk-preview != true }}

4
.github/workflows/code-coverage.yml

@ -10,7 +10,7 @@ jobs:
matrix:
options:
- os: ubuntu-latest
framework: net6.0
framework: net8.0
runtime: -x64
codecov: true
@ -58,7 +58,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: DotNet Build
shell: pwsh

4
README.md

@ -21,7 +21,7 @@ Designed to simplify image processing, ImageSharp brings you an incredibly power
ImageSharp is designed from the ground up to be flexible and extensible. The library provides API endpoints for common image processing operations and the building blocks to allow for the development of additional operations.
Built against [.NET 6](https://docs.microsoft.com/en-us/dotnet/standard/net-standard), ImageSharp can be used in device, cloud, and embedded/IoT scenarios.
Built against [.NET 8](https://docs.microsoft.com/en-us/dotnet/standard/net-standard), ImageSharp can be used in device, cloud, and embedded/IoT scenarios.
## License
@ -64,7 +64,7 @@ If you prefer, you can compile ImageSharp yourself (please do and help!)
- Using [Visual Studio 2022](https://visualstudio.microsoft.com/vs/)
- Make sure you have the latest version installed
- Make sure you have [the .NET 7 SDK](https://www.microsoft.com/net/core#windows) installed
- Make sure you have [the .NET 8 SDK](https://www.microsoft.com/net/core#windows) installed
Alternatively, you can work from command line and/or with a lightweight editor on **both Linux/Unix and Windows**:

2
shared-infrastructure

@ -1 +1 @@
Subproject commit 353b9afe32a8000410312d17263407cd7bb82d19
Subproject commit 1c526a97eea8bcbc7c79de095676f7fb975a9fb1

2
src/ImageSharp.ruleset

@ -4,4 +4,4 @@
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1011" Action="None" />
</Rules>
</RuleSet>
</RuleSet>

4
src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs

@ -51,7 +51,7 @@ public static partial class ParallelRowIterator
for (int y = yMin; y < yMax; y++)
{
// Skip the safety copy when invoking a potentially impure method on a readonly field
Unsafe.AsRef(this.action).Invoke(y);
Unsafe.AsRef(in this.action).Invoke(y);
}
}
}
@ -102,7 +102,7 @@ public static partial class ParallelRowIterator
for (int y = yMin; y < yMax; y++)
{
Unsafe.AsRef(this.action).Invoke(y, span);
Unsafe.AsRef(in this.action).Invoke(y, span);
}
}
}

10
src/ImageSharp/Advanced/ParallelRowIterator.cs

@ -58,7 +58,7 @@ public static partial class ParallelRowIterator
{
for (int y = top; y < bottom; y++)
{
Unsafe.AsRef(operation).Invoke(y);
Unsafe.AsRef(in operation).Invoke(y);
}
return;
@ -118,7 +118,7 @@ public static partial class ParallelRowIterator
int maxSteps = DivideCeil(width * (long)height, parallelSettings.MinimumPixelsProcessedPerTask);
int numOfSteps = Math.Min(parallelSettings.MaxDegreeOfParallelism, maxSteps);
MemoryAllocator allocator = parallelSettings.MemoryAllocator;
int bufferLength = Unsafe.AsRef(operation).GetRequiredBufferLength(rectangle);
int bufferLength = Unsafe.AsRef(in operation).GetRequiredBufferLength(rectangle);
// Avoid TPL overhead in this trivial case:
if (numOfSteps == 1)
@ -128,7 +128,7 @@ public static partial class ParallelRowIterator
for (int y = top; y < bottom; y++)
{
Unsafe.AsRef(operation).Invoke(y, span);
Unsafe.AsRef(in operation).Invoke(y, span);
}
return;
@ -245,7 +245,7 @@ public static partial class ParallelRowIterator
int maxSteps = DivideCeil(width * (long)height, parallelSettings.MinimumPixelsProcessedPerTask);
int numOfSteps = Math.Min(parallelSettings.MaxDegreeOfParallelism, maxSteps);
MemoryAllocator allocator = parallelSettings.MemoryAllocator;
int bufferLength = Unsafe.AsRef(operation).GetRequiredBufferLength(rectangle);
int bufferLength = Unsafe.AsRef(in operation).GetRequiredBufferLength(rectangle);
// Avoid TPL overhead in this trivial case:
if (numOfSteps == 1)
@ -253,7 +253,7 @@ public static partial class ParallelRowIterator
var rows = new RowInterval(top, bottom);
using IMemoryOwner<TBuffer> buffer = allocator.Allocate<TBuffer>(bufferLength);
Unsafe.AsRef(operation).Invoke(in rows, buffer.Memory.Span);
Unsafe.AsRef(in operation).Invoke(in rows, buffer.Memory.Span);
return;
}

2
src/ImageSharp/Common/Helpers/DebugGuard.cs

@ -33,10 +33,12 @@ internal static partial class DebugGuard
[Conditional("DEBUG")]
public static void NotDisposed(bool isDisposed, string objectName)
{
#pragma warning disable CA1513
if (isDisposed)
{
throw new ObjectDisposedException(objectName);
}
#pragma warning restore CA1513
}
/// <summary>

19
src/ImageSharp/Common/Helpers/Numerics.cs

@ -908,25 +908,6 @@ internal static class Numerics
return Sse2.ConvertToInt32(vsum);
}
/// <summary>
/// Reduces elements of the vector into one sum.
/// </summary>
/// <param name="accumulator">The accumulator to reduce.</param>
/// <returns>The sum of all elements.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public static int ReduceSumArm(Vector128<uint> accumulator)
{
if (AdvSimd.Arm64.IsSupported)
{
Vector64<uint> sum = AdvSimd.Arm64.AddAcross(accumulator);
return (int)AdvSimd.Extract(sum, 0);
}
Vector128<ulong> sum2 = AdvSimd.AddPairwiseWidening(accumulator);
Vector64<uint> sum3 = AdvSimd.Add(sum2.GetLower().AsUInt32(), sum2.GetUpper().AsUInt32());
return (int)AdvSimd.Extract(sum3, 0);
}
/// <summary>
/// Reduces even elements of the vector into one sum.
/// </summary>

5
src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -59,7 +60,7 @@ internal static partial class SimdUtils
public static void Shuffle4Reduce(
ref ReadOnlySpan<float> source,
ref Span<float> dest,
byte control)
[ConstantExpected] byte control)
{
if (Avx.IsSupported || Sse.IsSupported)
{
@ -218,7 +219,7 @@ internal static partial class SimdUtils
private static void Shuffle4(
ReadOnlySpan<float> source,
Span<float> dest,
byte control)
[ConstantExpected] byte control)
{
if (Avx.IsSupported)
{

3
src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs

@ -2,6 +2,7 @@
// Licensed under the Six Labors Split License.
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -20,7 +21,7 @@ internal static partial class SimdUtils
public static void Shuffle4(
ReadOnlySpan<float> source,
Span<float> dest,
byte control)
[ConstantExpected] byte control)
{
VerifyShuffle4SpanInput(source, dest);

5
src/ImageSharp/Configuration.cs

@ -87,10 +87,7 @@ public sealed class Configuration
get => this.streamProcessingBufferSize;
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(this.StreamProcessingBufferSize));
}
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(value);
this.streamProcessingBufferSize = value;
}

42
src/ImageSharp/Diagnostics/CodeAnalysis/UnscopedRefAttribute.cs

@ -1,42 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#if NET6_0
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Diagnostics.CodeAnalysis
{
/// <summary>
/// Used to indicate a byref escapes and is not scoped.
/// </summary>
/// <remarks>
/// <para>
/// There are several cases where the C# compiler treats a <see langword="ref"/> as implicitly
/// <see langword="scoped"/> - where the compiler does not allow the <see langword="ref"/> to escape the method.
/// </para>
/// <para>
/// For example:
/// <list type="number">
/// <item><see langword="this"/> for <see langword="struct"/> instance methods.</item>
/// <item><see langword="ref"/> parameters that refer to <see langword="ref"/> <see langword="struct"/> types.</item>
/// <item><see langword="out"/> parameters.</item>
/// </list>
/// </para>
/// <para>
/// This attribute is used in those instances where the <see langword="ref"/> should be allowed to escape.
/// </para>
/// <para>
/// Applying this attribute, in any form, has impact on consumers of the applicable API. It is necessary for
/// API authors to understand the lifetime implications of applying this attribute and how it may impact their users.
/// </para>
/// </remarks>
[global::System.AttributeUsage(
global::System.AttributeTargets.Method |
global::System.AttributeTargets.Property |
global::System.AttributeTargets.Parameter,
AllowMultiple = false,
Inherited = false)]
internal sealed class UnscopedRefAttribute : global::System.Attribute
{
}
}
#endif

1
src/ImageSharp/Formats/AnimatedImageFrameMetadata.cs

@ -2,6 +2,7 @@
// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Formats;
internal class AnimatedImageFrameMetadata
{
/// <summary>

1
src/ImageSharp/Formats/AnimatedImageMetadata.cs

@ -2,6 +2,7 @@
// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Formats;
internal class AnimatedImageMetadata
{
/// <summary>

5
src/ImageSharp/Formats/ImageFormatManager.cs

@ -83,10 +83,7 @@ public class ImageFormatManager
lock (HashLock)
{
if (!this.imageFormats.Contains(format))
{
this.imageFormats.Add(format);
}
this.imageFormats.Add(format);
}
}

4
src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegFrame.cs

@ -133,7 +133,7 @@ internal sealed class JpegFrame : IDisposable
for (int i = 0; i < this.ComponentCount; i++)
{
IJpegComponent component = this.Components[i];
JpegComponent component = this.Components[i];
component.Init(maxSubFactorH, maxSubFactorV);
}
}
@ -143,7 +143,7 @@ internal sealed class JpegFrame : IDisposable
bool fullScan = this.Progressive || !this.Interleaved;
for (int i = 0; i < this.ComponentCount; i++)
{
IJpegComponent component = this.Components[i];
JpegComponent component = this.Components[i];
component.AllocateSpectral(fullScan);
}
}

5
src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

@ -176,10 +176,7 @@ internal sealed unsafe partial class JpegEncoderCore : IImageEncoderInternals
/// <exception cref="ArgumentNullException"><paramref name="tableConfigs"/> is <see langword="null"/>.</exception>
private void WriteDefineHuffmanTables(JpegHuffmanTableConfig[] tableConfigs, HuffmanScanEncoder scanEncoder, Span<byte> buffer)
{
if (tableConfigs is null)
{
throw new ArgumentNullException(nameof(tableConfigs));
}
ArgumentNullException.ThrowIfNull(tableConfigs);
int markerlen = 2;

3
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -2039,8 +2039,7 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
// Keywords should not be empty or have leading or trailing whitespace.
name = PngConstants.Encoding.GetString(keywordBytes);
return !string.IsNullOrWhiteSpace(name)
&& !name.StartsWith(" ", StringComparison.Ordinal)
&& !name.EndsWith(" ", StringComparison.Ordinal);
&& !name.StartsWith(' ') && !name.EndsWith(' ');
}
private static bool IsXmpTextData(ReadOnlySpan<byte> keywordBytes)

1
src/ImageSharp/Formats/Qoi/QoiDecoder.cs

@ -4,6 +4,7 @@
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Qoi;
internal class QoiDecoder : ImageDecoder
{
private QoiDecoder()

2
src/ImageSharp/Formats/Tiff/Ifd/DirectoryReader.cs

@ -71,7 +71,7 @@ internal class DirectoryReader
throw TiffThrowHelper.ThrowInvalidHeader();
}
private IList<ExifProfile> ReadIfds(bool isBigTiff)
private List<ExifProfile> ReadIfds(bool isBigTiff)
{
List<EntryReader> readers = new();
while (this.nextIfdOffset != 0 && this.nextIfdOffset < (ulong)this.stream.Length)

13
src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs

@ -230,11 +230,7 @@ internal static class LossyUtils
}
}
#if NET7_0_OR_GREATER
return (int)Vector128.Sum(sum);
#else
return Numerics.ReduceSumArm(sum);
#endif
}
[MethodImpl(InliningOptions.ShortMethod)]
@ -252,11 +248,7 @@ internal static class LossyUtils
}
}
#if NET7_0_OR_GREATER
return (int)Vector128.Sum(sum);
#else
return Numerics.ReduceSumArm(sum);
#endif
}
[MethodImpl(InliningOptions.ShortMethod)]
@ -275,11 +267,8 @@ internal static class LossyUtils
Vector128<uint> sum2 = AdvSimd.AddPairwiseWidening(prod2);
Vector128<uint> sum = AdvSimd.Add(sum1, sum2);
#if NET7_0_OR_GREATER
return (int)Vector128.Sum(sum);
#else
return Numerics.ReduceSumArm(sum);
#endif
}
// Load all 4x4 pixels into a single Vector128<uint>

8
src/ImageSharp/ImageSharp.csproj

@ -22,20 +22,20 @@
</PropertyGroup>
<PropertyGroup>
<!--Bump to v3.1 prior to tagged release.-->
<MinVerMinimumMajorMinor>3.1</MinVerMinimumMajorMinor>
<!--Bump to v4.0 prior to tagged release.-->
<MinVerMinimumMajorMinor>4.0</MinVerMinimumMajorMinor>
</PropertyGroup>
<Choose>
<When Condition="$(SIXLABORS_TESTING_PREVIEW) == true">
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>
</Otherwise>

8
src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs

@ -57,13 +57,7 @@ internal class SharedArrayPoolBuffer<T> : ManagedBufferBase<T>, IRefCounted
[Conditional("DEBUG")]
[MemberNotNull(nameof(Array))]
private void CheckDisposed()
{
if (this.Array == null)
{
throw new ObjectDisposedException("SharedArrayPoolBuffer");
}
}
private void CheckDisposed() => ObjectDisposedException.ThrowIf(this.Array == null, this.Array);
private sealed class LifetimeGuard : RefCountedMemoryLifetimeGuard
{

2
src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs

@ -472,7 +472,7 @@ internal abstract class BaseExifReader
}
}
private void Add(IList<IExifValue> values, IExifValue exif, object? value)
private void Add(IList<IExifValue> values, ExifValue exif, object? value)
{
if (!exif.TrySetValue(value))
{

2
src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs

@ -129,7 +129,7 @@ public partial struct Abgr32 : IPixel<Abgr32>, IPackedVector<uint>
public uint Abgr
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Abgr32, uint>(ref Unsafe.AsRef(this));
readonly get => Unsafe.As<Abgr32, uint>(ref Unsafe.AsRef(in this));
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Abgr32, uint>(ref this) = value;

2
src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs

@ -129,7 +129,7 @@ public partial struct Argb32 : IPixel<Argb32>, IPackedVector<uint>
public uint Argb
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Argb32, uint>(ref Unsafe.AsRef(this));
readonly get => Unsafe.As<Argb32, uint>(ref Unsafe.AsRef(in this));
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Argb32, uint>(ref this) = value;

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs

@ -85,7 +85,7 @@ public partial struct Bgra32 : IPixel<Bgra32>, IPackedVector<uint>
public uint Bgra
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Bgra32, uint>(ref Unsafe.AsRef(this));
readonly get => Unsafe.As<Bgra32, uint>(ref Unsafe.AsRef(in this));
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Bgra32, uint>(ref this) = value;

2
src/ImageSharp/PixelFormats/PixelImplementations/La16.cs

@ -45,7 +45,7 @@ public partial struct La16 : IPixel<La16>, IPackedVector<ushort>
/// <inheritdoc/>
public ushort PackedValue
{
readonly get => Unsafe.As<La16, ushort>(ref Unsafe.AsRef(this));
readonly get => Unsafe.As<La16, ushort>(ref Unsafe.AsRef(in this));
set => Unsafe.As<La16, ushort>(ref this) = value;
}

2
src/ImageSharp/PixelFormats/PixelImplementations/La32.cs

@ -45,7 +45,7 @@ public partial struct La32 : IPixel<La32>, IPackedVector<uint>
public uint PackedValue
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<La32, uint>(ref Unsafe.AsRef(this));
readonly get => Unsafe.As<La32, uint>(ref Unsafe.AsRef(in this));
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<La32, uint>(ref this) = value;

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs

@ -124,7 +124,7 @@ public partial struct Rgba32 : IPixel<Rgba32>, IPackedVector<uint>
public uint Rgba
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Rgba32, uint>(ref Unsafe.AsRef(this));
readonly get => Unsafe.As<Rgba32, uint>(ref Unsafe.AsRef(in this));
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Rgba32, uint>(ref this) = value;

4
src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs

@ -152,7 +152,7 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong>
public Rgb48 Rgb
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Rgba64, Rgb48>(ref Unsafe.AsRef(this));
readonly get => Unsafe.As<Rgba64, Rgb48>(ref Unsafe.AsRef(in this));
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Rgba64, Rgb48>(ref this) = value;
@ -162,7 +162,7 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong>
public ulong PackedValue
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Rgba64, ulong>(ref Unsafe.AsRef(this));
readonly get => Unsafe.As<Rgba64, ulong>(ref Unsafe.AsRef(in this));
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Rgba64, ulong>(ref this) = value;

2
src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs

@ -143,7 +143,7 @@ public readonly partial struct ErrorDither : IDither, IEquatable<ErrorDither>, I
for (int x = bounds.Left; x < bounds.Right; x++)
{
ref TPixel sourcePixel = ref Unsafe.Add(ref sourceRowRef, (uint)x);
TPixel transformed = Unsafe.AsRef(processor).GetPaletteColor(sourcePixel);
TPixel transformed = Unsafe.AsRef(in processor).GetPaletteColor(sourcePixel);
this.Dither(source, bounds, sourcePixel, transformed, x, y, scale);
sourcePixel = transformed;
}

2
src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs

@ -96,7 +96,7 @@ internal sealed class PixelRowDelegateProcessor<TPixel, TDelegate> : ImageProces
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, rowSpan, span, this.modifiers);
// Run the user defined pixel shader to the current row of pixels
Unsafe.AsRef(this.rowProcessor).Invoke(span, new Point(this.startX, y));
Unsafe.AsRef(in this.rowProcessor).Invoke(span, new Point(this.startX, y));
PixelOperations<TPixel>.Instance.FromVector4Destructive(this.configuration, span, rowSpan, this.modifiers);
}

2
src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs

@ -78,7 +78,7 @@ internal class FilterProcessor<TPixel> : ImageProcessor<TPixel>
Span<TPixel> rowSpan = this.source.DangerousGetRowSpan(y).Slice(this.startX, span.Length);
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, rowSpan, span, PixelConversionModifiers.Scale);
ColorNumerics.Transform(span, ref Unsafe.AsRef(this.matrix));
ColorNumerics.Transform(span, ref Unsafe.AsRef(in this.matrix));
PixelOperations<TPixel>.Instance.FromVector4Destructive(this.configuration, span, rowSpan, PixelConversionModifiers.Scale);
}

2
src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs

@ -126,7 +126,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly IndexedImageFrame<TPixel> QuantizeFrame(ImageFrame<TPixel> source, Rectangle bounds)
=> QuantizerUtilities.QuantizeFrame(ref Unsafe.AsRef(this), source, bounds);
=> QuantizerUtilities.QuantizeFrame(ref Unsafe.AsRef(in this), source, bounds);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs

@ -56,7 +56,7 @@ internal readonly struct PaletteQuantizer<TPixel> : IQuantizer<TPixel>
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly IndexedImageFrame<TPixel> QuantizeFrame(ImageFrame<TPixel> source, Rectangle bounds)
=> QuantizerUtilities.QuantizeFrame(ref Unsafe.AsRef(this), source, bounds);
=> QuantizerUtilities.QuantizeFrame(ref Unsafe.AsRef(in this), source, bounds);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs

@ -161,7 +161,7 @@ public static class QuantizerUtilities
for (int x = 0; x < destinationRow.Length; x++)
{
destinationRow[x] = Unsafe.AsRef(quantizer).GetQuantizedColor(sourceRow[x + offsetX], out TPixel _);
destinationRow[x] = Unsafe.AsRef(in quantizer).GetQuantizedColor(sourceRow[x + offsetX], out TPixel _);
}
}

2
src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs

@ -168,7 +168,7 @@ internal struct WuQuantizer<TPixel> : IQuantizer<TPixel>
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly IndexedImageFrame<TPixel> QuantizeFrame(ImageFrame<TPixel> source, Rectangle bounds)
=> QuantizerUtilities.QuantizeFrame(ref Unsafe.AsRef(this), source, bounds);
=> QuantizerUtilities.QuantizeFrame(ref Unsafe.AsRef(in this), source, bounds);
/// <inheritdoc/>
public readonly byte GetQuantizedColor(TPixel color, out TPixel match)

24
tests/Directory.Build.targets

@ -18,20 +18,18 @@
<ItemGroup>
<!-- Test Dependencies -->
<PackageReference Update="BenchmarkDotNet" Version="0.13.0" />
<PackageReference Update="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.0" Condition="'$(IsWindows)'=='true'" />
<PackageReference Update="Colourful" Version="3.0.0" />
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="12.2.2" />
<PackageReference Update="Microsoft.DotNet.RemoteExecutor" Version="6.0.0-beta.21311.3" />
<PackageReference Update="Microsoft.DotNet.XUnitExtensions" Version="6.0.0-beta.21311.3" />
<PackageReference Update="Moq" Version="4.14.6" />
<PackageReference Update="NetVips" Version="2.0.1" />
<PackageReference Update="NetVips.Native" Version="8.11.0" />
<PackageReference Update="PhotoSauce.MagicScaler" Version="0.12.1" />
<PackageReference Update="Pfim" Version="0.9.1" />
<PackageReference Update="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="5.8.64" Condition="'$(IsOSX)'=='true'" />
<PackageReference Update="Colourful" Version="3.1.0" />
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="13.4.0" />
<PackageReference Update="Microsoft.DotNet.RemoteExecutor" Version="8.0.0-beta.23580.1" />
<PackageReference Update="Microsoft.DotNet.XUnitExtensions" Version="8.0.0-beta.23580.1" />
<PackageReference Update="Moq" Version="4.20.70" />
<PackageReference Update="NetVips" Version="2.4.0" />
<PackageReference Update="NetVips.Native" Version="8.15.0" />
<PackageReference Update="PhotoSauce.MagicScaler" Version="0.14.0" />
<PackageReference Update="Pfim" Version="0.11.2" />
<PackageReference Update="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" Condition="'$(IsOSX)'=='true'" />
<PackageReference Update="SharpZipLib" Version="1.4.2" />
<PackageReference Update="SkiaSharp" Version="2.80.2" />
<PackageReference Update="SkiaSharp" Version="2.88.6" />
<PackageReference Update="System.Drawing.Common" Version="6.0.0" />
<PackageReference Update="System.IO.Compression" Version="4.3.0" />
</ItemGroup>

10
tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj

@ -11,7 +11,7 @@
<IsTestProject>false</IsTestProject>
<Configurations>Debug;Release</Configurations>
<!-- Uncomment this to run benchmarks depending on Colorful or Pfim (colorspaces and TGA): -->
<!--<SignAssembly>false</SignAssembly>-->
<!--<SignAssembly>false</SignAssembly>-->
</PropertyGroup>
<PropertyGroup>
@ -23,12 +23,12 @@
<Choose>
<When Condition="$(SIXLABORS_TESTING_PREVIEW) == true">
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>
</Otherwise>
</Choose>
@ -41,8 +41,8 @@
<ItemGroup>
<PackageReference Include="Magick.NET-Q16-AnyCPU" />
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Condition="'$(OS)' == 'Windows_NT'" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.10" Condition="'$(IsWindows)'=='true'" />
<PackageReference Include="Colourful" />
<PackageReference Include="NetVips" />
<PackageReference Include="NetVips.Native" />

6
tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs

@ -269,9 +269,7 @@ public class LoadResizeSaveStressRunner
Width = this.ThumbnailSize,
Height = this.ThumbnailSize,
ResizeMode = CropScaleMode.Max,
SaveFormat = FileFormat.Jpeg,
JpegQuality = Quality,
JpegSubsampleMode = ChromaSubsampleMode.Subsample420
EncoderOptions = new JpegEncoderOptions(Quality, ChromaSubsampleMode.Subsample420, true)
};
// TODO: Is there a way to capture input dimensions for IncreaseTotalMegapixels?
@ -343,6 +341,6 @@ public class LoadResizeSaveStressRunner
using var thumb = NetVipsImage.Thumbnail(input, this.ThumbnailSize, this.ThumbnailSize);
// Save the results
thumb.Jpegsave(this.OutputPath(input), q: Quality, strip: true);
thumb.Jpegsave(this.OutputPath(input), q: Quality, keep: NetVips.Enums.ForeignKeep.None);
}
}

8
tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj

@ -7,7 +7,7 @@
<OutputType>Exe</OutputType>
<Prefer32Bit>false</Prefer32Bit>
<RootNamespace>SixLabors.ImageSharp.Tests.ProfilingSandbox</RootNamespace>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<StartupObject>SixLabors.ImageSharp.Tests.ProfilingSandbox.Program</StartupObject>
<!--Used to hide test project from dotnet test-->
<IsTestProject>false</IsTestProject>
@ -19,12 +19,12 @@
<Choose>
<When Condition="$(SIXLABORS_TESTING_PREVIEW) == true">
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>
</Otherwise>
</Choose>
@ -43,7 +43,7 @@
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Condition="'$(IsOSX)'=='true'" />
<PackageReference Include="SkiaSharp" />
<PackageReference Include="System.Drawing.Common" />
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
</ItemGroup>
<ItemGroup>

10
tests/ImageSharp.Tests/ImageSharp.Tests.csproj

@ -12,12 +12,12 @@
<Choose>
<When Condition="$(SIXLABORS_TESTING_PREVIEW) == true">
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>
</Otherwise>
</Choose>
@ -35,7 +35,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
<!--
Do not update or consolidate BenchmarkDotNet.
https://github.com/dotnet/arcade/issues/8483
-->
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" />
<PackageReference Include="Microsoft.DotNet.RemoteExecutor" />
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />

Loading…
Cancel
Save