Skip to content

Commit 4564831

Browse files
committed
Fix build errors
1 parent 69951a5 commit 4564831

File tree

22 files changed

+31
-30
lines changed

22 files changed

+31
-30
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ dotnet_naming_rule.parameters_rule.symbols = parameters_group
422422
dotnet_naming_rule.parameters_rule.style = camel_case_style
423423
dotnet_naming_rule.parameters_rule.severity = warning
424424

425+
426+
dotnet_diagnostics.CA1857.severity = none
425427
##########################################
426428
# License
427429
##########################################

src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void Invoke(int i)
5151
for (int y = yMin; y < yMax; y++)
5252
{
5353
// Skip the safety copy when invoking a potentially impure method on a readonly field
54-
Unsafe.AsRef(this.action).Invoke(y);
54+
Unsafe.AsRef(in this.action).Invoke(y);
5555
}
5656
}
5757
}
@@ -102,7 +102,7 @@ public void Invoke(int i)
102102

103103
for (int y = yMin; y < yMax; y++)
104104
{
105-
Unsafe.AsRef(this.action).Invoke(y, span);
105+
Unsafe.AsRef(in this.action).Invoke(y, span);
106106
}
107107
}
108108
}

src/ImageSharp/Advanced/ParallelRowIterator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static void IterateRows<T>(
5858
{
5959
for (int y = top; y < bottom; y++)
6060
{
61-
Unsafe.AsRef(operation).Invoke(y);
61+
Unsafe.AsRef(in operation).Invoke(y);
6262
}
6363

6464
return;
@@ -118,7 +118,7 @@ public static void IterateRows<T, TBuffer>(
118118
int maxSteps = DivideCeil(width * (long)height, parallelSettings.MinimumPixelsProcessedPerTask);
119119
int numOfSteps = Math.Min(parallelSettings.MaxDegreeOfParallelism, maxSteps);
120120
MemoryAllocator allocator = parallelSettings.MemoryAllocator;
121-
int bufferLength = Unsafe.AsRef(operation).GetRequiredBufferLength(rectangle);
121+
int bufferLength = Unsafe.AsRef(in operation).GetRequiredBufferLength(rectangle);
122122

123123
// Avoid TPL overhead in this trivial case:
124124
if (numOfSteps == 1)
@@ -128,7 +128,7 @@ public static void IterateRows<T, TBuffer>(
128128

129129
for (int y = top; y < bottom; y++)
130130
{
131-
Unsafe.AsRef(operation).Invoke(y, span);
131+
Unsafe.AsRef(in operation).Invoke(y, span);
132132
}
133133

134134
return;
@@ -245,15 +245,15 @@ public static void IterateRowIntervals<T, TBuffer>(
245245
int maxSteps = DivideCeil(width * (long)height, parallelSettings.MinimumPixelsProcessedPerTask);
246246
int numOfSteps = Math.Min(parallelSettings.MaxDegreeOfParallelism, maxSteps);
247247
MemoryAllocator allocator = parallelSettings.MemoryAllocator;
248-
int bufferLength = Unsafe.AsRef(operation).GetRequiredBufferLength(rectangle);
248+
int bufferLength = Unsafe.AsRef(in operation).GetRequiredBufferLength(rectangle);
249249

250250
// Avoid TPL overhead in this trivial case:
251251
if (numOfSteps == 1)
252252
{
253253
var rows = new RowInterval(top, bottom);
254254
using IMemoryOwner<TBuffer> buffer = allocator.Allocate<TBuffer>(bufferLength);
255255

256-
Unsafe.AsRef(operation).Invoke(in rows, buffer.Memory.Span);
256+
Unsafe.AsRef(in operation).Invoke(in rows, buffer.Memory.Span);
257257

258258
return;
259259
}

src/ImageSharp/Common/Helpers/DebugGuard.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ public static void IsTrue(bool target, string message)
3333
[Conditional("DEBUG")]
3434
public static void NotDisposed(bool isDisposed, string objectName)
3535
{
36+
#pragma warning disable CA1513
3637
if (isDisposed)
3738
{
3839
throw new ObjectDisposedException(objectName);
3940
}
41+
#pragma warning restore CA1513
4042
}
4143

4244
/// <summary>

src/ImageSharp/Configuration.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ public int StreamProcessingBufferSize
8787
get => this.streamProcessingBufferSize;
8888
set
8989
{
90-
if (value <= 0)
91-
{
92-
throw new ArgumentOutOfRangeException(nameof(this.StreamProcessingBufferSize));
93-
}
90+
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(value);
9491

9592
this.streamProcessingBufferSize = value;
9693
}

src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,7 @@ private void WriteJfifApplicationHeader(ImageMetadata meta, Span<byte> buffer)
176176
/// <exception cref="ArgumentNullException"><paramref name="tableConfigs"/> is <see langword="null"/>.</exception>
177177
private void WriteDefineHuffmanTables(JpegHuffmanTableConfig[] tableConfigs, HuffmanScanEncoder scanEncoder, Span<byte> buffer)
178178
{
179-
if (tableConfigs is null)
180-
{
181-
throw new ArgumentNullException(nameof(tableConfigs));
182-
}
179+
ArgumentNullException.ThrowIfNull(tableConfigs);
183180

184181
int markerlen = 2;
185182

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ public void AddRef()
5959
[MemberNotNull(nameof(Array))]
6060
private void CheckDisposed()
6161
{
62+
#pragma warning disable CA1513
6263
if (this.Array == null)
6364
{
6465
throw new ObjectDisposedException("SharedArrayPoolBuffer");
6566
}
67+
#pragma warning restore CA1513
6668
}
6769

6870
private sealed class LifetimeGuard : RefCountedMemoryLifetimeGuard

src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public Abgr32(uint packed)
129129
public uint Abgr
130130
{
131131
[MethodImpl(InliningOptions.ShortMethod)]
132-
readonly get => Unsafe.As<Abgr32, uint>(ref Unsafe.AsRef(this));
132+
readonly get => Unsafe.As<Abgr32, uint>(ref Unsafe.AsRef(in this));
133133

134134
[MethodImpl(InliningOptions.ShortMethod)]
135135
set => Unsafe.As<Abgr32, uint>(ref this) = value;

src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public Argb32(uint packed)
129129
public uint Argb
130130
{
131131
[MethodImpl(InliningOptions.ShortMethod)]
132-
readonly get => Unsafe.As<Argb32, uint>(ref Unsafe.AsRef(this));
132+
readonly get => Unsafe.As<Argb32, uint>(ref Unsafe.AsRef(in this));
133133

134134
[MethodImpl(InliningOptions.ShortMethod)]
135135
set => Unsafe.As<Argb32, uint>(ref this) = value;

src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public Bgra32(byte r, byte g, byte b, byte a)
8585
public uint Bgra
8686
{
8787
[MethodImpl(InliningOptions.ShortMethod)]
88-
readonly get => Unsafe.As<Bgra32, uint>(ref Unsafe.AsRef(this));
88+
readonly get => Unsafe.As<Bgra32, uint>(ref Unsafe.AsRef(in this));
8989

9090
[MethodImpl(InliningOptions.ShortMethod)]
9191
set => Unsafe.As<Bgra32, uint>(ref this) = value;

0 commit comments

Comments
 (0)