Browse Source

Fix build errors

pull/2583/head
Stefan Nikolei 3 years ago
parent
commit
4564831d10
  1. 2
      .editorconfig
  2. 4
      src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs
  3. 10
      src/ImageSharp/Advanced/ParallelRowIterator.cs
  4. 2
      src/ImageSharp/Common/Helpers/DebugGuard.cs
  5. 5
      src/ImageSharp/Configuration.cs
  6. 5
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
  7. 2
      src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs
  8. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs
  9. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
  10. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
  11. 2
      src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
  12. 2
      src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
  13. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
  14. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
  15. 2
      src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs
  16. 2
      src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs
  17. 2
      src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs
  18. 2
      src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs
  19. 2
      src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs
  20. 2
      src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs
  21. 2
      src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs
  22. 1
      tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj

2
.editorconfig

@ -422,6 +422,8 @@ dotnet_naming_rule.parameters_rule.symbols = parameters_group
dotnet_naming_rule.parameters_rule.style = camel_case_style
dotnet_naming_rule.parameters_rule.severity = warning
dotnet_diagnostics.CA1857.severity = none
##########################################
# License
##########################################

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>

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;
}

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;

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

@ -59,10 +59,12 @@ internal class SharedArrayPoolBuffer<T> : ManagedBufferBase<T>, IRefCounted
[MemberNotNull(nameof(Array))]
private void CheckDisposed()
{
#pragma warning disable CA1513
if (this.Array == null)
{
throw new ObjectDisposedException("SharedArrayPoolBuffer");
}
#pragma warning restore CA1513
}
private sealed class LifetimeGuard : RefCountedMemoryLifetimeGuard

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

@ -128,7 +128,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 = bounds.Left; x < bounds.Right; x++)
{
destinationRow[x - offsetX] = Unsafe.AsRef(quantizer).GetQuantizedColor(sourceRow[x], out TPixel _);
destinationRow[x - offsetX] = Unsafe.AsRef(in quantizer).GetQuantizedColor(sourceRow[x], out TPixel _);
}
}

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

@ -167,7 +167,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)

1
tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj

@ -10,6 +10,7 @@
<!--Used to hide test project from dotnet test-->
<IsTestProject>false</IsTestProject>
<Configurations>Debug;Release</Configurations>
<LangVersion>12.0</LangVersion>
<!-- Uncomment this to run benchmarks depending on Colorful or Pfim (colorspaces and TGA): -->
<!--<SignAssembly>false</SignAssembly>-->
</PropertyGroup>

Loading…
Cancel
Save