diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs
index 9cae89252b..ecb7b1b87d 100644
--- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs
+++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs
@@ -279,7 +279,7 @@ namespace SixLabors.ImageSharp.Formats.Webp
/// The webp features.
private void ParseOptionalChunks(WebpFeatures features)
{
- if (this.skipMetadata || (features.ExifProfile == false && features.XmpMetaData == false))
+ if (this.skipMetadata || (!features.ExifProfile && !features.XmpMetaData))
{
return;
}
diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
index 603a7b90fa..5bf28b3c8b 100644
--- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
@@ -28,38 +28,68 @@ namespace SixLabors.ImageSharp.Tests
private readonly Dictionary decoderParameters;
- public Key(PixelTypes pixelType, string filePath, IImageDecoder customDecoder)
+ public Key(
+ PixelTypes pixelType,
+ string filePath,
+ IImageDecoder customDecoder,
+ DecoderOptions options,
+ ISpecializedDecoderOptions specialized)
{
Type customType = customDecoder?.GetType();
this.commonValues = new Tuple(
pixelType,
filePath,
customType);
- this.decoderParameters = GetDecoderParameters(customDecoder);
+ this.decoderParameters = GetDecoderParameters(options, specialized);
}
- private static Dictionary GetDecoderParameters(IImageDecoder customDecoder)
+ private static Dictionary GetDecoderParameters(
+ DecoderOptions options,
+ ISpecializedDecoderOptions specialized)
{
- Type type = customDecoder.GetType();
+ Type type = options.GetType();
var data = new Dictionary();
while (type != null && type != typeof(object))
{
- PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
- foreach (PropertyInfo p in properties)
+ foreach (PropertyInfo p in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
string key = $"{type.FullName}.{p.Name}";
- object value = p.GetValue(customDecoder);
- data[key] = value;
+ data[key] = p.GetValue(options);
}
type = type.GetTypeInfo().BaseType;
}
+ GetSpecializedDecoderParameters(data, specialized);
+
return data;
}
+ private static void GetSpecializedDecoderParameters(
+ Dictionary data,
+ ISpecializedDecoderOptions options)
+ {
+ if (options is null)
+ {
+ return;
+ }
+
+ Type type = options.GetType();
+
+ while (type != null && type != typeof(object))
+ {
+ foreach (PropertyInfo p in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
+ {
+ string key = $"{type.FullName}.{p.Name}";
+ data[key] = p.GetValue(options);
+ }
+
+ type = type.GetTypeInfo().BaseType;
+ }
+ }
+
public bool Equals(Key other)
{
if (other is null)
@@ -165,7 +195,7 @@ namespace SixLabors.ImageSharp.Tests
return this.DecodeImage(decoder, options);
}
- var key = new Key(this.PixelType, this.FilePath, decoder);
+ var key = new Key(this.PixelType, this.FilePath, decoder, options, null);
Image cachedImage = Cache.GetOrAdd(key, _ => this.DecodeImage(decoder, options));
return cachedImage.Clone(this.Configuration);
@@ -202,7 +232,7 @@ namespace SixLabors.ImageSharp.Tests
return this.DecodeImage(decoder, options);
}
- var key = new Key(this.PixelType, this.FilePath, decoder);
+ var key = new Key(this.PixelType, this.FilePath, decoder, options.GeneralOptions, options);
Image cachedImage = Cache.GetOrAdd(key, _ => this.DecodeImage(decoder, options));
return cachedImage.Clone(this.Configuration);