Browse Source

Fix throwhelper

pull/1629/head
James Jackson-South 5 years ago
parent
commit
65808ae55f
  1. 10
      src/ImageSharp/Image.cs
  2. 10
      src/ImageSharp/ImageFrameCollection.cs

10
src/ImageSharp/Image.cs

@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
@ -149,9 +150,9 @@ namespace SixLabors.ImageSharp
protected void UpdateSize(Size size) => this.size = size;
/// <summary>
/// Internal routine for freeing managed resources called from <see cref="Dispose"/>
/// Disposes the object and frees resources for the Garbage Collector.
/// </summary>
/// /// <param name="disposing">Whether to dispose of managed objects.</param>
/// <param name="disposing">Whether to dispose of managed and unmanaged objects.</param>
protected abstract void Dispose(bool disposing);
/// <summary>
@ -161,7 +162,7 @@ namespace SixLabors.ImageSharp
{
if (this.isDisposed)
{
ThrowHelper.ThrowObjectDisposedException(this.GetType());
ThrowObjectDisposedException(this.GetType());
}
}
@ -182,6 +183,9 @@ namespace SixLabors.ImageSharp
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
internal abstract Task AcceptAsync(IImageVisitorAsync visitor, CancellationToken cancellationToken);
[MethodImpl(InliningOptions.ColdPath)]
private static void ThrowObjectDisposedException(Type type) => throw new ObjectDisposedException(type.Name);
private class EncodeVisitor : IImageVisitor, IImageVisitorAsync
{
private readonly IImageEncoder encoder;

10
src/ImageSharp/ImageFrameCollection.cs

@ -4,6 +4,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp
{
@ -198,14 +199,14 @@ namespace SixLabors.ImageSharp
{
if (this.isDisposed)
{
ThrowHelper.ThrowObjectDisposedException(this.GetType());
ThrowObjectDisposedException(this.GetType());
}
}
/// <summary>
/// Internal routine for freeing managed resources called from <see cref="Dispose"/>
/// Disposes the object and frees resources for the Garbage Collector.
/// </summary>
/// /// /// <param name="disposing">Whether to dispose of managed objects.</param>
/// <param name="disposing">Whether to dispose of managed and unmanaged objects.</param>
protected abstract void Dispose(bool disposing);
/// <summary>
@ -262,5 +263,8 @@ namespace SixLabors.ImageSharp
/// <param name="backgroundColor">The background color.</param>
/// <returns>The new frame.</returns>
protected abstract ImageFrame NonGenericCreateFrame(Color backgroundColor);
[MethodImpl(InliningOptions.ColdPath)]
private static void ThrowObjectDisposedException(Type type) => throw new ObjectDisposedException(type.Name);
}
}

Loading…
Cancel
Save