Browse Source

Fix errors reported by rider

- Used collection expressions were possible
- Added the used type were needed for clarification
- Disabled an Resharper rule With ImageSharp.sln.DotSettings --> It said that the Attribute ConstantExpected is not valid on floats
pull/3013/head
Stefan Nikolei 3 months ago
parent
commit
28ae9aa099
  1. 2
      ImageSharp.sln.DotSettings
  2. 2
      src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs
  3. 29
      src/ImageSharp/Common/Helpers/TestHelpers.cs
  4. 181
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs
  5. 2
      src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  6. 2
      src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs
  7. 2
      tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs
  8. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs
  9. 111
      tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs
  10. 3
      tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs
  11. 8
      tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs
  12. 2
      tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs
  13. 6
      tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs
  14. 2
      tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs
  15. 12
      tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs
  16. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs
  17. 4
      tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs
  18. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs
  19. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs
  20. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs
  21. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs
  22. 53
      tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs

2
ImageSharp.sln.DotSettings

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=IncorrectConstantExpectedAnnotation/@EntryIndexedValue">HINT</s:String></wpf:ResourceDictionary>

2
src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs

@ -12,7 +12,7 @@ internal class GrayTrcCalculator : IVector4Calculator
private readonly TrcCalculator calculator;
public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs)
=> this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs);
=> this.calculator = new TrcCalculator([grayTrc], !toPcs);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector4 Calculate(Vector4 value) => this.calculator.Calculate(value);

29
src/ImageSharp/Common/Helpers/TestHelpers.cs

@ -1,29 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Common.Helpers;
/// <summary>
/// Internal utilities intended to be only used in tests.
/// </summary>
internal static class TestHelpers
{
/// <summary>
/// This constant is useful to verify the target framework ImageSharp has been built against.
/// Only intended to be used in tests!
/// </summary>
internal const string ImageSharpBuiltAgainst =
#if NETCOREAPP3_1
"netcoreapp3.1";
#elif NETCOREAPP2_1
"netcoreapp2.1";
#elif NETSTANDARD2_1
"netstandard2.1";
#elif NETSTANDARD2_0
"netstandard2.0";
#elif NETSTANDARD1_3
"netstandard1.3";
#else
"net472";
#endif
}

181
src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs

