mirror of https://github.com/SixLabors/ImageSharp
8 changed files with 0 additions and 129 deletions
@ -1,33 +1,23 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Compression.Zlib; |
|||
|
|||
internal static class DeflateThrowHelper |
|||
{ |
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowAlreadyFinished() => throw new InvalidOperationException("Finish() already called."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowAlreadyClosed() => throw new InvalidOperationException("Deflator already closed."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowUnknownCompression() => throw new InvalidOperationException("Unknown compression function."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowNotProcessed() => throw new InvalidOperationException("Old input was not completely processed."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowNull(string name) => throw new ArgumentNullException(name); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowOutOfRange(string name) => throw new ArgumentOutOfRangeException(name); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowHeapViolated() => throw new InvalidOperationException("Huffman heap invariant violated."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowNoDeflate() => throw new ImageFormatException("Cannot deflate all input."); |
|||
} |
|||
|
|||
@ -1,25 +1,13 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Bmp; |
|||
|
|||
internal static class BmpThrowHelper |
|||
{ |
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="InvalidImageContentException"/>'s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(MethodImplOptions.NoInlining)] |
|||
public static void ThrowInvalidImageContentException(string errorMessage) |
|||
=> throw new InvalidImageContentException(errorMessage); |
|||
|
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="NotSupportedException"/>'s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(MethodImplOptions.NoInlining)] |
|||
public static void ThrowNotSupportedException(string errorMessage) |
|||
=> throw new NotSupportedException(errorMessage); |
|||
} |
|||
|
|||
@ -1,26 +1,12 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Gif; |
|||
|
|||
internal static class GifThrowHelper |
|||
{ |
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="InvalidImageContentException"/>'s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowInvalidImageContentException(string errorMessage) |
|||
=> throw new InvalidImageContentException(errorMessage); |
|||
|
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="InvalidImageContentException"/>'s.
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
|
|||
/// if no inner exception is specified.</param>
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowInvalidImageContentException(string errorMessage, Exception innerException) => throw new InvalidImageContentException(errorMessage, innerException); |
|||
} |
|||
|
|||
@ -1,56 +1,33 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg; |
|||
|
|||
internal static class JpegThrowHelper |
|||
{ |
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="NotSupportedException"/>'s.
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowNotSupportedException(string errorMessage) => throw new NotSupportedException(errorMessage); |
|||
|
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="InvalidImageContentException"/>'s.
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowBadMarker(string marker, int length) => throw new InvalidImageContentException($"Marker {marker} has bad length {length}."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowNotEnoughBytesForMarker(byte marker) => throw new InvalidImageContentException($"Input stream does not have enough bytes to parse declared contents of the {marker:X2} marker."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowBadQuantizationTableIndex(int index) => throw new InvalidImageContentException($"Bad Quantization Table index {index}."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowBadQuantizationTablePrecision(int precision) => throw new InvalidImageContentException($"Unknown Quantization Table precision {precision}."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowBadSampling() => throw new InvalidImageContentException("Bad sampling factor."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowBadSampling(int factor) => throw new InvalidImageContentException($"Bad sampling factor: {factor}"); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowBadProgressiveScan(int ss, int se, int ah, int al) => throw new InvalidImageContentException($"Invalid progressive parameters Ss={ss} Se={se} Ah={ah} Al={al}."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowInvalidImageDimensions(int width, int height) => throw new InvalidImageContentException($"Invalid image dimensions: {width}x{height}."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowDimensionsTooLarge(int width, int height) => throw new ImageFormatException($"Image is too large to encode at {width}x{height} for JPEG format."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowNotSupportedComponentCount(int componentCount) => throw new NotSupportedException($"Images with {componentCount} components are not supported."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowNotSupportedColorSpace() => throw new NotSupportedException("Image color space could not be deduced."); |
|||
} |
|||
|
|||
@ -1,35 +1,16 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Tga; |
|||
|
|||
internal static class TgaThrowHelper |
|||
{ |
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="ImageFormatException"/>'s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowInvalidImageContentException(string errorMessage) |
|||
=> throw new InvalidImageContentException(errorMessage); |
|||
|
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="ImageFormatException"/>'s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
|
|||
/// if no inner exception is specified.</param>
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowInvalidImageContentException(string errorMessage, Exception innerException) |
|||
=> throw new InvalidImageContentException(errorMessage, innerException); |
|||
|
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="NotSupportedException"/>'s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowNotSupportedException(string errorMessage) |
|||
=> throw new NotSupportedException(errorMessage); |
|||
} |
|||
|
|||
@ -1,37 +1,21 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Tiff; |
|||
|
|||
/// <summary>
|
|||
/// Cold path optimizations for throwing tiff format based exceptions.
|
|||
/// </summary>
|
|||
internal static class TiffThrowHelper |
|||
{ |
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="ImageFormatException"/>-s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(MethodImplOptions.NoInlining)] |
|||
public static Exception ThrowImageFormatException(string errorMessage) => throw new ImageFormatException(errorMessage); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static Exception NotSupportedDecompressor(string compressionType) => throw new NotSupportedException($"Not supported decoder compression method: {compressionType}"); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static Exception NotSupportedCompressor(string compressionType) => throw new NotSupportedException($"Not supported encoder compression method: {compressionType}"); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static Exception InvalidColorType(string colorType) => throw new NotSupportedException($"Invalid color type: {colorType}"); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static Exception ThrowInvalidHeader() => throw new ImageFormatException("Invalid TIFF file header."); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowNotSupported(string message) => throw new NotSupportedException(message); |
|||
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowArgumentException(string message) => throw new ArgumentException(message); |
|||
} |
|||
|
|||
@ -1,37 +1,15 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Webp; |
|||
|
|||
internal static class WebpThrowHelper |
|||
{ |
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="InvalidImageContentException"/>'s.
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(InliningOptions.ColdPath)] |
|||
public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage); |
|||
|
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="ImageFormatException"/>-s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(MethodImplOptions.NoInlining)] |
|||
public static void ThrowImageFormatException(string errorMessage) => throw new ImageFormatException(errorMessage); |
|||
|
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="NotSupportedException"/>-s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(MethodImplOptions.NoInlining)] |
|||
public static void ThrowNotSupportedException(string errorMessage) => throw new NotSupportedException(errorMessage); |
|||
|
|||
/// <summary>
|
|||
/// Cold path optimization for throwing <see cref="InvalidImageContentException"/>-s
|
|||
/// </summary>
|
|||
/// <param name="errorMessage">The error message for the exception.</param>
|
|||
[MethodImpl(MethodImplOptions.NoInlining)] |
|||
public static void ThrowInvalidImageDimensions(string errorMessage) => throw new InvalidImageContentException(errorMessage); |
|||
} |
|||
|
|||
Loading…
Reference in new issue