Skip to content

Commit

Permalink
Merge pull request #2583 from stefannikolei/sn/net8
Browse files Browse the repository at this point in the history
Update to net8
  • Loading branch information
JimBobSquarePants authored Dec 4, 2023
2 parents 07fd936 + b4f9bf9 commit 3d69f21
Show file tree
Hide file tree
Showing 45 changed files with 94 additions and 191 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 10 additions & 29 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
matrix:
options:
- os: ubuntu-latest
framework: net6.0
framework: net8.0
runtime: -x64
codecov: true

Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: DotNet Build
shell: pwsh
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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**:

Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1011" Action="None" />
</Rules>
</RuleSet>
</RuleSet>
4 changes: 2 additions & 2 deletions src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void Invoke(int i)
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);
}
}
}
Expand Down Expand Up @@ -102,7 +102,7 @@ public void Invoke(int i)

for (int y = yMin; y < yMax; y++)
{
Unsafe.AsRef(this.action).Invoke(y, span);
Unsafe.AsRef(in this.action).Invoke(y, span);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/ImageSharp/Advanced/ParallelRowIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void IterateRows<T>(
{
for (int y = top; y < bottom; y++)
{
Unsafe.AsRef(operation).Invoke(y);
Unsafe.AsRef(in operation).Invoke(y);
}

return;
Expand Down Expand Up @@ -118,7 +118,7 @@ public static void IterateRows<T, TBuffer>(
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)
Expand All @@ -128,7 +128,7 @@ public static void IterateRows<T, TBuffer>(

for (int y = top; y < bottom; y++)
{
Unsafe.AsRef(operation).Invoke(y, span);
Unsafe.AsRef(in operation).Invoke(y, span);
}

return;
Expand Down Expand Up @@ -245,15 +245,15 @@ public static void IterateRowIntervals<T, TBuffer>(
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)
{
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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/ImageSharp/Common/Helpers/DebugGuard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public static void IsTrue(bool target, string message)
[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>
Expand Down
19 changes: 0 additions & 19 deletions src/ImageSharp/Common/Helpers/Numerics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -908,25 +908,6 @@ public static int ReduceSum(Vector256<int> accumulator)
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>
Expand Down
5 changes: 3 additions & 2 deletions src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -59,7 +60,7 @@ public static Vector256<uint> PermuteMaskShiftAlpha8x32() => Vector256.Create(
public static void Shuffle4Reduce(
ref ReadOnlySpan<float> source,
ref Span<float> dest,
byte control)
[ConstantExpected] byte control)
{
if (Avx.IsSupported || Sse.IsSupported)
{
Expand Down Expand Up @@ -218,7 +219,7 @@ public static void Shuffle4Slice3Reduce(
private static void Shuffle4(
ReadOnlySpan<float> source,
Span<float> dest,
byte control)
[ConstantExpected] byte control)
{
if (Avx.IsSupported)
{
Expand Down
3 changes: 2 additions & 1 deletion src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

Expand Down
5 changes: 1 addition & 4 deletions src/ImageSharp/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ public int StreamProcessingBufferSize
get => this.streamProcessingBufferSize;
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(this.StreamProcessingBufferSize));
}
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(value);

this.streamProcessingBufferSize = value;
}
Expand Down
42 changes: 0 additions & 42 deletions src/ImageSharp/Diagnostics/CodeAnalysis/UnscopedRefAttribute.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/ImageSharp/Formats/AnimatedImageFrameMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Six Labors Split License.

namespace SixLabors.ImageSharp.Formats;

internal class AnimatedImageFrameMetadata
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/ImageSharp/Formats/AnimatedImageMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Six Labors Split License.

namespace SixLabors.ImageSharp.Formats;

internal class AnimatedImageMetadata
{
/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions src/ImageSharp/Formats/ImageFormatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ public void AddImageFormat(IImageFormat format)

lock (HashLock)
{
if (!this.imageFormats.Contains(format))
{
this.imageFormats.Add(format);
}
this.imageFormats.Add(format);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void Init(int maxSubFactorH, int maxSubFactorV)

for (int i = 0; i < this.ComponentCount; i++)
{
IJpegComponent component = this.Components[i];
JpegComponent component = this.Components[i];
component.Init(maxSubFactorH, maxSubFactorV);
}
}
Expand All @@ -143,7 +143,7 @@ public void AllocateComponents()
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);
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,7 @@ private void WriteJfifApplicationHeader(ImageMetadata meta, Span<byte> buffer)
/// <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;

Expand Down
3 changes: 1 addition & 2 deletions src/ImageSharp/Formats/Png/PngDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2039,8 +2039,7 @@ private static bool TryReadTextKeyword(ReadOnlySpan<byte> keywordBytes, out stri
// 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)
Expand Down
1 change: 1 addition & 0 deletions src/ImageSharp/Formats/Qoi/QoiDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SixLabors.ImageSharp.PixelFormats;

namespace SixLabors.ImageSharp.Formats.Qoi;

internal class QoiDecoder : ImageDecoder
{
private QoiDecoder()
Expand Down
Loading

0 comments on commit 3d69f21

Please sign in to comment.