@ -21,175 +21,158 @@ internal sealed unsafe partial class JpegEncoderCore
JpegQuantizationTableConfig defaultLuminanceQuantTable = new(0, Quantization.LuminanceTable);
JpegQuantizationTableConfig defaultChrominanceQuantTable = new(1, Quantization.ChrominanceTable);
JpegHuffmanTableConfig[] yCbCrHuffmanConfigs = new JpegHuffmanTableConfig[]
{
JpegHuffmanTableConfig[] yCbCrHuffmanConfigs =
[
defaultLuminanceHuffmanDC,
defaultLuminanceHuffmanAC,
defaultChrominanceHuffmanDC,
defaultChrominanceHuffmanAC,
};
defaultChrominanceHuffmanAC
];
JpegQuantizationTableConfig[] yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[]
{
JpegQuantizationTableConfig[] yCbCrQuantTableConfigs =
[
defaultLuminanceQuantTable,
defaultChrominanceQuantTable,
};
defaultChrominanceQuantTable
];
return new JpegFrameConfig[]
{
return
[
// YCbCr 4:4:4
new(
new JpegFrameConfig(
JpegColorSpace.YCbCr,
JpegColorType.YCbCrRatio444,
new JpegComponentConfig[]
{
new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
},
[
new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1)
],
yCbCrHuffmanConfigs,
yCbCrQuantTableConfigs),
// YCbCr 4:2:2
new(
new JpegFrameConfig(
JpegColorSpace.YCbCr,
JpegColorType.YCbCrRatio422,
new JpegComponentConfig[]
{
new(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
},
[
new JpegComponentConfig(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1)
],
yCbCrHuffmanConfigs,
yCbCrQuantTableConfigs),
// YCbCr 4:2:0
new(
new JpegFrameConfig(
JpegColorSpace.YCbCr,
JpegColorType.YCbCrRatio420,
new JpegComponentConfig[]
{
new(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
},
[
new JpegComponentConfig(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1)
],
yCbCrHuffmanConfigs,
yCbCrQuantTableConfigs),
// YCbCr 4:1:1
new(
new JpegFrameConfig(
JpegColorSpace.YCbCr,
JpegColorType.YCbCrRatio411,
new JpegComponentConfig[]
{
new(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
},
[
new JpegComponentConfig(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1)
],
yCbCrHuffmanConfigs,
yCbCrQuantTableConfigs),
// YCbCr 4:1:0
new(
new JpegFrameConfig(
JpegColorSpace.YCbCr,
JpegColorType.YCbCrRatio410,
new JpegComponentConfig[]
{
new(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
},
[
new JpegComponentConfig(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1),
new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1)
],
yCbCrHuffmanConfigs,
yCbCrQuantTableConfigs),
// Luminance
new(
new JpegFrameConfig(
JpegColorSpace.Grayscale,
JpegColorType.Luminance,
new JpegComponentConfig[]
{
new(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
},
new JpegHuffmanTableConfig[]
{
[
new JpegComponentConfig(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0)
],
[
defaultLuminanceHuffmanDC,
defaultLuminanceHuffmanAC
},
new JpegQuantizationTableConfig[]
{
],
[
defaultLuminanceQuantTable
}),
]),
// Rgb
new(
new JpegFrameConfig(
JpegColorSpace.RGB,
JpegColorType.Rgb,
new JpegComponentConfig[]
{
new(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 71, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 66, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
},
new JpegHuffmanTableConfig[]
{
[
new JpegComponentConfig(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 71, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 66, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0)
],
[
defaultLuminanceHuffmanDC,
defaultLuminanceHuffmanAC
},
new JpegQuantizationTableConfig[]
{
],
[
defaultLuminanceQuantTable
})
])
{
AdobeColorTransformMarkerFlag = JpegConstants.Adobe.ColorTransformUnknown
},
// Cmyk
new(
new JpegFrameConfig(
JpegColorSpace.Cmyk,
JpegColorType.Cmyk,
new JpegComponentConfig[]
{
new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
},
new JpegHuffmanTableConfig[]
{
[
new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0)
],
[
defaultLuminanceHuffmanDC,
defaultLuminanceHuffmanAC
},
new JpegQuantizationTableConfig[]
{
],
[
defaultLuminanceQuantTable
})
])
{
AdobeColorTransformMarkerFlag = JpegConstants.Adobe.ColorTransformUnknown,
},
// YccK
new(
new JpegFrameConfig(
JpegColorSpace.Ycck,
JpegColorType.Ycck,
new JpegComponentConfig[]
{
new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
},
new JpegHuffmanTableConfig[]
{
[
new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
new JpegComponentConfig(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0)
],
[
defaultLuminanceHuffmanDC,
defaultLuminanceHuffmanAC
},
new JpegQuantizationTableConfig[]
{
],
[
defaultLuminanceQuantTable
})
])
{
AdobeColorTransformMarkerFlag = JpegConstants.Adobe.ColorTransformYcck,
},
};
}
];
}
}

2
src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs

@ -102,7 +102,7 @@ internal sealed class IccTextDescriptionTagDataEntry : IccTagDataEntry, IEquatab
localString = new IccLocalizedString(string.Empty);
}
return new IccMultiLocalizedUnicodeTagDataEntry(new[] { localString }, textEntry.TagSignature);
return new IccMultiLocalizedUnicodeTagDataEntry([localString], textEntry.TagSignature);
static CultureInfo GetCulture(uint value)
{

2
src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs

@ -35,7 +35,7 @@ internal class AffineTransformProcessor<TPixel> : TransformProcessor<TPixel>, IR
{
this.destinationSize = definition.DestinationSize;
this.transformMatrix = definition.TransformMatrix;
this.transformMatrix4x4 = new(this.transformMatrix);
this.transformMatrix4x4 = new Matrix4x4(this.transformMatrix);
this.resampler = definition.Sampler;
}

2
tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs

@ -20,7 +20,7 @@ public class EncoderExtensionsTests
[Fact]
public void GetString_Buffer_ReturnsString()
{
ReadOnlySpan<byte> buffer = new(new byte[] { 73, 109, 97, 103, 101, 83, 104, 97, 114, 112 });
ReadOnlySpan<byte> buffer = new("ImageSharp"u8.ToArray());
string result = Encoding.UTF8.GetString(buffer);

2
tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs

@ -71,7 +71,7 @@ public class JpegMetadataTests
public void Comment_OnlyComment()
{
string comment = "test comment";
Collection<string> expectedCollection = new() { comment };
Collection<string> expectedCollection = [comment];
JpegMetadata meta = new();
meta.Comments.Add(JpegComData.FromString(comment));

111
tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs

@ -13,55 +13,60 @@ public class Vp8HistogramTests
{
get
{
List<object[]> result = new();
result.Add(new object[]
{
new byte[]
{
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 24, 16, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204
},
new byte[]
{
128, 128, 128, 128, 129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 128, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, 129, 129,
129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 128, 127, 127, 128, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, 129, 129, 129, 129, 127, 127, 127, 127,
129, 129, 129, 129, 129, 129, 128, 127, 129, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 128, 128, 128, 128, 129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 129,
129, 128, 129, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 127, 127, 129,
129, 129, 129, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 129, 129, 128, 128, 129, 129, 129, 129, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 129, 129, 129, 129, 129, 129, 129, 129, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 129, 129, 129, 129,
129, 129, 129, 129, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204
}
});
List<object[]> result =
[
[
new byte[]
{
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 19, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 19, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 24, 16, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204
},
new byte[]
{
128, 128, 128, 128, 129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 128,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128,
128, 128, 129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 128, 127,
127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128,
129, 129, 129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 129, 128, 127, 129,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, 129, 129,
129, 129, 127, 127, 127, 127, 129, 129, 129, 129, 129, 129, 129, 128, 129, 128, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 127, 127, 129, 129, 129, 129,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 129, 129, 128, 128, 129, 129, 129, 129, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 129, 129, 129, 129, 129, 129, 129, 129, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 129, 129, 129, 129, 129, 129, 129, 129, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204
}
]
];
return result;
}
}
@ -72,7 +77,7 @@ public class Vp8HistogramTests
Vp8Histogram histogram = new();
byte[] reference =
{
[
154, 154, 151, 151, 149, 148, 151, 157, 163, 163, 154, 132, 102, 98, 104, 108, 107, 104, 104, 103,
101, 106, 123, 119, 170, 171, 172, 171, 168, 175, 171, 173, 151, 151, 149, 150, 147, 147, 146, 159,
164, 165, 154, 129, 92, 90, 101, 105, 104, 103, 104, 101, 100, 105, 123, 117, 172, 172, 172, 168,
@ -99,9 +104,9 @@ public class Vp8HistogramTests
95, 102, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 151, 130,
82, 82, 89, 134, 154, 161, 161, 157, 152, 129, 81, 77, 95, 102, 204, 204, 204, 204, 204, 204, 204,
204, 204, 204, 204, 204, 204, 204, 204, 204
};
];
byte[] pred =
{
[
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129,
@ -154,7 +159,7 @@ public class Vp8HistogramTests
129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129,
129, 129, 129, 129
};
];
int expectedAlpha = 146;
// act

3
tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs

@ -570,7 +570,6 @@ public partial class ImageTests
}
private static bool ShouldSkipBitmapTest =>
!TestEnvironment.Is64BitProcess || (TestHelpers.ImageSharpBuiltAgainst != "netcoreapp3.1" &&
TestHelpers.ImageSharpBuiltAgainst != "netcoreapp2.1");
!TestEnvironment.Is64BitProcess;
}
}

8
tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs

@ -99,9 +99,9 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase
[Fact]
public void Wrap()
{
int[] data0 = { 1, 2, 3, 4 };
int[] data1 = { 5, 6, 7, 8 };
int[] data2 = { 9, 10 };
int[] data0 = [1, 2, 3, 4];
int[] data1 = [5, 6, 7, 8];
int[] data2 = [9, 10];
using TestMemoryManager<int> mgr0 = new(data0);
using TestMemoryManager<int> mgr1 = new(data1);
@ -116,7 +116,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase
Assert.True(group[2].Span.SequenceEqual(data2));
int cnt = 0;
int[][] allData = { data0, data1, data2 };
int[][] allData = [data0, data1, data2];
foreach (Memory<int> memory in group)
{
Assert.True(memory.Span.SequenceEqual(allData[cnt]));

2
tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs

@ -21,7 +21,7 @@ public class ExifReaderTests
[Fact]
public void Read_DataIsMinimal_ReturnsEmptyCollection()
{
ExifReader reader = new(new byte[] { 69, 120, 105, 102, 0, 0 });
ExifReader reader = new("Exif\0\0"u8.ToArray());
IList<IExifValue> result = reader.ReadValues();

6
tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs

@ -458,7 +458,7 @@ public class ExifValuesTests
[MemberData(nameof(NumberArrayTags))]
public void ExifNumberArrayTests(ExifTag tag)
{
Number[] expected = [new Number(uint.MaxValue)];
Number[] expected = [new(uint.MaxValue)];
ExifValue value = ExifValues.Create(tag);
Assert.False(value.TrySetValue(expected.ToString()));
@ -496,7 +496,7 @@ public class ExifValuesTests
[MemberData(nameof(RationalArrayTags))]
public void ExifRationalArrayTests(ExifTag tag)
{
Rational[] expected = [new Rational(21, 42)];
Rational[] expected = [new(21, 42)];
ExifValue value = ExifValues.Create(tag);
Assert.False(value.TrySetValue(expected.ToString()));
@ -554,7 +554,7 @@ public class ExifValuesTests
[MemberData(nameof(SignedRationalArrayTags))]
public void ExifSignedRationalArrayTests(ExifTag tag)
{
SignedRational[] expected = [new SignedRational(21, 42)];
SignedRational[] expected = [new(21, 42)];
ExifValue value = ExifValues.Create(tag);
Assert.False(value.TrySetValue(expected.ToString()));

2
tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs

@ -12,7 +12,7 @@ public class PorterDuffFunctionsTestsTPixel
private static Span<T> AsSpan<T>(T value)
where T : struct
{
return new Span<T>(new[] { value });
return new Span<T>([value]);
}
public static TheoryData<object, object, float, object> NormalBlendFunctionData = new()

12
tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs

@ -47,10 +47,10 @@ public class BokehBlurTest
public void VerifyComplexComponents()
{
// Get the saved components
List<Complex64[]> components = new();
List<Complex64[]> components = [];
foreach (Match match in Regex.Matches(Components10x2, @"\[\[(.*?)\]\]", RegexOptions.Singleline))
{
string[] values = match.Groups[1].Value.Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
string[] values = match.Groups[1].Value.Trim().Split([' '], StringSplitOptions.RemoveEmptyEntries);
Complex64[] component = values.Select(
value =>
{
@ -114,12 +114,12 @@ public class BokehBlurTest
};
public static readonly string[] TestFiles =
{
TestImages.Png.CalliphoraPartial,
[
TestImages.Png.CalliphoraPartial,
TestImages.Png.Bike,
TestImages.Png.BikeGrayscale,
TestImages.Png.Cross,
};
TestImages.Png.Cross
];
[Theory]
[WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32)]

2
tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs

@ -35,7 +35,7 @@ public class CropTest
{
using Image<TPixel> image = provider.GetImage();
image.Metadata.ExifProfile = new();
image.Metadata.ExifProfile = new ExifProfile();
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]);
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]);

4
tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs

@ -50,7 +50,7 @@ public class FlipTests
{
using Image<TPixel> image = provider.GetImage();
image.Metadata.ExifProfile = new();
image.Metadata.ExifProfile = new ExifProfile();
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]);
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]);
@ -79,7 +79,7 @@ public class FlipTests
{
using Image<TPixel> image = provider.GetImage();
image.Metadata.ExifProfile = new();
image.Metadata.ExifProfile = new ExifProfile();
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]);
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]);

2
tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs

@ -239,7 +239,7 @@ public class ProjectiveTransformTests
{
using Image<TPixel> image = provider.GetImage();
image.Metadata.ExifProfile = new();
image.Metadata.ExifProfile = new ExifProfile();
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]);
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]);

