Browse Source

Revert unrequired async/await additions

pull/1574/head
James Jackson-South 6 years ago
parent
commit
d2a2709c71
  1. 4
      src/ImageSharp/Advanced/AdvancedImageExtensions.cs
  2. 4
      src/ImageSharp/Formats/Bmp/BmpEncoder.cs
  3. 4
      src/ImageSharp/Formats/Gif/GifEncoder.cs
  4. 4
      src/ImageSharp/Formats/Tga/TgaDecoder.cs
  5. 4
      src/ImageSharp/Formats/Tga/TgaEncoder.cs
  6. 37
      src/ImageSharp/Image.FromStream.cs

4
src/ImageSharp/Advanced/AdvancedImageExtensions.cs

@ -74,8 +74,8 @@ namespace SixLabors.ImageSharp.Advanced
/// <param name="source">The source image.</param> /// <param name="source">The source image.</param>
/// <param name="visitor">The image visitor.</param> /// <param name="visitor">The image visitor.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public static async Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor) public static Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor)
=> await source.AcceptAsync(visitor).ConfigureAwait(false); => source.AcceptAsync(visitor);
/// <summary> /// <summary>
/// Gets the configuration for the image. /// Gets the configuration for the image.

4
src/ImageSharp/Formats/Bmp/BmpEncoder.cs

@ -42,11 +42,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp
} }
/// <inheritdoc/> /// <inheritdoc/>
public async Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream) public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var encoder = new BmpEncoderCore(this, image.GetMemoryAllocator()); var encoder = new BmpEncoderCore(this, image.GetMemoryAllocator());
await encoder.EncodeAsync(image, stream).ConfigureAwait(false); return encoder.EncodeAsync(image, stream);
} }
} }
} }

4
src/ImageSharp/Formats/Gif/GifEncoder.cs

@ -41,11 +41,11 @@ namespace SixLabors.ImageSharp.Formats.Gif
} }
/// <inheritdoc/> /// <inheritdoc/>
public async Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream) public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var encoder = new GifEncoderCore(image.GetConfiguration(), this); var encoder = new GifEncoderCore(image.GetConfiguration(), this);
await encoder.EncodeAsync(image, stream).ConfigureAwait(false); return encoder.EncodeAsync(image, stream);
} }
} }
} }

4
src/ImageSharp/Formats/Tga/TgaDecoder.cs

@ -74,11 +74,11 @@ namespace SixLabors.ImageSharp.Formats.Tga
} }
/// <inheritdoc/> /// <inheritdoc/>
public async Task<IImageInfo> IdentifyAsync(Configuration configuration, Stream stream) public Task<IImageInfo> IdentifyAsync(Configuration configuration, Stream stream)
{ {
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
return await new TgaDecoderCore(configuration, this).IdentifyAsync(stream).ConfigureAwait(false); return new TgaDecoderCore(configuration, this).IdentifyAsync(stream);
} }
} }
} }

4
src/ImageSharp/Formats/Tga/TgaEncoder.cs

@ -32,11 +32,11 @@ namespace SixLabors.ImageSharp.Formats.Tga
} }
/// <inheritdoc/> /// <inheritdoc/>
public async Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream) public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var encoder = new TgaEncoderCore(this, image.GetMemoryAllocator()); var encoder = new TgaEncoderCore(this, image.GetMemoryAllocator());
await encoder.EncodeAsync(image, stream).ConfigureAwait(false); return encoder.EncodeAsync(image, stream);
} }
} }
} }

37
src/ImageSharp/Image.FromStream.cs

