Skip to content

Commit 344cca9

Browse files
authored
Merge branch 'main' into bp/modeScoreArm
2 parents ae7306b + 08f6d73 commit 344cca9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/ImageSharp/Formats/DecoderOptions.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,25 @@ public sealed class DecoderOptions
1515

1616
private uint maxFrames = int.MaxValue;
1717

18+
// Used by the FileProvider in the unit tests to set the configuration on the fly.
19+
#pragma warning disable IDE0032 // Use auto property
20+
private Configuration configuration = Configuration.Default;
21+
#pragma warning restore IDE0032 // Use auto property
22+
1823
/// <summary>
1924
/// Gets the shared default general decoder options instance.
25+
/// Used internally to reduce allocations for default decoding operations.
2026
/// </summary>
2127
internal static DecoderOptions Default { get; } = LazyOptions.Value;
2228

2329
/// <summary>
2430
/// Gets a custom configuration instance to be used by the image processing pipeline.
2531
/// </summary>
26-
public Configuration Configuration { get; internal set; } = Configuration.Default;
32+
#pragma warning disable IDE0032 // Use auto property
33+
#pragma warning disable RCS1085 // Use auto-implemented property.
34+
public Configuration Configuration { get => this.configuration; init => this.configuration = value; }
35+
#pragma warning restore RCS1085 // Use auto-implemented property.
36+
#pragma warning restore IDE0032 // Use auto property
2737

2838
/// <summary>
2939
/// Gets the target size to decode the image into. Scaling should use an operation equivalent to <see cref="ResizeMode.Max"/>.
@@ -44,4 +54,6 @@ public sealed class DecoderOptions
4454
/// Gets the maximum number of image frames to decode, inclusive.
4555
/// </summary>
4656
public uint MaxFrames { get => this.maxFrames; init => this.maxFrames = Math.Clamp(value, 1, int.MaxValue); }
57+
58+
internal void SetConfiguration(Configuration configuration) => this.configuration = configuration;
4759
}

tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public override async Task<Image<TPixel>> GetImageAsync(IImageDecoder decoder, D
207207
Guard.NotNull(decoder, nameof(decoder));
208208
Guard.NotNull(options, nameof(options));
209209

210-
options.Configuration = this.Configuration;
210+
options.SetConfiguration(this.Configuration);
211211

212212
// Used in small subset of decoder tests, no caching.
213213
// TODO: Check Path here. Why combined?
@@ -244,7 +244,7 @@ public override async Task<Image<TPixel>> GetImageAsync<T>(ISpecializedImageDeco
244244
Guard.NotNull(decoder, nameof(decoder));
245245
Guard.NotNull(options, nameof(options));
246246

247-
options.GeneralOptions.Configuration = this.Configuration;
247+
options.GeneralOptions.SetConfiguration(this.Configuration);
248248

249249
// Used in small subset of decoder tests, no caching.
250250
// TODO: Check Path here. Why combined?
@@ -268,7 +268,7 @@ public override void Serialize(IXunitSerializationInfo info)
268268

269269
private Image<TPixel> DecodeImage(IImageDecoder decoder, DecoderOptions options)
270270
{
271-
options.Configuration = this.Configuration;
271+
options.SetConfiguration(this.Configuration);
272272

273273
var testFile = TestFile.Create(this.FilePath);
274274
using Stream stream = new MemoryStream(testFile.Bytes);
@@ -278,7 +278,7 @@ private Image<TPixel> DecodeImage(IImageDecoder decoder, DecoderOptions options)
278278
private Image<TPixel> DecodeImage<T>(ISpecializedImageDecoder<T> decoder, T options)
279279
where T : class, ISpecializedDecoderOptions, new()
280280
{
281-
options.GeneralOptions.Configuration = this.Configuration;
281+
options.GeneralOptions.SetConfiguration(this.Configuration);
282282

283283
var testFile = TestFile.Create(this.FilePath);
284284
using Stream stream = new MemoryStream(testFile.Bytes);

0 commit comments

Comments
 (0)