diff --git a/build/Build.cs b/build/Build.cs
index af3dfa3d..286a3356 100644
--- a/build/Build.cs
+++ b/build/Build.cs
@@ -38,8 +38,8 @@ partial class Build : NukeBuild
string VipsVersion => Environment.GetEnvironmentVariable("VIPS_VERSION");
- string[] NuGetArchitectures => new[]
- {
+ string[] NuGetArchitectures =>
+ [
"win-x64",
"win-x86",
"win-arm64",
@@ -50,7 +50,7 @@ partial class Build : NukeBuild
"linux-arm64",
"osx-x64",
"osx-arm64"
- };
+ ];
protected override void OnBuildInitialized()
{
diff --git a/build/common.props b/build/common.props
index da2b48d1..4c2fab4f 100644
--- a/build/common.props
+++ b/build/common.props
@@ -14,7 +14,7 @@
false
false
- 11
+ 12
2
4
diff --git a/samples/NetVips.Samples/Program.cs b/samples/NetVips.Samples/Program.cs
index aa3ec964..cae8cab6 100644
--- a/samples/NetVips.Samples/Program.cs
+++ b/samples/NetVips.Samples/Program.cs
@@ -8,11 +8,13 @@ namespace NetVips;
internal class Program
{
- private static readonly List Samples = Assembly.GetExecutingAssembly().GetTypes()
- .Where(x => x.GetInterfaces().Contains(typeof(ISample)) && x.GetConstructor(Type.EmptyTypes) != null)
- .Select(x => Activator.CreateInstance(x) as ISample)
- .OrderBy(s => s?.Category)
- .ToList();
+ private static readonly List Samples =
+ [
+ .. Assembly.GetExecutingAssembly().GetTypes()
+ .Where(x => x.GetInterfaces().Contains(typeof(ISample)) && x.GetConstructor(Type.EmptyTypes) != null)
+ .Select(x => Activator.CreateInstance(x) as ISample)
+ .OrderBy(s => s?.Category)
+ ];
private static void Main(string[] args)
{
@@ -60,7 +62,7 @@ private static void Main(string[] args)
}
// Clear any arguments
- args = Array.Empty();
+ args = [];
} while (!string.IsNullOrEmpty(input) && !string.Equals(input, "Q", StringComparison.OrdinalIgnoreCase));
}
diff --git a/samples/NetVips.Samples/SampleExtensions.cs b/samples/NetVips.Samples/SampleExtensions.cs
index edc65d6d..4765783c 100644
--- a/samples/NetVips.Samples/SampleExtensions.cs
+++ b/samples/NetVips.Samples/SampleExtensions.cs
@@ -52,7 +52,7 @@ internal static string FirstLetterToLower(this string str)
/// A new camel cased string.
internal static string ToPascalCase(this string str)
{
- return str.Split(new[] { "_" }, StringSplitOptions.RemoveEmptyEntries)
+ return str.Split(["_"], StringSplitOptions.RemoveEmptyEntries)
.Select(s => char.ToUpperInvariant(s[0]) + s[1..])
.Aggregate(string.Empty, (s1, s2) => s1 + s2);
}
diff --git a/samples/NetVips.Samples/Samples/CaptchaGenerator.cs b/samples/NetVips.Samples/Samples/CaptchaGenerator.cs
index 16e41618..a78bdb86 100644
--- a/samples/NetVips.Samples/Samples/CaptchaGenerator.cs
+++ b/samples/NetVips.Samples/Samples/CaptchaGenerator.cs
@@ -85,7 +85,7 @@ public void Execute(string[] args)
}
// remove any unused edges
- var trim = textLayer.FindTrim(background: new double[] { 0 });
+ var trim = textLayer.FindTrim(background: [0]);
using (textLayer)
{
textLayer = textLayer.Crop((int)trim[0], (int)trim[1], (int)trim[2], (int)trim[3]);
diff --git a/samples/NetVips.Samples/Samples/Duotone.cs b/samples/NetVips.Samples/Samples/Duotone.cs
index 4babfb98..12d4dc8e 100644
--- a/samples/NetVips.Samples/Samples/Duotone.cs
+++ b/samples/NetVips.Samples/Samples/Duotone.cs
@@ -13,10 +13,10 @@ public class Duotone : ISample
public const string Filename = "images/equus_quagga.jpg";
// #C83658 as CIELAB triple
- public double[] Start = { 46.479, 58.976, 15.052 };
+ public double[] Start = [46.479, 58.976, 15.052];
// #D8E74F as CIELAB triple
- public double[] Stop = { 88.12, -23.952, 69.178 };
+ public double[] Stop = [88.12, -23.952, 69.178];
public void Execute(string[] args)
{
diff --git a/samples/NetVips.Samples/Samples/GenerateImageClass.cs b/samples/NetVips.Samples/Samples/GenerateImageClass.cs
index c746c850..02bbc355 100644
--- a/samples/NetVips.Samples/Samples/GenerateImageClass.cs
+++ b/samples/NetVips.Samples/Samples/GenerateImageClass.cs
@@ -179,9 +179,9 @@ private string GenerateFunction(string operationName, string indent = "
}
string[] reservedKeywords =
- {
+ [
"in", "ref", "out", "ushort"
- };
+ ];
string SafeIdentifier(string name) =>
reservedKeywords.Contains(name)
@@ -739,7 +739,7 @@ string ToCref(string name) =>
if (optionalOutput.Length > 0 && outParameters == null)
{
result.AppendLine()
- .Append(GenerateFunction(operationName, indent, mutable, new[] { optionalOutput[0] }));
+ .Append(GenerateFunction(operationName, indent, mutable, [optionalOutput[0]]));
}
else if (outParameters != null && outParameters.Count != optionalOutput.Length)
{
diff --git a/samples/NetVips.Samples/Samples/GenerateImageOperators.cs b/samples/NetVips.Samples/Samples/GenerateImageOperators.cs
index c1501267..cb02752c 100644
--- a/samples/NetVips.Samples/Samples/GenerateImageOperators.cs
+++ b/samples/NetVips.Samples/Samples/GenerateImageOperators.cs
@@ -267,22 +267,22 @@ public string GenerateOperators()
// generate list of all operator overloads and supported types
var allOverloads = new Dictionary
{
- {"+", new[] {"Image", "double", "double[]", "int[]"}},
- {"-", new[] {"Image", "double", "double[]", "int[]"}},
- {"*", new[] {"Image", "double", "double[]", "int[]"}},
- {"/", new[] {"Image", "double", "double[]", "int[]"}},
- {"%", new[] {"Image", "double", "double[]", "int[]"}},
- {"&", new[] {"Image", "double", "double[]", "int[]"}},
- {"|", new[] {"Image", "double", "double[]", "int[]"}},
- {"^", new[] {"Image", "double", "double[]", "int[]"}},
- {"<<", new[] {"int"}},
- {">>", new[] {"int"}},
- {"==", new[] {"double", "double[]", "int[]"}},
- {"!=", new[] {"double", "double[]", "int[]"}},
- {"<", new[] {"Image", "double", "double[]", "int[]"}},
- {">", new[] {"Image", "double", "double[]", "int[]"}},
- {"<=", new[] {"Image", "double", "double[]", "int[]"}},
- {">=", new[] {"Image", "double", "double[]", "int[]"}}
+ {"+", ["Image", "double", "double[]", "int[]"]},
+ {"-", ["Image", "double", "double[]", "int[]"]},
+ {"*", ["Image", "double", "double[]", "int[]"]},
+ {"/", ["Image", "double", "double[]", "int[]"]},
+ {"%", ["Image", "double", "double[]", "int[]"]},
+ {"&", ["Image", "double", "double[]", "int[]"]},
+ {"|", ["Image", "double", "double[]", "int[]"]},
+ {"^", ["Image", "double", "double[]", "int[]"]},
+ {"<<", ["int"]},
+ {">>", ["int"]},
+ {"==", ["double", "double[]", "int[]"]},
+ {"!=", ["double", "double[]", "int[]"]},
+ {"<", ["Image", "double", "double[]", "int[]"]},
+ {">", ["Image", "double", "double[]", "int[]"]},
+ {"<=", ["Image", "double", "double[]", "int[]"]},
+ {">=", ["Image", "double", "double[]", "int[]"]}
};
const string preamble = """
diff --git a/samples/NetVips.Samples/Samples/Indexer.cs b/samples/NetVips.Samples/Samples/Indexer.cs
index 134bdb6c..606e016f 100644
--- a/samples/NetVips.Samples/Samples/Indexer.cs
+++ b/samples/NetVips.Samples/Samples/Indexer.cs
@@ -12,7 +12,7 @@ public class Indexer : ISample
public void Execute(string[] args)
{
- using var r = Image.NewFromArray(new[] { 1, 2, 3 });
+ using var r = Image.NewFromArray([1, 2, 3]);
using var g = r + 1;
using var b = r + 2;
using var image = r.Bandjoin(g, b);
diff --git a/samples/NetVips.Samples/Samples/MutableImage.cs b/samples/NetVips.Samples/Samples/MutableImage.cs
index ba0b840d..4aa38b4b 100644
--- a/samples/NetVips.Samples/Samples/MutableImage.cs
+++ b/samples/NetVips.Samples/Samples/MutableImage.cs
@@ -15,7 +15,7 @@ public void Execute(string[] args)
for (var i = 0; i <= 100; i++)
{
var j = i / 100.0;
- x.DrawLine(new[] { 255.0 }, (int)(x.Width * j), 0, 0, (int)(x.Height * (1 - j)));
+ x.DrawLine([255.0], (int)(x.Width * j), 0, 0, (int)(x.Height * (1 - j)));
}
});
mutated.WriteToFile("mutated.jpg");
diff --git a/samples/NetVips.Samples/Samples/OnePointMosaic.cs b/samples/NetVips.Samples/Samples/OnePointMosaic.cs
index 41cc056d..63893d04 100644
--- a/samples/NetVips.Samples/Samples/OnePointMosaic.cs
+++ b/samples/NetVips.Samples/Samples/OnePointMosaic.cs
@@ -11,19 +11,13 @@ public class OnePointMosaic : ISample
public string Name => "1 Point Mosaic";
public string Category => "Mosaicing";
- public struct Point
+ public struct Point(int x, int y)
{
- public int X, Y;
-
- public Point(int x, int y)
- {
- X = x;
- Y = y;
- }
+ public int X = x, Y = y;
}
- public List Images = new()
- {
+ public List Images =
+ [
"images/cd1.1.jpg",
"images/cd1.2.jpg",
"images/cd2.1.jpg",
@@ -32,10 +26,10 @@ public Point(int x, int y)
"images/cd3.2.jpg",
"images/cd4.1.jpg",
"images/cd4.2.jpg"
- };
+ ];
- public List HorizontalMarks = new()
- {
+ public List HorizontalMarks =
+ [
new Point(489, 140),
new Point(66, 141),
new Point(453, 40),
@@ -44,17 +38,17 @@ public Point(int x, int y)
new Point(65, 121),
new Point(495, 58),
new Point(40, 57)
- };
+ ];
- public List VerticalMarks = new()
- {
+ public List VerticalMarks =
+ [
new Point(364, 346),
new Point(388, 44),
new Point(385, 629),
new Point(384, 17),
new Point(503, 959),
new Point(527, 42)
- };
+ ];
public void Execute(string[] args)
{
diff --git a/samples/NetVips.Samples/Samples/ShapeCropping.cs b/samples/NetVips.Samples/Samples/ShapeCropping.cs
index 32ac55c0..fb47aa99 100644
--- a/samples/NetVips.Samples/Samples/ShapeCropping.cs
+++ b/samples/NetVips.Samples/Samples/ShapeCropping.cs
@@ -284,7 +284,7 @@ public int[] ResolveShapeTrim(int width, int height, int maskWidth, int maskHeig
var left = (int)Math.Round((width - trimWidth) / 2);
var top = (int)Math.Round((height - trimHeight) / 2);
- return new[] { left, top, (int)Math.Round(trimWidth), (int)Math.Round(trimHeight) };
+ return [left, top, (int)Math.Round(trimWidth), (int)Math.Round(trimHeight)];
}
#region helpers
diff --git a/src/NetVips/ExtensionMethods.cs b/src/NetVips/ExtensionMethods.cs
index cb4479b2..6de54690 100644
--- a/src/NetVips/ExtensionMethods.cs
+++ b/src/NetVips/ExtensionMethods.cs
@@ -88,7 +88,7 @@ internal static object[] PrependImage(this T[] args, Image image)
{
if (args == null)
{
- return new object[] { image };
+ return [image];
}
var newValues = new object[args.Length + 1];
@@ -152,7 +152,7 @@ internal static string ToUtf8String(this nint utf8Str, bool freePtr = false, int
/// The readable format of the bytes.
internal static string ToReadableBytes(this ulong value)
{
- string[] sizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
+ string[] sizeSuffixes = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
var i = 0;
decimal dValue = value;
diff --git a/src/NetVips/GObject.cs b/src/NetVips/GObject.cs
index 071a1151..aaf64af2 100644
--- a/src/NetVips/GObject.cs
+++ b/src/NetVips/GObject.cs
@@ -19,7 +19,7 @@ public class GObject : SafeHandle
///
/// All recorded delegates are freed in .
///
- private readonly ICollection _handles = new List();
+ private readonly ICollection _handles = [];
///
/// Hint of how much native memory is actually occupied by the object.
diff --git a/src/NetVips/Image.cs b/src/NetVips/Image.cs
index 4e0cb7ae..19cd937f 100644
--- a/src/NetVips/Image.cs
+++ b/src/NetVips/Image.cs
@@ -1236,7 +1236,7 @@ public string[] GetFields()
GLib.GFree(ptrArr);
- return names.ToArray();
+ return [.. names];
}
///
@@ -1378,7 +1378,7 @@ public Image Case(params int[] ints) =>
/// Array of case images.
/// A new .
public Image Case(params Image[] images) =>
- this.Call("case", new object[] { images }) as Image;
+ this.Call("case", [images]) as Image;
///
/// Use pixel values to pick cases from an a set of mixed images and constants.
@@ -1391,7 +1391,7 @@ public Image Case(params Image[] images) =>
/// Array of mixed images and constants.
/// A new .
public Image Case(params object[] objects) =>
- this.Call("case", new object[] { objects }) as Image;
+ this.Call("case", [objects]) as Image;
///
/// Append a set of constants bandwise.
@@ -1430,7 +1430,7 @@ public Image Bandjoin(params int[] ints) =>
/// Array of images.
/// A new .
public Image Bandjoin(params Image[] images) =>
- this.Call("bandjoin", new object[] { images.PrependImage(this) }) as Image;
+ this.Call("bandjoin", [images.PrependImage(this)]) as Image;
///
/// Append a set of mixed images and constants bandwise.
@@ -1443,7 +1443,7 @@ public Image Bandjoin(params Image[] images) =>
/// Array of mixed images and constants.
/// A new .
public Image Bandjoin(params object[] objects) =>
- this.Call("bandjoin", new object[] { objects.PrependImage(this) }) as Image;
+ this.Call("bandjoin", [objects.PrependImage(this)]) as Image;
///
/// Band-wise rank a set of constants.
@@ -1496,7 +1496,7 @@ public Image Bandrank(Image[] images, int? index = null)
options.AddIfPresent(nameof(index), index);
- return this.Call("bandrank", options, new object[] { images.PrependImage(this) }) as Image;
+ return this.Call("bandrank", options, [images.PrependImage(this)]) as Image;
}
///
@@ -1511,7 +1511,7 @@ public Image Bandrank(Image[] images, int? index = null)
/// Select this band element from sorted list.
/// A new .
public Image Bandrank(Image other, int? index = null) =>
- Bandrank(new[] { other }, index);
+ Bandrank([other], index);
///
/// Band-wise rank a set of mixed images and constants.
@@ -1530,7 +1530,7 @@ public Image Bandrank(object[] objects, int? index = null)
options.AddIfPresent(nameof(index), index);
- return this.Call("bandrank", options, new object[] { objects.PrependImage(this) }) as Image;
+ return this.Call("bandrank", options, [objects.PrependImage(this)]) as Image;
}
///
@@ -1603,7 +1603,7 @@ public Image Crop(int left, int top, int width, int height) =>
public double[] MaxPos()
{
var v = Max(out var x, out var y);
- return new[] { v, x, y };
+ return [v, x, y];
}
///
@@ -1613,7 +1613,7 @@ public double[] MaxPos()
public double[] MinPos()
{
var v = Min(out var x, out var y);
- return new[] { v, x, y };
+ return [v, x, y];
}
///
@@ -1754,7 +1754,7 @@ public double[] MinPos()
///
/// To the power of this.
/// A new .
- public Image Pow(double exp) => Math2Const(Enums.OperationMath2.Pow, new[] { exp });
+ public Image Pow(double exp) => Math2Const(Enums.OperationMath2.Pow, [exp]);
///
/// Raise to power of an array.
@@ -1783,7 +1783,7 @@ public Image Pow(int[] exp) =>
///
/// To the base of this.
/// A new .
- public Image Wop(double @base) => Math2Const(Enums.OperationMath2.Wop, new[] { @base });
+ public Image Wop(double @base) => Math2Const(Enums.OperationMath2.Wop, [@base]);
///
/// Raise to power of an array, but with the arguments reversed.
@@ -1812,7 +1812,7 @@ public Image Wop(int[] @base) =>
///
/// Arc tangent of y / .
/// A new .
- public Image Atan2(double x) => Math2Const(Enums.OperationMath2.Atan2, new[] { x });
+ public Image Atan2(double x) => Math2Const(Enums.OperationMath2.Atan2, [x]);
///
/// Arc tangent of an array in degrees.
diff --git a/src/NetVips/Introspect.cs b/src/NetVips/Introspect.cs
index 7dc2a210..e268bb28 100644
--- a/src/NetVips/Introspect.cs
+++ b/src/NetVips/Introspect.cs
@@ -55,22 +55,22 @@ public struct Argument
///
/// The required input for this operation.
///
- public readonly List RequiredInput = new();
+ public readonly List RequiredInput = [];
///
/// The optional input for this operation.
///
- public readonly Dictionary OptionalInput = new();
+ public readonly Dictionary OptionalInput = [];
///
/// The required output for this operation.
///
- public readonly List RequiredOutput = new();
+ public readonly List RequiredOutput = [];
///
/// The optional output for this operation.
///
- public readonly Dictionary OptionalOutput = new();
+ public readonly Dictionary OptionalOutput = [];
///
/// Build introspection data for a specified operation name.
diff --git a/src/NetVips/ModuleInitializer.cs b/src/NetVips/ModuleInitializer.cs
index 0e210636..d2aa2ca4 100644
--- a/src/NetVips/ModuleInitializer.cs
+++ b/src/NetVips/ModuleInitializer.cs
@@ -36,7 +36,7 @@ public static class ModuleInitializer
///
/// A cache for .
///
- internal static readonly Dictionary DllImportCache = new();
+ internal static readonly Dictionary DllImportCache = [];
internal static string RemapLibraryName(string libraryName)
{
diff --git a/src/NetVips/NetVips.cs b/src/NetVips/NetVips.cs
index b7bd68ca..9f5d51d9 100644
--- a/src/NetVips/NetVips.cs
+++ b/src/NetVips/NetVips.cs
@@ -214,12 +214,12 @@ public static bool BlockUntrusted
[Obsolete("NetVips.MemoryStats is deprecated, please use the Stats class instead.")]
public static int[] MemoryStats()
{
- return new[]
- {
+ return
+ [
Stats.Allocations,
Stats.Mem,
Stats.Files
- };
+ ];
}
///
@@ -319,7 +319,7 @@ public static string[] GetSuffixes()
GLib.GFree(ptrArr);
- return names.ToArray();
+ return [.. names];
}
///
diff --git a/src/NetVips/VOption.cs b/src/NetVips/VOption.cs
index 973fbb2d..217b05a2 100644
--- a/src/NetVips/VOption.cs
+++ b/src/NetVips/VOption.cs
@@ -10,7 +10,7 @@ namespace NetVips;
///
public class VOption : IEnumerable>
{
- private readonly Dictionary _internalDictionary = new();
+ private readonly Dictionary _internalDictionary = [];
///
/// Returns an enumerator that iterates through the .
diff --git a/tests/NetVips.Benchmarks/ImageSharp/ConvolutionProcessor.cs b/tests/NetVips.Benchmarks/ImageSharp/ConvolutionProcessor.cs
index c324da25..4c233d63 100644
--- a/tests/NetVips.Benchmarks/ImageSharp/ConvolutionProcessor.cs
+++ b/tests/NetVips.Benchmarks/ImageSharp/ConvolutionProcessor.cs
@@ -9,28 +9,23 @@ namespace NetVips.Benchmarks.ImageSharp;
///
/// Defines a processor that uses a 2 dimensional matrix to perform convolution against an image.
///
-public sealed class ConvolutionProcessor : IImageProcessor
+///
+/// Initializes a new instance of the class.
+///
+/// The 2d gradient operator.
+/// Whether the convolution filter is applied to alpha as well as the color channels.
+public sealed class ConvolutionProcessor(in DenseMatrix kernelXY, bool preserveAlpha) : IImageProcessor
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// The 2d gradient operator.
- /// Whether the convolution filter is applied to alpha as well as the color channels.
- public ConvolutionProcessor(in DenseMatrix kernelXY, bool preserveAlpha)
- {
- KernelXY = kernelXY;
- PreserveAlpha = preserveAlpha;
- }
///
/// Gets the 2d gradient operator.
///
- public DenseMatrix KernelXY { get; }
+ public DenseMatrix KernelXY { get; } = kernelXY;
///
/// Gets a value indicating whether the convolution filter is applied to alpha as well as the color channels.
///
- public bool PreserveAlpha { get; }
+ public bool PreserveAlpha { get; } = preserveAlpha;
///
public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration,
@@ -39,17 +34,17 @@ public IImageProcessor CreatePixelSpecificProcessor(Configuratio
{
var type = Type.GetType(
"SixLabors.ImageSharp.Processing.Processors.Convolution.ConvolutionProcessor`1, SixLabors.ImageSharp");
- Type[] typeArgs = { typeof(TPixel) };
+ Type[] typeArgs = [typeof(TPixel)];
var genericType = type.MakeGenericType(typeArgs);
Type[] parameterTypes =
- {
+ [
configuration.GetType(), KernelXY.GetType().MakeByRefType(), PreserveAlpha.GetType(), source.GetType(),
sourceRectangle.GetType()
- };
+ ];
var ctor = genericType.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null,
parameterTypes, null);
var instance =
- ctor.Invoke(new object[] { configuration, KernelXY, PreserveAlpha, source, sourceRectangle });
+ ctor.Invoke([configuration, KernelXY, PreserveAlpha, source, sourceRectangle]);
return (IImageProcessor)instance;
}
diff --git a/tests/NetVips.Tests/ArithmeticTests.cs b/tests/NetVips.Tests/ArithmeticTests.cs
index dd548932..8261ef7d 100644
--- a/tests/NetVips.Tests/ArithmeticTests.cs
+++ b/tests/NetVips.Tests/ArithmeticTests.cs
@@ -20,11 +20,11 @@ public ArithmeticTests(TestsFixture testsFixture, ITestOutputHelper output)
_image = Image.MaskIdeal(100, 100, 0.5, reject: true, optical: true);
_colour = _image * new[] { 1, 2, 3 } + new[] { 2, 3, 4 };
_mono = _colour[1];
- _allImages = new[]
- {
+ _allImages =
+ [
_mono,
_colour
- };
+ ];
}
#region helpers
@@ -439,10 +439,10 @@ dynamic Abs(dynamic x)
}
var im = _colour * -1;
- RunUnary(new[]
- {
+ RunUnary(
+ [
im
- }, Abs);
+ ], Abs);
}
[Fact]
@@ -530,7 +530,7 @@ dynamic Invert(dynamic x)
// image ^ -1 is trimmed to image max so it's hard to test for all formats
// just test uchar
- RunUnary(_allImages, Invert, new[] { Enums.BandFormat.Uchar });
+ RunUnary(_allImages, Invert, [Enums.BandFormat.Uchar]);
}
#endregion
@@ -605,23 +605,23 @@ public void TestHistFind()
foreach (var fmt in Helper.AllFormats)
{
var hist = test.Cast(fmt).HistFind();
- Assert.Equal(new double[] { 5000 }, hist[0, 0]);
- Assert.Equal(new double[] { 5000 }, hist[10, 0]);
- Assert.Equal(new double[] { 0 }, hist[5, 0]);
+ Assert.Equal([5000], hist[0, 0]);
+ Assert.Equal([5000], hist[10, 0]);
+ Assert.Equal([0], hist[5, 0]);
}
test *= new[] { 1, 2, 3 };
foreach (var fmt in Helper.AllFormats)
{
var hist = test.Cast(fmt).HistFind(band: 0);
- Assert.Equal(new double[] { 5000 }, hist[0, 0]);
- Assert.Equal(new double[] { 5000 }, hist[10, 0]);
- Assert.Equal(new double[] { 0 }, hist[5, 0]);
+ Assert.Equal([5000], hist[0, 0]);
+ Assert.Equal([5000], hist[10, 0]);
+ Assert.Equal([0], hist[5, 0]);
hist = test.Cast(fmt).HistFind(band: 1);
- Assert.Equal(new double[] { 5000 }, hist[0, 0]);
- Assert.Equal(new double[] { 5000 }, hist[20, 0]);
- Assert.Equal(new double[] { 0 }, hist[5, 0]);
+ Assert.Equal([5000], hist[0, 0]);
+ Assert.Equal([5000], hist[20, 0]);
+ Assert.Equal([0], hist[5, 0]);
}
}
@@ -641,8 +641,8 @@ public void TestHistFindIndexed()
var a = test.Cast(x);
var b = index.Cast(y);
var hist = a.HistFindIndexed(b);
- Assert.Equal(new double[] { 0 }, hist[0, 0]);
- Assert.Equal(new double[] { 50000 }, hist[1, 0]);
+ Assert.Equal([0], hist[0, 0]);
+ Assert.Equal([50000], hist[1, 0]);
}
}
}
@@ -671,7 +671,7 @@ public void TestHistFindNdim()
[Fact]
public void TestHoughCircle()
{
- var test = Image.Black(100, 100).Mutate(x => x.DrawCircle(new double[] { 100 }, 50, 50, 40));
+ var test = Image.Black(100, 100).Mutate(x => x.DrawCircle([100], 50, 50, 40));
foreach (var fmt in Helper.AllFormats)
{
@@ -699,7 +699,7 @@ public void TestHoughLine()
// test earlier versions
Skip.IfNot(NetVips.AtLeastLibvips(8, 7), "requires libvips >= 8.7");
- var test = Image.Black(100, 100).Mutate(x => x.DrawLine(new double[] { 100 }, 10, 90, 90, 10));
+ var test = Image.Black(100, 100).Mutate(x => x.DrawLine([100], 10, 90, 90, 10));
foreach (var fmt in Helper.AllFormats)
{
@@ -780,7 +780,7 @@ dynamic Asin(dynamic x)
}
var im = (Image.Black(100, 100) + new[] { 1, 2, 3 }) / 3.0;
- RunUnary(new[] { im }, Asin, Helper.NonComplexFormats);
+ RunUnary([im], Asin, Helper.NonComplexFormats);
}
[Fact]
@@ -797,7 +797,7 @@ dynamic Acos(dynamic x)
}
var im = (Image.Black(100, 100) + new[] { 1, 2, 3 }) / 3.0;
- RunUnary(new[] { im }, Acos, Helper.NonComplexFormats);
+ RunUnary([im], Acos, Helper.NonComplexFormats);
}
[Fact]
@@ -814,7 +814,7 @@ dynamic Atan(dynamic x)
}
var im = (Image.Black(100, 100) + new[] { 1, 2, 3 }) / 3.0;
- RunUnary(new[] { im }, Atan, Helper.NonComplexFormats);
+ RunUnary([im], Atan, Helper.NonComplexFormats);
}
[SkippableFact]
@@ -888,7 +888,7 @@ dynamic Asinh(dynamic x)
}
var im = (Image.Black(100, 100) + new[] { 4, 5, 6 }) / 3.0;
- RunUnary(new[] { im }, Asinh, Helper.NonComplexFormats);
+ RunUnary([im], Asinh, Helper.NonComplexFormats);
}
[SkippableFact]
@@ -907,7 +907,7 @@ dynamic Acosh(dynamic x)
}
var im = (Image.Black(100, 100) + new[] { 4, 5, 6 }) / 3.0;
- RunUnary(new[] { im }, Acosh, Helper.NonComplexFormats);
+ RunUnary([im], Acosh, Helper.NonComplexFormats);
}
[SkippableFact]
@@ -926,7 +926,7 @@ dynamic Atanh(dynamic x)
}
var im = (Image.Black(100, 100) + new[] { 0, 1, 2 }) / 3.0;
- RunUnary(new[] { im }, Atanh, Helper.NonComplexFormats);
+ RunUnary([im], Atanh, Helper.NonComplexFormats);
}
#endif
@@ -1090,7 +1090,7 @@ dynamic Sign(dynamic x)
[Fact]
public void TestMax()
{
- var test = Image.Black(100, 100).Mutate(x => x.DrawRect(new double[] { 100 }, 40, 50, 1, 1));
+ var test = Image.Black(100, 100).Mutate(x => x.DrawRect([100], 40, 50, 1, 1));
foreach (var fmt in Helper.AllFormats)
{
@@ -1112,7 +1112,7 @@ public void TestMax()
[Fact]
public void TestMin()
{
- var test = (Image.Black(100, 100) + 100).Mutate(x => x.DrawRect(new double[] { 0 }, 40, 50, 1, 1));
+ var test = (Image.Black(100, 100) + 100).Mutate(x => x.DrawRect([0], 40, 50, 1, 1));
foreach (var fmt in Helper.AllFormats)
{
@@ -1173,7 +1173,7 @@ public void TestFindTrim()
}
var testRgb = test.Bandjoin(test, test);
- var trim2 = testRgb.FindTrim(background: new double[] { 255, 255, 255 });
+ var trim2 = testRgb.FindTrim(background: [255, 255, 255]);
var left2 = trim2[0];
var top2 = trim2[1];
var width2 = trim2[2];
@@ -1188,7 +1188,7 @@ public void TestFindTrim()
[Fact]
public void TestProfile()
{
- var test = Image.Black(100, 100).Mutate(x => x.DrawRect(new double[] { 100 }, 40, 50, 1, 1));
+ var test = Image.Black(100, 100).Mutate(x => x.DrawRect([100], 40, 50, 1, 1));
foreach (var fmt in Helper.NonComplexFormats)
{
@@ -1228,10 +1228,10 @@ public void TestProject()
var columns = (Image)profile[0];
var rows = (Image)profile[1];
- Assert.Equal(new double[] { 0 }, columns[10, 0]);
- Assert.Equal(new double[] { 50 * 10 }, columns[70, 0]);
+ Assert.Equal([0], columns[10, 0]);
+ Assert.Equal([50 * 10], columns[70, 0]);
- Assert.Equal(new double[] { 50 * 10 }, rows[0, 10]);
+ Assert.Equal([50 * 10], rows[0, 10]);
}
}
@@ -1248,15 +1248,15 @@ public void TestStats()
Assert.Equal(new[] { a.Min() }, matrix[0, 0]);
Assert.Equal(new[] { a.Max() }, matrix[1, 0]);
- Assert.Equal(new double[] { 50 * 50 * 10 }, matrix[2, 0]);
- Assert.Equal(new double[] { 50 * 50 * 100 }, matrix[3, 0]);
+ Assert.Equal([50 * 50 * 10], matrix[2, 0]);
+ Assert.Equal([50 * 50 * 100], matrix[3, 0]);
Assert.Equal(new[] { a.Avg() }, matrix[4, 0]);
Assert.Equal(new[] { a.Deviate() }, matrix[5, 0]);
Assert.Equal(new[] { a.Min() }, matrix[0, 1]);
Assert.Equal(new[] { a.Max() }, matrix[1, 1]);
- Assert.Equal(new double[] { 50 * 50 * 10 }, matrix[2, 1]);
- Assert.Equal(new double[] { 50 * 50 * 100 }, matrix[3, 1]);
+ Assert.Equal([50 * 50 * 10], matrix[2, 1]);
+ Assert.Equal([50 * 50 * 100], matrix[3, 1]);
Assert.Equal(new[] { a.Avg() }, matrix[4, 1]);
Assert.Equal(new[] { a.Deviate() }, matrix[5, 1]);
}
diff --git a/tests/NetVips.Tests/ColourTests.cs b/tests/NetVips.Tests/ColourTests.cs
index 12d03837..b9aa4618 100644
--- a/tests/NetVips.Tests/ColourTests.cs
+++ b/tests/NetVips.Tests/ColourTests.cs
@@ -22,7 +22,7 @@ public void TestColourspace()
// a long series should come in a circle
var im = test;
- foreach (var col in Helper.ColourColourspaces.Concat(new[] { Enums.Interpretation.Lab }))
+ foreach (var col in Helper.ColourColourspaces.Concat([Enums.Interpretation.Lab]))
{
im = im.Colourspace(col);
Assert.Equal(col, im.Interpretation);
@@ -86,7 +86,7 @@ public void TestColourspace()
{
var testGrey = test.Colourspace(monoFmt);
im = testGrey;
- foreach (var col in Helper.ColourColourspaces.Concat(new[] { monoFmt }))
+ foreach (var col in Helper.ColourColourspaces.Concat([monoFmt]))
{
im = im.Colourspace(col);
Assert.Equal(col, im.Interpretation);
diff --git a/tests/NetVips.Tests/ConversionTests.cs b/tests/NetVips.Tests/ConversionTests.cs
index 5f33ba3e..dd480220 100644
--- a/tests/NetVips.Tests/ConversionTests.cs
+++ b/tests/NetVips.Tests/ConversionTests.cs
@@ -22,11 +22,11 @@ public ConversionTests(TestsFixture testsFixture, ITestOutputHelper output)
_colour = _colour.Copy(interpretation: Enums.Interpretation.Srgb);
_mono = _colour[1];
_mono = _mono.Copy(interpretation: Enums.Interpretation.Bw);
- _allImages = new[]
- {
+ _allImages =
+ [
_mono,
_colour
- };
+ ];
_image = Image.Jpegload(Helper.JpegFile);
}
@@ -300,24 +300,24 @@ public void TestEmbed()
var im = test.Embed(20, 20, _colour.Width + 40, _colour.Height + 40);
var pixel = im[10, 10];
- Assert.Equal(new double[] { 0, 0, 0 }, pixel);
+ Assert.Equal([0, 0, 0], pixel);
pixel = im[30, 30];
- Assert.Equal(new double[] { 2, 3, 4 }, pixel);
+ Assert.Equal([2, 3, 4], pixel);
pixel = im[im.Width - 10, im.Height - 10];
- Assert.Equal(new double[] { 0, 0, 0 }, pixel);
+ Assert.Equal([0, 0, 0], pixel);
im = test.Embed(20, 20, _colour.Width + 40, _colour.Height + 40, extend: Enums.Extend.Copy);
pixel = im[10, 10];
- Assert.Equal(new double[] { 2, 3, 4 }, pixel);
+ Assert.Equal([2, 3, 4], pixel);
pixel = im[im.Width - 10, im.Height - 10];
- Assert.Equal(new double[] { 2, 3, 4 }, pixel);
+ Assert.Equal([2, 3, 4], pixel);
im = test.Embed(20, 20, _colour.Width + 40, _colour.Height + 40, extend: Enums.Extend.Background,
- background: new double[] { 7, 8, 9 });
+ background: [7, 8, 9]);
pixel = im[10, 10];
- Assert.Equal(new double[] { 7, 8, 9 }, pixel);
+ Assert.Equal([7, 8, 9], pixel);
pixel = im[im.Width - 10, im.Height - 10];
- Assert.Equal(new double[] { 7, 8, 9 }, pixel);
+ Assert.Equal([7, 8, 9], pixel);
im = test.Embed(20, 20, _colour.Width + 40, _colour.Height + 40, extend: Enums.Extend.White);
@@ -325,10 +325,10 @@ public void TestEmbed()
// uses 255 in all bytes of ints, 255.0 for float
var pixelLongs = pixel.Select(x => (double)(Convert.ToInt64(x) & 255));
- Assert.Equal(new double[] { 255, 255, 255 }, pixelLongs);
+ Assert.Equal([255, 255, 255], pixelLongs);
pixel = im[im.Width - 10, im.Height - 10];
pixelLongs = pixel.Select(x => (double)(Convert.ToInt64(x) & 255));
- Assert.Equal(new double[] { 255, 255, 255 }, pixelLongs);
+ Assert.Equal([255, 255, 255], pixelLongs);
}
}
@@ -340,15 +340,15 @@ public void TestGravity()
var im = Image.Black(1, 1) + 255;
var positions = new Dictionary
{
- {Enums.CompassDirection.Centre, new[] {1, 1}},
- {Enums.CompassDirection.North, new[] {1, 0}},
- {Enums.CompassDirection.South, new[] {1, 2}},
- {Enums.CompassDirection.East, new[] {2, 1}},
- {Enums.CompassDirection.West, new[] {0, 1}},
- {Enums.CompassDirection.NorthEast, new[] {2, 0}},
- {Enums.CompassDirection.SouthEast, new[] {2, 2}},
- {Enums.CompassDirection.SouthWest, new[] {0, 2}},
- {Enums.CompassDirection.NorthWest, new[] {0, 0}}
+ {Enums.CompassDirection.Centre, [1, 1] },
+ {Enums.CompassDirection.North, [1, 0] },
+ {Enums.CompassDirection.South, [1, 2] },
+ {Enums.CompassDirection.East, [2, 1] },
+ {Enums.CompassDirection.West, [0, 1] },
+ {Enums.CompassDirection.NorthEast, [2, 0] },
+ {Enums.CompassDirection.SouthEast, [2, 2] },
+ {Enums.CompassDirection.SouthWest, [0, 2] },
+ {Enums.CompassDirection.NorthWest, [0, 0] }
};
foreach (var (direction, value) in positions)
@@ -356,7 +356,7 @@ public void TestGravity()
var x = value[0];
var y = value[1];
var im2 = im.Gravity(direction, 3, 3);
- Assert.Equal(new double[] { 255 }, im2[x, y]);
+ Assert.Equal([255], im2[x, y]);
Assert.Equal(255.0 / 9.0, im2.Avg());
}
}
@@ -369,17 +369,17 @@ public void TestExtract()
var test = _colour.Cast(fmt);
var pixel = test[30, 30];
- Assert.Equal(new double[] { 2, 3, 4 }, pixel);
+ Assert.Equal([2, 3, 4], pixel);
var sub = test.ExtractArea(25, 25, 10, 10);
pixel = sub[5, 5];
- Assert.Equal(new double[] { 2, 3, 4 }, pixel);
+ Assert.Equal([2, 3, 4], pixel);
sub = test.ExtractBand(1, n: 2);
pixel = sub[30, 30];
- Assert.Equal(new double[] { 3, 4 }, pixel);
+ Assert.Equal([3, 4], pixel);
}
}
@@ -424,10 +424,10 @@ public void TestCrop()
{
var test = _colour.Cast(fmt);
var pixel = test[30, 30];
- Assert.Equal(new double[] { 2, 3, 4 }, pixel);
+ Assert.Equal([2, 3, 4], pixel);
var sub = test.Crop(25, 25, 10, 10);
pixel = sub[5, 5];
- Assert.Equal(new double[] { 2, 3, 4 }, pixel);
+ Assert.Equal([2, 3, 4], pixel);
}
}
@@ -455,7 +455,7 @@ public void TestFalsecolour()
Assert.Equal(3, im.Bands);
var pixel = im[30, 30];
- Assert.Equal(new double[] { 20, 0, 41 }, pixel);
+ Assert.Equal([20, 0, 41], pixel);
}
}
@@ -467,7 +467,7 @@ public void TestFlatten()
const double nalpha = mx - alpha;
foreach (var fmt in Helper.UnsignedFormats
- .Concat(new[] { Enums.BandFormat.Short, Enums.BandFormat.Int })
+ .Concat([Enums.BandFormat.Short, Enums.BandFormat.Int])
.Concat(Helper.FloatFormats))
{
var test = _colour.Bandjoin(alpha).Cast(fmt);
@@ -491,7 +491,7 @@ public void TestFlatten()
Assert.Equal(x, y, 2.0);
}
- im = test.Flatten(background: new double[] { 100, 100, 100 });
+ im = test.Flatten(background: [100, 100, 100]);
pixel = test[30, 30];
predict = pixel.Take(pixel.Length - 1)
@@ -517,7 +517,7 @@ public void TestPremultiply()
const double alpha = mx / 2.0;
foreach (var fmt in Helper.UnsignedFormats
- .Concat(new[] { Enums.BandFormat.Short, Enums.BandFormat.Int })
+ .Concat([Enums.BandFormat.Short, Enums.BandFormat.Int])
.Concat(Helper.FloatFormats))
{
var test = _colour.Bandjoin(alpha).Cast(fmt);
@@ -525,7 +525,7 @@ public void TestPremultiply()
var predict = pixel.Take(pixel.Length - 1)
.Select(x => Convert.ToInt32(x) * alpha / mx)
- .Concat(new[] { alpha })
+ .Concat([alpha])
.ToArray();
var im = test.Premultiply();
@@ -564,7 +564,7 @@ public void TestUnpremultiply()
const double alpha = mx / 2.0;
foreach (var fmt in Helper.UnsignedFormats
- .Concat(new[] { Enums.BandFormat.Short, Enums.BandFormat.Int })
+ .Concat([Enums.BandFormat.Short, Enums.BandFormat.Int])
.Concat(Helper.FloatFormats))
{
var test = _colour.Bandjoin(alpha).Cast(fmt);
@@ -572,7 +572,7 @@ public void TestUnpremultiply()
var predict = pixel.Take(pixel.Length - 1)
.Select(x => Convert.ToInt32(x) / (alpha / mx))
- .Concat(new[] { alpha })
+ .Concat([alpha])
.ToArray();
var im = test.Unpremultiply();
@@ -758,7 +758,7 @@ public void TestIfthenelse()
Assert.Equal(_colour.Bands, r.Bands);
var result = r[10, 10];
- Assert.Equal(new double[] { 3, 3, 13 }, result);
+ Assert.Equal([3, 3, 13], result);
}
}
@@ -771,9 +771,9 @@ public void TestIfthenelse()
Assert.Equal(_colour.Format, r2.Format);
Assert.Equal(_colour.Interpretation, r2.Interpretation);
var result2 = r2[10, 10];
- Assert.Equal(new double[] { 2, 3, 4 }, result2);
+ Assert.Equal([2, 3, 4], result2);
result2 = r2[50, 50];
- Assert.Equal(new double[] { 1, 2, 3 }, result2);
+ Assert.Equal([1, 2, 3], result2);
test = _mono;
r2 = test.Ifthenelse(new[] { 1, 2, 3 }, _colour, blend: true);
@@ -846,14 +846,14 @@ public void TestInsert()
{
var main = _mono.Cast(x);
var sub = _colour.Cast(y);
- var r = main.Insert(sub, 10, 10, expand: true, background: new double[] { 100 });
+ var r = main.Insert(sub, 10, 10, expand: true, background: [100]);
Assert.Equal(main.Width + 10, r.Width);
Assert.Equal(main.Height + 10, r.Height);
Assert.Equal(sub.Bands, r.Bands);
var a = r[r.Width - 5, 5];
- Assert.Equal(new double[] { 100, 100, 100 }, a);
+ Assert.Equal([100, 100, 100], a);
}
}
}
@@ -970,7 +970,7 @@ dynamic Recomb(dynamic x)
{
if (x is Image image)
{
- return image.Recomb(Image.NewFromArray(new[] { array }));
+ return image.Recomb(Image.NewFromArray([array]));
}
var sum = array
@@ -984,7 +984,7 @@ dynamic Recomb(dynamic x)
};
}
- RunUnary(new[] { _colour }, Recomb, Helper.NonComplexFormats);
+ RunUnary([_colour], Recomb, Helper.NonComplexFormats);
}
[Fact]
diff --git a/tests/NetVips.Tests/ConvolutionTests.cs b/tests/NetVips.Tests/ConvolutionTests.cs
index 79815cbc..8bb95462 100644
--- a/tests/NetVips.Tests/ConvolutionTests.cs
+++ b/tests/NetVips.Tests/ConvolutionTests.cs
@@ -28,11 +28,11 @@ public ConvolutionTests(TestsFixture testsFixture, ITestOutputHelper output)
_colour = _colour.Copy(interpretation: Enums.Interpretation.Srgb);
_mono = _colour[0];
_mono = _mono.Copy(interpretation: Enums.Interpretation.Bw);
- _allImages = new[]
- {
+ _allImages =
+ [
_mono,
_colour
- };
+ ];
_sharp = Image.NewFromArray(new[,]
{
{-1, -1, -1},
@@ -57,7 +57,7 @@ public ConvolutionTests(TestsFixture testsFixture, ITestOutputHelper output)
{0, 0, 0},
{-1, -2, -1}
});
- _allMasks = new[] { _sharp, _blur, _line, _sobel };
+ _allMasks = [_sharp, _blur, _line, _sobel];
}
#region helpers
diff --git a/tests/NetVips.Tests/CreateTests.cs b/tests/NetVips.Tests/CreateTests.cs
index c2092173..948cf575 100644
--- a/tests/NetVips.Tests/CreateTests.cs
+++ b/tests/NetVips.Tests/CreateTests.cs
@@ -39,18 +39,17 @@ public void TestBlack()
{
var pixel = im[i, i];
Assert.Equal(3, pixel.Length);
- Assert.Equal(new double[] { 0, 0, 0 }, pixel);
+ Assert.Equal([0, 0, 0], pixel);
}
}
[Fact]
public void TestBuildlut()
{
- var m = Image.NewFromArray(new[]
- {
- new double[] {0, 0},
- new double[] {255, 100}
- });
+ var m = Image.NewFromArray([
+ [0, 0],
+ [255, 100]
+ ]);
var lut = m.Buildlut();
Assert.Equal(256, lut.Width);
Assert.Equal(1, lut.Height);
@@ -62,12 +61,11 @@ public void TestBuildlut()
p = lut[10, 0];
Assert.Equal(100 * 10.0 / 255.0, p[0]);
- m = Image.NewFromArray(new[]
- {
- new double[] {0, 0, 100},
- new double[] {255, 100, 0},
- new double[] {128, 10, 90}
- });
+ m = Image.NewFromArray([
+ [0, 0, 100],
+ [255, 100, 0],
+ [128, 10, 90]
+ ]);
lut = m.Buildlut();
Assert.Equal(256, lut.Width);
Assert.Equal(1, lut.Height);
@@ -241,9 +239,9 @@ public void TestInvertlut()
Assert.Equal(Enums.BandFormat.Double, im.Format);
var p = im[0, 0];
- Assert.Equal(new double[] { 0, 0, 0 }, p);
+ Assert.Equal([0, 0, 0], p);
p = im[255, 0];
- Assert.Equal(new double[] { 1, 1, 1 }, p);
+ Assert.Equal([1, 1, 1], p);
p = im[(int)0.2 * 255, 0];
Assert.Equal(0, p[0], 1);
p = im[(int)0.3 * 255, 0];
@@ -527,7 +525,7 @@ public void TestXyz()
Assert.Equal(128, im.Width);
Assert.Equal(128, im.Height);
var p = im[45, 35];
- Assert.Equal(new double[] { 45, 35 }, p);
+ Assert.Equal([45, 35], p);
}
[Fact]
diff --git a/tests/NetVips.Tests/DrawTests.cs b/tests/NetVips.Tests/DrawTests.cs
index bb777f7e..2f8f466a 100644
--- a/tests/NetVips.Tests/DrawTests.cs
+++ b/tests/NetVips.Tests/DrawTests.cs
@@ -14,7 +14,7 @@ public DrawTests(TestsFixture testsFixture, ITestOutputHelper output)
public void TestDrawCircle()
{
var im = Image.Black(100, 100);
- im = im.Mutate(x => x.DrawCircle(new double[] { 100 }, 50, 50, 25));
+ im = im.Mutate(x => x.DrawCircle([100], 50, 50, 25));
var pixel = im[25, 50];
Assert.Single(pixel);
Assert.Equal(100, pixel[0]);
@@ -23,7 +23,7 @@ public void TestDrawCircle()
Assert.Equal(0, pixel[0]);
im = Image.Black(100, 100);
- im = im.Mutate(x => x.DrawCircle(new double[] { 100 }, 50, 50, 25, fill: true));
+ im = im.Mutate(x => x.DrawCircle([100], 50, 50, 25, fill: true));
pixel = im[25, 50];
Assert.Single(pixel);
Assert.Equal(100, pixel[0]);
@@ -39,12 +39,12 @@ public void TestDrawFlood()
var im = Image.Black(100, 100);
im = im.Mutate(x =>
{
- x.DrawCircle(new double[] { 100 }, 50, 50, 25);
- x.DrawFlood(new double[] { 100 }, 50, 50);
+ x.DrawCircle([100], 50, 50, 25);
+ x.DrawFlood([100], 50, 50);
});
var im2 = Image.Black(100, 100);
- im2 = im2.Mutate(x => x.DrawCircle(new double[] { 100 }, 50, 50, 25, fill: true));
+ im2 = im2.Mutate(x => x.DrawCircle([100], 50, 50, 25, fill: true));
var diff = (im - im2).Abs().Max();
Assert.Equal(0, diff);
@@ -54,13 +54,13 @@ public void TestDrawFlood()
public void TestDrawImage()
{
var im = Image.Black(51, 51);
- im = im.Mutate(x => x.DrawCircle(new double[] { 100 }, 25, 25, 25, fill: true));
+ im = im.Mutate(x => x.DrawCircle([100], 25, 25, 25, fill: true));
var im2 = Image.Black(100, 100);
im2 = im2.Mutate(x => x.DrawImage(im, 25, 25));
var im3 = Image.Black(100, 100);
- im3 = im3.Mutate(x => x.DrawCircle(new double[] { 100 }, 50, 50, 25, fill: true));
+ im3 = im3.Mutate(x => x.DrawCircle([100], 50, 50, 25, fill: true));
var diff = (im2 - im3).Abs().Max();
Assert.Equal(0, diff);
@@ -70,7 +70,7 @@ public void TestDrawImage()
public void TestDrawLine()
{
var im = Image.Black(100, 100);
- im = im.Mutate(x => x.DrawLine(new double[] { 100 }, 0, 0, 100, 0));
+ im = im.Mutate(x => x.DrawLine([100], 0, 0, 100, 0));
var pixel = im[0, 0];
Assert.Single(pixel);
Assert.Equal(100, pixel[0]);
@@ -83,13 +83,13 @@ public void TestDrawLine()
public void TestDrawMask()
{
var mask = Image.Black(51, 51);
- mask = mask.Mutate(x => x.DrawCircle(new double[] { 128 }, 25, 25, 25, fill: true));
+ mask = mask.Mutate(x => x.DrawCircle([128], 25, 25, 25, fill: true));
var im = Image.Black(100, 100);
- im = im.Mutate(x => x.DrawMask(new double[] { 200 }, mask, 25, 25));
+ im = im.Mutate(x => x.DrawMask([200], mask, 25, 25));
var im2 = Image.Black(100, 100);
- im2 = im2.Mutate(x => x.DrawCircle(new double[] { 100 }, 50, 50, 25, fill: true));
+ im2 = im2.Mutate(x => x.DrawCircle([100], 50, 50, 25, fill: true));
var diff = (im - im2).Abs().Max();
Assert.Equal(0, diff);
@@ -99,14 +99,14 @@ public void TestDrawMask()
public void TestDrawRect()
{
var im = Image.Black(100, 100);
- im = im.Mutate(x => x.DrawRect(new double[] { 100 }, 25, 25, 50, 50, fill: true));
+ im = im.Mutate(x => x.DrawRect([100], 25, 25, 50, 50, fill: true));
var im2 = Image.Black(100, 100);
im2 = im2.Mutate(x =>
{
for (var y = 25; y < 75; y++)
{
- x.DrawLine(new double[] { 100 }, 25, y, 74, y);
+ x.DrawLine([100], 25, y, 74, y);
}
});
@@ -119,7 +119,7 @@ public void TestDrawRect()
public void TestDrawSmudge()
{
var im = Image.Black(100, 100);
- im = im.Mutate(x => x.DrawCircle(new double[] { 100 }, 50, 50, 25, fill: true));
+ im = im.Mutate(x => x.DrawCircle([100], 50, 50, 25, fill: true));
var im2 = im.ExtractArea(10, 10, 50, 50);
diff --git a/tests/NetVips.Tests/ExtensionsTests.cs b/tests/NetVips.Tests/ExtensionsTests.cs
index 8e2b463d..cdd5ce8f 100644
--- a/tests/NetVips.Tests/ExtensionsTests.cs
+++ b/tests/NetVips.Tests/ExtensionsTests.cs
@@ -71,7 +71,7 @@ private static void AssertPixelValue(byte[] expected, Bitmap actual)
// An additional band is added for greyscale images
if (expected.Length == 2)
{
- expected = new byte[] { expected[0], expected[1], 255 };
+ expected = [expected[0], expected[1], 255];
}
var pixels = new byte[expected.Length];
diff --git a/tests/NetVips.Tests/ForeignTests.cs b/tests/NetVips.Tests/ForeignTests.cs
index 2ec1df09..dcd0ad21 100644
--- a/tests/NetVips.Tests/ForeignTests.cs
+++ b/tests/NetVips.Tests/ForeignTests.cs
@@ -164,7 +164,7 @@ public void TestJpeg()
void JpegValid(Image im)
{
var a = im[10, 10];
- Assert.Equal(new double[] { 6, 5, 3 }, a);
+ Assert.Equal([6, 5, 3], a);
var profile = (byte[])im.Get("icc-profile-data");
Assert.Equal(1352, profile.Length);
@@ -1005,7 +1005,7 @@ void OpenslideValid(Image im)
{
var a = im[10, 10];
- Assert.Equal(new double[] { 244, 250, 243, 255 }, a);
+ Assert.Equal([244, 250, 243, 255], a);
Assert.Equal(2220, im.Width);
Assert.Equal(2967, im.Height);
Assert.Equal(4, im.Bands);
@@ -1023,7 +1023,7 @@ void PdfValid(Image im)
{
var a = im[10, 10];
- Assert.Equal(new double[] { 35, 31, 32, 255 }, a);
+ Assert.Equal([35, 31, 32, 255], a);
// New sizing rules in libvips 8.8+, see:
// https://github.com/libvips/libvips/commit/29d29533d45848ecc12a3c50c39c26c835458a61
diff --git a/tests/NetVips.Tests/Helper.cs b/tests/NetVips.Tests/Helper.cs
index ef168f0b..10dbf1f8 100644
--- a/tests/NetVips.Tests/Helper.cs
+++ b/tests/NetVips.Tests/Helper.cs
@@ -39,39 +39,39 @@ public static class Helper
public static readonly string AvifFile = Path.Combine(Images, "avif-orientation-6.avif");
public static readonly Enums.BandFormat[] UnsignedFormats =
- {
+ [
Enums.BandFormat.Uchar,
Enums.BandFormat.Ushort,
Enums.BandFormat.Uint
- };
+ ];
public static readonly Enums.BandFormat[] SignedFormats =
- {
+ [
Enums.BandFormat.Char,
Enums.BandFormat.Short,
Enums.BandFormat.Int
- };
+ ];
public static readonly Enums.BandFormat[] FloatFormats =
- {
+ [
Enums.BandFormat.Float,
Enums.BandFormat.Double
- };
+ ];
public static readonly Enums.BandFormat[] ComplexFormats =
- {
+ [
Enums.BandFormat.Complex,
Enums.BandFormat.Dpcomplex
- };
+ ];
- public static readonly Enums.BandFormat[] IntFormats = UnsignedFormats.Concat(SignedFormats).ToArray();
+ public static readonly Enums.BandFormat[] IntFormats = [.. UnsignedFormats, .. SignedFormats];
- public static readonly Enums.BandFormat[] NonComplexFormats = IntFormats.Concat(FloatFormats).ToArray();
+ public static readonly Enums.BandFormat[] NonComplexFormats = [.. IntFormats, .. FloatFormats];
- public static readonly Enums.BandFormat[] AllFormats = IntFormats.Concat(FloatFormats).Concat(ComplexFormats).ToArray();
+ public static readonly Enums.BandFormat[] AllFormats = [.. IntFormats, .. FloatFormats, .. ComplexFormats];
public static readonly Enums.Interpretation[] ColourColourspaces =
- {
+ [
Enums.Interpretation.Xyz,
Enums.Interpretation.Lab,
Enums.Interpretation.Lch,
@@ -81,34 +81,33 @@ public static class Helper
Enums.Interpretation.Hsv,
Enums.Interpretation.Srgb,
Enums.Interpretation.Yxy
- };
+ ];
public static readonly Enums.Interpretation[] CodedColourspaces =
- {
+ [
Enums.Interpretation.Labq
- };
+ ];
public static readonly Enums.Interpretation[] MonoColourspaces =
- {
+ [
Enums.Interpretation.Bw
- };
+ ];
public static readonly Enums.Interpretation[] SixteenbitColourspaces =
- {
+ [
Enums.Interpretation.Grey16,
Enums.Interpretation.Rgb16
- };
+ ];
public static readonly Enums.Interpretation[] CmykColourspaces =
- {
+ [
Enums.Interpretation.Cmyk
- };
+ ];
- public static Enums.Interpretation[] AllColourspaces = ColourColourspaces.Concat(MonoColourspaces)
- .Concat(CodedColourspaces)
- .Concat(SixteenbitColourspaces)
- .Concat(CmykColourspaces)
- .ToArray();
+ public static readonly Enums.Interpretation[] AllColourspaces =
+ [
+ .. ColourColourspaces, .. MonoColourspaces, .. CodedColourspaces, .. SixteenbitColourspaces, .. CmykColourspaces
+ ];
public static readonly Dictionary MaxValue = new()
{
@@ -199,7 +198,7 @@ public static class Helper
};
public static readonly Enums.Angle45[] Rot45Angles =
- {
+ [
Enums.Angle45.D0,
Enums.Angle45.D45,
Enums.Angle45.D90,
@@ -208,10 +207,10 @@ public static class Helper
Enums.Angle45.D225,
Enums.Angle45.D270,
Enums.Angle45.D315
- };
+ ];
public static readonly Enums.Angle45[] Rot45AngleBonds =
- {
+ [
Enums.Angle45.D0,
Enums.Angle45.D315,
Enums.Angle45.D270,
@@ -220,23 +219,23 @@ public static class Helper
Enums.Angle45.D135,
Enums.Angle45.D90,
Enums.Angle45.D45
- };
+ ];
public static readonly Enums.Angle[] RotAngles =
- {
+ [
Enums.Angle.D0,
Enums.Angle.D90,
Enums.Angle.D180,
Enums.Angle.D270
- };
+ ];
public static readonly Enums.Angle[] RotAngleBonds =
- {
+ [
Enums.Angle.D0,
Enums.Angle.D270,
Enums.Angle.D180,
Enums.Angle.D90
- };
+ ];
///
/// an expanding zip ... if either of the args is a scalar or a one-element list,
@@ -283,10 +282,10 @@ public static IEnumerable