@ -57,12 +57,11 @@ namespace SixLabors.ImageSharp
/// <exception cref="ArgumentNullException">The stream is null.</exception> /// <exception cref="ArgumentNullException">The stream is null.</exception>
/// <exception cref="NotSupportedException">The stream is not readable.</exception> /// <exception cref="NotSupportedException">The stream is not readable.</exception>
/// <returns>The format type or null if none found.</returns> /// <returns>The format type or null if none found.</returns>
public static async Task<IImageFormat> DetectFormatAsync(Configuration configuration, Stream stream) public static Task<IImageFormat> DetectFormatAsync(Configuration configuration, Stream stream)
=> await WithSeekableStreamAsync( => WithSeekableStreamAsync(
configuration, configuration,
stream, stream,
async s => await InternalDetectFormatAsync(s, configuration).ConfigureAwait(false)) s => InternalDetectFormatAsync(s, configuration));
.ConfigureAwait(false);
/// <summary> /// <summary>
/// Reads the raw image information from the specified stream without fully decoding it. /// Reads the raw image information from the specified stream without fully decoding it.
@ -184,12 +183,11 @@ namespace SixLabors.ImageSharp
/// <returns> /// <returns>
/// The <see cref="FormattedImageInfo"/> with <see cref="FormattedImageInfo.ImageInfo"/> set to null if suitable info detector is not found. /// The <see cref="FormattedImageInfo"/> with <see cref="FormattedImageInfo.ImageInfo"/> set to null if suitable info detector is not found.
/// </returns> /// </returns>
public static async Task<FormattedImageInfo> IdentifyWithFormatAsync(Configuration configuration, Stream stream) public static Task<FormattedImageInfo> IdentifyWithFormatAsync(Configuration configuration, Stream stream)
=> await WithSeekableStreamAsync( => WithSeekableStreamAsync(
configuration, configuration,
stream, stream,
async s => await InternalIdentityAsync(s, configuration ?? Configuration.Default)) s => InternalIdentityAsync(s, configuration ?? Configuration.Default));
.ConfigureAwait(false);
/// <summary> /// <summary>
/// Decode a new instance of the <see cref="Image"/> class from the given stream. /// Decode a new instance of the <see cref="Image"/> class from the given stream.
@ -309,7 +307,10 @@ namespace SixLabors.ImageSharp
public static Task<Image> LoadAsync(Configuration configuration, Stream stream, IImageDecoder decoder) public static Task<Image> LoadAsync(Configuration configuration, Stream stream, IImageDecoder decoder)
{ {
Guard.NotNull(decoder, nameof(decoder)); Guard.NotNull(decoder, nameof(decoder));
return WithSeekableStreamAsync(configuration, stream, s => decoder.DecodeAsync(configuration, s)); return WithSeekableStreamAsync(
configuration,
stream,
s => decoder.DecodeAsync(configuration, s));
} }
/// <summary> /// <summary>
@ -425,13 +426,12 @@ namespace SixLabors.ImageSharp
/// <exception cref="InvalidImageContentException">Image contains invalid content.</exception> /// <exception cref="InvalidImageContentException">Image contains invalid content.</exception>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static async Task<Image<TPixel>> LoadAsync<TPixel>(Stream stream, IImageDecoder decoder) public static Task<Image<TPixel>> LoadAsync<TPixel>(Stream stream, IImageDecoder decoder)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> await WithSeekableStreamAsync( => WithSeekableStreamAsync(
Configuration.Default, Configuration.Default,
stream, stream,
async s => await decoder.DecodeAsync<TPixel>(Configuration.Default, s).ConfigureAwait(false)) s => decoder.DecodeAsync<TPixel>(Configuration.Default, s));
.ConfigureAwait(false);
/// <summary> /// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream. /// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
@ -463,13 +463,12 @@ namespace SixLabors.ImageSharp
/// <exception cref="InvalidImageContentException">Image contains invalid content.</exception> /// <exception cref="InvalidImageContentException">Image contains invalid content.</exception>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static async Task<Image<TPixel>> LoadAsync<TPixel>(Configuration configuration, Stream stream, IImageDecoder decoder) public static Task<Image<TPixel>> LoadAsync<TPixel>(Configuration configuration, Stream stream, IImageDecoder decoder)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> await WithSeekableStreamAsync( => WithSeekableStreamAsync(
configuration, configuration,
stream, stream,
async s => await decoder.DecodeAsync<TPixel>(configuration, s).ConfigureAwait(false)) s => decoder.DecodeAsync<TPixel>(configuration, s));
.ConfigureAwait(false);
/// <summary> /// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream. /// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
@ -577,8 +576,8 @@ namespace SixLabors.ImageSharp
await WithSeekableStreamAsync( await WithSeekableStreamAsync(
configuration, configuration,
stream, stream,
async s => await DecodeAsync<TPixel>(s, configuration).ConfigureAwait(false)) async s => await DecodeAsync<TPixel>(s, configuration)
.ConfigureAwait(false); .ConfigureAwait(false));
if (data.img != null) if (data.img != null)
{ {

Loading…
Cancel
Save