From d2a2709c710bf799e8dc6cf5ed431f42e97f24c9 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 17 May 2020 18:06:40 +0100 Subject: [PATCH] Revert unrequired async/await additions --- .../Advanced/AdvancedImageExtensions.cs | 4 +- src/ImageSharp/Formats/Bmp/BmpEncoder.cs | 4 +- src/ImageSharp/Formats/Gif/GifEncoder.cs | 4 +- src/ImageSharp/Formats/Tga/TgaDecoder.cs | 4 +- src/ImageSharp/Formats/Tga/TgaEncoder.cs | 4 +- src/ImageSharp/Image.FromStream.cs | 37 +++++++++---------- 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs index 61dfc8944..fea0feb53 100644 --- a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs +++ b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs @@ -74,8 +74,8 @@ namespace SixLabors.ImageSharp.Advanced /// The source image. /// The image visitor. /// A representing the asynchronous operation. - public static async Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor) - => await source.AcceptAsync(visitor).ConfigureAwait(false); + public static Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor) + => source.AcceptAsync(visitor); /// /// Gets the configuration for the image. diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs index 70023ffc1..52b87ef27 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs @@ -42,11 +42,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp } /// - public async Task EncodeAsync(Image image, Stream stream) + public Task EncodeAsync(Image image, Stream stream) where TPixel : unmanaged, IPixel { var encoder = new BmpEncoderCore(this, image.GetMemoryAllocator()); - await encoder.EncodeAsync(image, stream).ConfigureAwait(false); + return encoder.EncodeAsync(image, stream); } } } diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs index 78e78a81f..8d4c33eff 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoder.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoder.cs @@ -41,11 +41,11 @@ namespace SixLabors.ImageSharp.Formats.Gif } /// - public async Task EncodeAsync(Image image, Stream stream) + public Task EncodeAsync(Image image, Stream stream) where TPixel : unmanaged, IPixel { var encoder = new GifEncoderCore(image.GetConfiguration(), this); - await encoder.EncodeAsync(image, stream).ConfigureAwait(false); + return encoder.EncodeAsync(image, stream); } } } diff --git a/src/ImageSharp/Formats/Tga/TgaDecoder.cs b/src/ImageSharp/Formats/Tga/TgaDecoder.cs index f977623f4..5cd7ca7b0 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoder.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoder.cs @@ -74,11 +74,11 @@ namespace SixLabors.ImageSharp.Formats.Tga } /// - public async Task IdentifyAsync(Configuration configuration, Stream stream) + public Task IdentifyAsync(Configuration configuration, Stream stream) { Guard.NotNull(stream, nameof(stream)); - return await new TgaDecoderCore(configuration, this).IdentifyAsync(stream).ConfigureAwait(false); + return new TgaDecoderCore(configuration, this).IdentifyAsync(stream); } } } diff --git a/src/ImageSharp/Formats/Tga/TgaEncoder.cs b/src/ImageSharp/Formats/Tga/TgaEncoder.cs index 449a724bf..058dd3559 100644 --- a/src/ImageSharp/Formats/Tga/TgaEncoder.cs +++ b/src/ImageSharp/Formats/Tga/TgaEncoder.cs @@ -32,11 +32,11 @@ namespace SixLabors.ImageSharp.Formats.Tga } /// - public async Task EncodeAsync(Image image, Stream stream) + public Task EncodeAsync(Image image, Stream stream) where TPixel : unmanaged, IPixel { var encoder = new TgaEncoderCore(this, image.GetMemoryAllocator()); - await encoder.EncodeAsync(image, stream).ConfigureAwait(false); + return encoder.EncodeAsync(image, stream); } } } diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs index bb36b1462..afd0f0e59 100644 --- a/src/ImageSharp/Image.FromStream.cs +++ b/src/ImageSharp/Image.FromStream.cs @@ -57,12 +57,11 @@ namespace SixLabors.ImageSharp /// The stream is null. /// The stream is not readable. /// The format type or null if none found. - public static async Task DetectFormatAsync(Configuration configuration, Stream stream) - => await WithSeekableStreamAsync( + public static Task DetectFormatAsync(Configuration configuration, Stream stream) + => WithSeekableStreamAsync( configuration, stream, - async s => await InternalDetectFormatAsync(s, configuration).ConfigureAwait(false)) - .ConfigureAwait(false); + s => InternalDetectFormatAsync(s, configuration)); /// /// Reads the raw image information from the specified stream without fully decoding it. @@ -184,12 +183,11 @@ namespace SixLabors.ImageSharp /// /// The with set to null if suitable info detector is not found. /// - public static async Task IdentifyWithFormatAsync(Configuration configuration, Stream stream) - => await WithSeekableStreamAsync( + public static Task IdentifyWithFormatAsync(Configuration configuration, Stream stream) + => WithSeekableStreamAsync( configuration, stream, - async s => await InternalIdentityAsync(s, configuration ?? Configuration.Default)) - .ConfigureAwait(false); + s => InternalIdentityAsync(s, configuration ?? Configuration.Default)); /// /// Decode a new instance of the class from the given stream. @@ -309,7 +307,10 @@ namespace SixLabors.ImageSharp public static Task LoadAsync(Configuration configuration, Stream stream, IImageDecoder decoder) { Guard.NotNull(decoder, nameof(decoder)); - return WithSeekableStreamAsync(configuration, stream, s => decoder.DecodeAsync(configuration, s)); + return WithSeekableStreamAsync( + configuration, + stream, + s => decoder.DecodeAsync(configuration, s)); } /// @@ -425,13 +426,12 @@ namespace SixLabors.ImageSharp /// Image contains invalid content. /// The pixel format. /// A new .> - public static async Task> LoadAsync(Stream stream, IImageDecoder decoder) + public static Task> LoadAsync(Stream stream, IImageDecoder decoder) where TPixel : unmanaged, IPixel - => await WithSeekableStreamAsync( + => WithSeekableStreamAsync( Configuration.Default, stream, - async s => await decoder.DecodeAsync(Configuration.Default, s).ConfigureAwait(false)) - .ConfigureAwait(false); + s => decoder.DecodeAsync(Configuration.Default, s)); /// /// Create a new instance of the class from the given stream. @@ -463,13 +463,12 @@ namespace SixLabors.ImageSharp /// Image contains invalid content. /// The pixel format. /// A new .> - public static async Task> LoadAsync(Configuration configuration, Stream stream, IImageDecoder decoder) + public static Task> LoadAsync(Configuration configuration, Stream stream, IImageDecoder decoder) where TPixel : unmanaged, IPixel - => await WithSeekableStreamAsync( + => WithSeekableStreamAsync( configuration, stream, - async s => await decoder.DecodeAsync(configuration, s).ConfigureAwait(false)) - .ConfigureAwait(false); + s => decoder.DecodeAsync(configuration, s)); /// /// Create a new instance of the class from the given stream. @@ -577,8 +576,8 @@ namespace SixLabors.ImageSharp await WithSeekableStreamAsync( configuration, stream, - async s => await DecodeAsync(s, configuration).ConfigureAwait(false)) - .ConfigureAwait(false); + async s => await DecodeAsync(s, configuration) + .ConfigureAwait(false)); if (data.img != null) {