Browse Source

Resolve PR comments

pull/2327/head
Stefan Nikolei 3 years ago
parent
commit
dfde8d8bf5
  1. 4
      src/ImageSharp/Memory/Allocators/Internals/Gen2GcCallback.cs
  2. 2
      src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs
  3. 6
      src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs
  4. 2
      src/ImageSharp/Memory/Buffer2D{T}.cs
  5. 2
      src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs

4
src/ImageSharp/Memory/Allocators/Internals/Gen2GcCallback.cs

@ -42,7 +42,7 @@ internal sealed class Gen2GcCallback : CriticalFinalizerObject
// Execute the callback method.
try
{
if (this.callback1 is not null && !this.callback1(targetObj))
if (!this.callback1!(targetObj))
{
// If the callback returns false, this callback object is no longer needed.
this.weakTargetObj.Free();
@ -63,7 +63,7 @@ internal sealed class Gen2GcCallback : CriticalFinalizerObject
// Execute the callback method.
try
{
if (this.callback0 is not null && !this.callback0())
if (!this.callback0!())
{
// If the callback returns false, this callback object is no longer needed.
return;

2
src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs

@ -43,5 +43,5 @@ internal abstract class ManagedBufferBase<T> : MemoryManager<T>
/// Gets the object that should be pinned.
/// </summary>
/// <returns>The pinnable <see cref="object"/>.</returns>
protected abstract object? GetPinnableObject();
protected abstract object GetPinnableObject();
}

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

@ -40,7 +40,11 @@ internal class SharedArrayPoolBuffer<T> : ManagedBufferBase<T>, IRefCounted
return MemoryMarshal.Cast<byte, T>(this.Array.AsSpan(0, this.lengthInBytes));
}
protected override object? GetPinnableObject() => this.Array;
protected override object GetPinnableObject()
{
Guard.NotNull(this.Array);
return this.Array;
}
public void AddRef()
{

2
src/ImageSharp/Memory/Buffer2D{T}.cs

@ -43,7 +43,7 @@ public sealed class Buffer2D<T> : IDisposable
/// Gets the backing <see cref="IMemoryGroup{T}"/>.
/// </summary>
/// <returns>The MemoryGroup.</returns>
public IMemoryGroup<T>? MemoryGroup => this.FastMemoryGroup.View;
public IMemoryGroup<T> MemoryGroup => this.FastMemoryGroup.View;
/// <summary>
/// Gets the backing <see cref="MemoryGroup{T}"/> without the view abstraction.

2
src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs

@ -41,7 +41,7 @@ internal abstract partial class MemoryGroup<T> : IMemoryGroup<T>, IDisposable
/// <inheritdoc />
public bool IsValid { get; private set; } = true;
public MemoryGroupView<T>? View { get; private set; }
public MemoryGroupView<T> View { get; private set; } = null!;
/// <inheritdoc />
public abstract Memory<T> this[int index] { get; }

Loading…
Cancel
Save