2
tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs

@ -639,7 +639,7 @@ public class ResizeTests
{
using Image<TPixel> image = provider.GetImage();
image.Metadata.ExifProfile = new();
image.Metadata.ExifProfile = new ExifProfile();
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]);
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 20, 20]);

2
tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs

@ -48,7 +48,7 @@ public class RotateTests
{
using Image<TPixel> image = provider.GetImage();
image.Metadata.ExifProfile = new();
image.Metadata.ExifProfile = new ExifProfile();
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]);
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]);

2
tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs

@ -60,7 +60,7 @@ public class SwizzleTests
{
using Image<TPixel> image = provider.GetImage();
image.Metadata.ExifProfile = new();
image.Metadata.ExifProfile = new ExifProfile();
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]);
image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 20, 20]);

53
tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs

@ -9,15 +9,14 @@ public class IccConversionDataMultiProcessElement
{
private static readonly IccMatrixProcessElement Matrix = new(
new float[,]
{
{ 2, 4, 6 },
{ 3, 5, 7 },
},
new float[] { 3, 4, 5 });
{
{ 2, 4, 6 },
{ 3, 5, 7 },
},
[3, 4, 5]);
private static readonly IccClut Clut = new(
new[]
{
[
0.2f, 0.3f,
0.4f, 0.2f,
@ -28,9 +27,9 @@ public class IccConversionDataMultiProcessElement
0.42f, 0.52f,
0.23f, 0.33f,
0.43f, 0.53f,
},
new byte[] { 2, 2, 2 },
0.43f, 0.53f
],
[2, 2, 2],
IccClutDataType.Float,
outputChannelCount: 2);
@ -42,39 +41,39 @@ public class IccConversionDataMultiProcessElement
private static readonly IccCurveSetProcessElement CurveSet1DFormula2 = Create1DSingleCurveSet(FormulaCurveElement2);
private static readonly IccCurveSetProcessElement CurveSet1DFormula3 = Create1DSingleCurveSet(FormulaCurveElement3);
private static readonly IccCurveSetProcessElement CurveSet1DFormula1And2 = Create1DMultiCurveSet(new[] { 0.5f }, FormulaCurveElement1, FormulaCurveElement2);
private static readonly IccCurveSetProcessElement CurveSet1DFormula1And2 = Create1DMultiCurveSet([0.5f], FormulaCurveElement1, FormulaCurveElement2);
private static readonly IccClutProcessElement ClutElement = new(Clut);
private static IccCurveSetProcessElement Create1DSingleCurveSet(IccCurveSegment segment)
{
IccOneDimensionalCurve curve = new(new float[0], new[] { segment });
return new IccCurveSetProcessElement(new[] { curve });
IccOneDimensionalCurve curve = new([], [segment]);
return new IccCurveSetProcessElement([curve]);
}
private static IccCurveSetProcessElement Create1DMultiCurveSet(float[] breakPoints, params IccCurveSegment[] segments)
{
IccOneDimensionalCurve curve = new(breakPoints, segments);
return new IccCurveSetProcessElement(new[] { curve });
return new IccCurveSetProcessElement([curve]);
}
public static object[][] MpeCurveConversionTestData =
{
new object[] { CurveSet1DFormula1, new[] { 0.51f }, new[] { 0.575982451f } },
new object[] { CurveSet1DFormula2, new[] { 0.52f }, new[] { -0.4684991f } },
new object[] { CurveSet1DFormula3, new[] { 0.53f }, new[] { 0.86126f } },
[
[CurveSet1DFormula1, new[] { 0.51f }, new[] { 0.575982451f }],
[CurveSet1DFormula2, new[] { 0.52f }, new[] { -0.4684991f }],
[CurveSet1DFormula3, new[] { 0.53f }, new[] { 0.86126f }],
new object[] { CurveSet1DFormula1And2, new[] { 0.31f }, new[] { 0.445982f } },
new object[] { CurveSet1DFormula1And2, new[] { 0.61f }, new[] { -0.341274023f } },
};
[CurveSet1DFormula1And2, new[] { 0.31f }, new[] { 0.445982f }],
[CurveSet1DFormula1And2, new[] { 0.61f }, new[] { -0.341274023f }]
];
public static object[][] MpeMatrixConversionTestData =
{
new object[] { Matrix, new float[] { 2, 4 }, new float[] { 19, 32, 45 } }
};
[
[Matrix, new float[] { 2, 4 }, new float[] { 19, 32, 45 }]
];
public static object[][] MpeClutConversionTestData =
{
new object[] { ClutElement, new[] { 0.5f, 0.5f, 0.5f }, new[] { 0.5f, 0.5f } }
};
[
[ClutElement, new[] { 0.5f, 0.5f, 0.5f }, new[] { 0.5f, 0.5f }]
];
}

Loading…
Cancel
Save