diff --git a/.editorconfig b/.editorconfig index fb971515415..3c3da0e87a8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -227,7 +227,7 @@ dotnet_diagnostic.CA2241.severity = error # CA2245: Do not assign a property to itself dotnet_diagnostic.CA2245.severity = error -# CA2248: Provide correct enumm argument to Enum.HasFlag +# CA2248: Provide correct enum argument to Enum.HasFlag dotnet_diagnostic.CA2248.severity = error # CA2249: Consider using String.Contains instead of String.IndexOf diff --git a/global.json b/global.json index 46aead322d9..44994b52eb5 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "9.0.100-rc.1.24452.12", + "dotnet": "9.0.100-rc.2.24474.12", "runtimes": { "dotnet/x64": [ "$(VSRedistCommonNetCoreSharedFrameworkx64100PackageVersion)" @@ -11,7 +11,7 @@ } }, "sdk": { - "version": "9.0.100-rc.1.24452.12" + "version": "9.0.100-rc.2.24474.12" }, "msbuild-sdks": { "Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.24501.6", diff --git a/src/System.Drawing.Common/tests/System/Drawing/Drawing2D/GraphicsPathTests.cs b/src/System.Drawing.Common/tests/System/Drawing/Drawing2D/GraphicsPathTests.cs index 7dbc39c3f05..bb7251bb827 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/Drawing2D/GraphicsPathTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/Drawing2D/GraphicsPathTests.cs @@ -253,7 +253,7 @@ public void AddLines_Success() { using GraphicsPath gpi = new(); using GraphicsPath gpf = new(); - gpi.AddLines(new Point[] { new(1, 1), new(2, 2) }); + gpi.AddLines([new(1, 1), new(2, 2)]); AssertLine(gpi); gpf.AddLines(new PointF[] { new(1, 1), new(2, 2) }); @@ -604,7 +604,7 @@ public void AddCurve_InvalidSegment_ThrowsArgumentException(int segment) () => gp.AddCurve(new PointF[2] { new(1f, 1f), new(2f, 2f) }, 0, segment, 0.5f)); AssertExtensions.ThrowsAny( - () => gp.AddCurve(new Point[2] { new(1, 1), new(2, 2) }, 0, segment, 0.5f)); + () => gp.AddCurve([new(1, 1), new(2, 2)], 0, segment, 0.5f)); } [Fact] @@ -615,7 +615,7 @@ public void AddCurve_OffsetTooLarge_ThrowsArgumentException() () => gp.AddCurve(new PointF[3] { new(1f, 1f), new(0f, 20f), new(20f, 0f) }, 1, 2, 0.5f)); AssertExtensions.ThrowsAny( - () => gp.AddCurve(new Point[3] { new(1, 1), new(0, 20), new(20, 0) }, 1, 2, 0.5f)); + () => gp.AddCurve([new(1, 1), new(0, 20), new(20, 0)], 1, 2, 0.5f)); } [Fact] @@ -623,7 +623,7 @@ public void AddClosedCurve_Points_Success() { using GraphicsPath gpi = new(); using GraphicsPath gpf = new(); - gpi.AddClosedCurve(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }); + gpi.AddClosedCurve([new(1, 1), new(2, 2), new(3, 3)]); // AssertClosedCurve() method expects added ClosedCurve with points (1, 1), (2, 2), (3, 3), here and below. AssertClosedCurve(gpi); @@ -636,9 +636,9 @@ public void AddClosedCurve_SamePoints_Success() { using GraphicsPath gpi = new(); using GraphicsPath gpf = new(); - gpi.AddClosedCurve(new Point[3] { new(1, 1), new(1, 1), new(1, 1) }); + gpi.AddClosedCurve([new(1, 1), new(1, 1), new(1, 1)]); Assert.Equal(10, gpi.PointCount); - gpi.AddClosedCurve(new Point[3] { new(1, 1), new(1, 1), new(1, 1) }); + gpi.AddClosedCurve([new(1, 1), new(1, 1), new(1, 1)]); Assert.Equal(20, gpi.PointCount); gpf.AddClosedCurve(new PointF[3] { new(1, 1), new(1, 1), new(1, 1) }); @@ -652,7 +652,7 @@ public void AddClosedCurve_Tension_Success() { using GraphicsPath gpi = new(); using GraphicsPath gpf = new(); - gpi.AddClosedCurve(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }, 0.5f); + gpi.AddClosedCurve([new(1, 1), new(2, 2), new(3, 3)], 0.5f); AssertClosedCurve(gpi); gpf.AddClosedCurve(new PointF[3] { new(1, 1), new(2, 2), new(3, 3) }, 0.5f); @@ -886,7 +886,7 @@ public void AddPolygon_Points_Success() { using GraphicsPath gpi = new(); using GraphicsPath gpf = new(); - gpi.AddPolygon(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }); + gpi.AddPolygon([new(1, 1), new(2, 2), new(3, 3)]); // AssertPolygon() method expects added Polygon with points (1, 1), (2, 2), (3, 3), here and below. AssertPolygon(gpi); @@ -899,19 +899,19 @@ public void AddPolygon_SamePoints_Success() { using GraphicsPath gpi = new(); using GraphicsPath gpf = new(); - gpi.AddPolygon(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }); + gpi.AddPolygon([new(1, 1), new(2, 2), new(3, 3)]); Assert.Equal(3, gpi.PointCount); Assert.Equal(new byte[] { 0, 1, 129 }, gpi.PathTypes); - gpi.AddPolygon(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }); + gpi.AddPolygon([new(1, 1), new(2, 2), new(3, 3)]); Assert.Equal(6, gpi.PointCount); Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129 }, gpi.PathTypes); - gpi.AddPolygon(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }); + gpi.AddPolygon([new(1, 1), new(2, 2), new(3, 3)]); Assert.Equal(9, gpi.PointCount); Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpi.PathTypes); - gpi.AddPolygon(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }); + gpi.AddPolygon([new(1, 1), new(2, 2), new(3, 3)]); Assert.Equal(12, gpi.PointCount); Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpi.PathTypes); @@ -1194,11 +1194,11 @@ public void Flatten_ClosedCurve_Success() { using GraphicsPath gp = new(); using GraphicsPath clone = Assert.IsType(gp.Clone()); - gp.AddClosedCurve(new Point[4] - { - new(0, 0), new(40, 20), - new(20, 40), new(40, 40) - }); + gp.AddClosedCurve( + [ + new(0, 0), new(40, 20), + new(20, 40), new(40, 40) + ]); gp.Flatten(); AssertFlats(gp, clone); @@ -1209,11 +1209,11 @@ public void Flatten_Curve_Success() { using GraphicsPath gp = new(); using GraphicsPath clone = Assert.IsType(gp.Clone()); - gp.AddCurve(new Point[4] - { - new(0, 0), new(40, 20), - new(20, 40), new(40, 40) - }); + gp.AddCurve( + [ + new(0, 0), new(40, 20), + new(20, 40), new(40, 40) + ]); gp.Flatten(); AssertFlats(gp, clone); @@ -1254,11 +1254,11 @@ public void Flatten_Polygon_Success() { using GraphicsPath gp = new(); using GraphicsPath clone = Assert.IsType(gp.Clone()); - gp.AddPolygon(new Point[4] - { - new(0, 0), new(10, 10), - new(20, 20), new(40, 40) - }); + gp.AddPolygon( + [ + new(0, 0), new(10, 10), + new(20, 20), new(40, 40) + ]); gp.Flatten(); AssertFlats(gp, clone); @@ -1303,7 +1303,7 @@ public void Warp_WarpModeInvalid_Success() { using GraphicsPath gp = new(); using Matrix matrix = new(); - gp.AddPolygon(new Point[3] { new(5, 5), new(15, 5), new(10, 15) }); + gp.AddPolygon([new(5, 5), new(15, 5), new(10, 15)]); gp.Warp([new(0, 0)], new RectangleF(10, 20, 30, 40), matrix, (WarpMode)int.MinValue); Assert.Equal(0, gp.PointCount); } @@ -1312,7 +1312,7 @@ public void Warp_WarpModeInvalid_Success() public void Warp_RectangleEmpty_Success() { using GraphicsPath gp = new(); - gp.AddPolygon(new Point[3] { new(5, 5), new(15, 5), new(10, 15) }); + gp.AddPolygon([new(5, 5), new(15, 5), new(10, 15)]); gp.Warp([new(0, 0)], new Rectangle(), null); AssertWrapNaN(gp); } @@ -1431,12 +1431,12 @@ public void StartClose_AddBeziers() { using GraphicsPath gp = new(); gp.AddLine(1, 1, 2, 2); - gp.AddBeziers(new Point[7] - { - new(10, 10), new(20, 10), new(20, 20), - new(30, 20), new(40, 40), new(50, 40), - new(50, 50) - }); + gp.AddBeziers( + [ + new(10, 10), new(20, 10), new(20, 20), + new(30, 20), new(40, 40), new(50, 40), + new(50, 50) + ]); gp.AddLine(10, 10, 20, 20); byte[] types = gp.PathTypes; @@ -1452,7 +1452,7 @@ public void StartClose_AddClosedCurve() { using GraphicsPath gp = new(); gp.AddLine(1, 1, 2, 2); - gp.AddClosedCurve(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }); + gp.AddClosedCurve([new(1, 1), new(2, 2), new(3, 3)]); gp.AddLine(10, 10, 20, 20); byte[] types = gp.PathTypes; @@ -1468,7 +1468,7 @@ public void StartClose_AddCurve() { using GraphicsPath path = new(); path.AddLine(1, 1, 2, 2); - path.AddCurve(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }); + path.AddCurve([new(1, 1), new(2, 2), new(3, 3)]); path.AddLine(10, 10, 20, 20); byte[] types = path.PathTypes; @@ -1514,7 +1514,7 @@ public void StartClose_AddLines() { using GraphicsPath gp = new(); gp.AddLine(1, 1, 2, 2); - gp.AddLines(new Point[4] { new(10, 10), new(20, 10), new(20, 20), new(30, 20) }); + gp.AddLines([new(10, 10), new(20, 10), new(20, 20), new(30, 20)]); gp.AddLine(10, 10, 20, 20); byte[] types = gp.PathTypes; @@ -1580,7 +1580,7 @@ public void StartClose_AddPolygon() { using GraphicsPath gp = new(); gp.AddLine(1, 1, 2, 2); - gp.AddPolygon(new Point[3] { new(1, 1), new(2, 2), new(3, 3) }); + gp.AddPolygon([new(1, 1), new(2, 2), new(3, 3)]); gp.AddLine(10, 10, 20, 20); byte[] types = gp.PathTypes; @@ -1691,7 +1691,7 @@ public void Widen_MatrixNull_Success() { using GraphicsPath gp = new(); using Pen pen = new(Color.Blue); - gp.AddPolygon(new Point[3] { new(5, 5), new(15, 5), new(10, 15) }); + gp.AddPolygon([new(5, 5), new(15, 5), new(10, 15)]); gp.Widen(pen, null); Assert.Equal(9, gp.PointCount); AssertWiden3(gp); @@ -1703,7 +1703,7 @@ public void Widen_MatrixEmpty_Success() using GraphicsPath gp = new(); using Pen pen = new(Color.Blue); using Matrix matrix = new(); - gp.AddPolygon(new Point[3] { new(5, 5), new(15, 5), new(10, 15) }); + gp.AddPolygon([new(5, 5), new(15, 5), new(10, 15)]); gp.Widen(pen, new Matrix()); Assert.Equal(9, gp.PointCount); AssertWiden3(gp); diff --git a/src/System.Drawing.Common/tests/System/Drawing/GraphicsTests.cs b/src/System.Drawing.Common/tests/System/Drawing/GraphicsTests.cs index 6672b0c1314..8bdc68e8fc2 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/GraphicsTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/GraphicsTests.cs @@ -1850,7 +1850,7 @@ public void TransformPoints_InvalidDestSpace_ThrowsArgumentException(CoordinateS { using Bitmap image = new(10, 10); using Graphics graphics = Graphics.FromImage(image); - AssertExtensions.Throws(null, () => graphics.TransformPoints(destSpace, CoordinateSpace.World, new Point[] { new(1, 1) })); + AssertExtensions.Throws(null, () => graphics.TransformPoints(destSpace, CoordinateSpace.World, [new(1, 1)])); AssertExtensions.Throws(null, () => graphics.TransformPoints(destSpace, CoordinateSpace.World, new PointF[] { new(1, 1) })); } @@ -1861,7 +1861,7 @@ public void TransformPoints_InvalidSourceSpace_ThrowsArgumentException(Coordinat { using Bitmap image = new(10, 10); using Graphics graphics = Graphics.FromImage(image); - AssertExtensions.Throws(null, () => graphics.TransformPoints(CoordinateSpace.World, srcSpace, new Point[] { new(1, 1) })); + AssertExtensions.Throws(null, () => graphics.TransformPoints(CoordinateSpace.World, srcSpace, [new(1, 1)])); AssertExtensions.Throws(null, () => graphics.TransformPoints(CoordinateSpace.World, srcSpace, new PointF[] { new(1, 1) })); } @@ -1891,8 +1891,8 @@ public void TransformPoints_Busy_ThrowsInvalidOperationException() graphics.GetHdc(); try { - Assert.Throws(() => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new Point[] { Point.Empty })); - Assert.Throws(() => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new PointF[] { PointF.Empty })); + Assert.Throws(() => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, [Point.Empty])); + Assert.Throws(() => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, [PointF.Empty])); } finally { @@ -1907,8 +1907,8 @@ public void TransformPoints_Disposed_ThrowsArgumentException() Graphics graphics = Graphics.FromImage(image); graphics.Dispose(); - AssertExtensions.Throws(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new Point[] { Point.Empty })); - AssertExtensions.Throws(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new PointF[] { PointF.Empty })); + AssertExtensions.Throws(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, [Point.Empty])); + AssertExtensions.Throws(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, [PointF.Empty])); } public static IEnumerable GetNearestColor_TestData() diff --git a/src/System.Drawing.Common/tests/System/Drawing/Graphics_DrawLineTests.cs b/src/System.Drawing.Common/tests/System/Drawing/Graphics_DrawLineTests.cs index 1e7ac3959cb..3b30e0644aa 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/Graphics_DrawLineTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/Graphics_DrawLineTests.cs @@ -12,7 +12,7 @@ public void DrawLines_Points() using Pen pen = new(Color.White); using Graphics graphics = Graphics.FromImage(bitmap); - graphics.DrawLines(pen, new Point[] { new(1, 1), new(1, 10), new(20, 5), new(25, 30) }); + graphics.DrawLines(pen, [new(1, 1), new(1, 10), new(20, 5), new(25, 30)]); ValidateBitmapContent( bitmap, diff --git a/src/System.Drawing.Common/tests/System/Drawing/Imaging/ColorMatrixTests.cs b/src/System.Drawing.Common/tests/System/Drawing/Imaging/ColorMatrixTests.cs index b23c65e5c25..992651797ae 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/Imaging/ColorMatrixTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/Imaging/ColorMatrixTests.cs @@ -112,15 +112,15 @@ public void Ctor_BadValues_ThrowsExpectedException(float[][] newColorMatrix, Typ [Fact] public void Ctor_TooBigArraySize_MapOnly4and4Elements() { - ColorMatrix cm = new(new float[][] - { + ColorMatrix cm = new( + [ [0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f], [1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f], [2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 2.5f], [3.0f, 3.1f, 3.2f, 3.3f, 3.4f, 3.5f], [4.0f, 4.1f, 4.2f, 4.3f, 4.4f, 4.5f], [5.0f, 5.1f, 5.2f, 5.3f, 5.4f, 5.5f] - }); + ]); Assert.Equal(0.0f, cm.Matrix00); Assert.Equal(0.1f, cm.Matrix01); @@ -152,15 +152,15 @@ public void Ctor_TooBigArraySize_MapOnly4and4Elements() [Fact] public void AccessToNotExistingElement_ThrowsIndexOutOfRangeException() { - ColorMatrix cm = new(new float[][] - { + ColorMatrix cm = new( + [ [0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f], [1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f], [2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 2.5f], [3.0f, 3.1f, 3.2f, 3.3f, 3.4f, 3.5f], [4.0f, 4.1f, 4.2f, 4.3f, 4.4f, 4.5f], [5.0f, 5.1f, 5.2f, 5.3f, 5.4f, 5.5f] - }); + ]); Assert.Throws(() => _ = cm[5, 5]); } diff --git a/src/System.Drawing.Common/tests/System/Drawing/Imaging/ImageAttributesTests.cs b/src/System.Drawing.Common/tests/System/Drawing/Imaging/ImageAttributesTests.cs index c7843d3a3e5..671e95e8c14 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/Imaging/ImageAttributesTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/Imaging/ImageAttributesTests.cs @@ -34,23 +34,23 @@ public class ImageAttributesTests private readonly Color _actualGreen = Color.FromArgb(255, 0, 255, 0); private readonly Color _expectedRed = Color.FromArgb(255, 255, 0, 0); private readonly Color _expectedBlack = Color.FromArgb(255, 0, 0, 0); - private readonly ColorMatrix _greenComponentToZeroColorMatrix = new(new float[][] - { + private readonly ColorMatrix _greenComponentToZeroColorMatrix = new( + [ [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0], - }); + ]); - private readonly ColorMatrix _grayMatrix = new(new float[][] - { + private readonly ColorMatrix _grayMatrix = new( + [ [1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0], - }); + ]); private readonly ColorMap[] _yellowToRedColorMap = [ @@ -114,14 +114,14 @@ public static IEnumerable ColorMatrix_DropShadowRepaintWhenAreaIsSmall [MemberData(nameof(ColorMatrix_DropShadowRepaintWhenAreaIsSmallerThanTheFilteredElement_TestData))] public void SetColorMatrix_ColorMatrixI_Success(Color color) { - ColorMatrix colorMatrix = new(new float[][] - { + ColorMatrix colorMatrix = new( + [ [1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0.5f, 0], [0, 0, 0, 0, 1], - }); + ]); using SolidBrush brush = new(color); using Bitmap bitmapBig = new(200, 100); diff --git a/src/System.Drawing.Common/tests/System/Drawing/PenTests.cs b/src/System.Drawing.Common/tests/System/Drawing/PenTests.cs index d2a73dd2b05..75c706ef23f 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/PenTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/PenTests.cs @@ -14,7 +14,7 @@ public static IEnumerable Ctor_Brush_TestData() yield return new object[] { new HatchBrush(HatchStyle.BackwardDiagonal, Color.Red), PenType.HatchFill }; yield return new object[] { new LinearGradientBrush(new Point(0, 0), new Point(0, 2), Color.Purple, Color.Plum), PenType.LinearGradient }; yield return new object[] { new TextureBrush(new Bitmap(1, 1)), PenType.TextureFill }; - yield return new object[] { new PathGradientBrush(new Point[] { new(1, 2), new(2, 3) }), PenType.PathGradient }; + yield return new object[] { new PathGradientBrush([new(1, 2), new(2, 3)]), PenType.PathGradient }; } [Theory] diff --git a/src/System.Drawing.Common/tests/System/Drawing/RegionTests.cs b/src/System.Drawing.Common/tests/System/Drawing/RegionTests.cs index 23be1e1b308..9fc440edd59 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/RegionTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/RegionTests.cs @@ -205,15 +205,15 @@ public static IEnumerable Ctor_InfiniteGraphicsPath_TestData() yield return new object[] { path3, false }; GraphicsPath path4 = new(); - path4.AddCurve(new Point[] { new(-4194304, -4194304), new(4194304, 4194304) }); + path4.AddCurve([new(-4194304, -4194304), new(4194304, 4194304)]); yield return new object[] { path4, false }; GraphicsPath path5 = new(); - path5.AddPolygon(new Point[] { new(-4194304, -4194304), new(-4194304, 4194304), new(4194304, 4194304), new(4194304, -4194304) }); + path5.AddPolygon([new(-4194304, -4194304), new(-4194304, 4194304), new(4194304, 4194304), new(4194304, -4194304)]); yield return new object[] { path5, true }; GraphicsPath path6 = new(); - path6.AddPolygon(new Point[] { new(-4194304, -4194304), new(-4194304, 4194304), new(4194304, 4194304), new(4194304, -4194304), new(-4194304, -4194304) }); + path6.AddPolygon([new(-4194304, -4194304), new(-4194304, 4194304), new(4194304, 4194304), new(4194304, -4194304), new(-4194304, -4194304)]); yield return new object[] { path6, true }; } @@ -232,7 +232,7 @@ public void Ctor_InfiniteGraphicsPath_IsInfinite(GraphicsPath path, bool isInfin public void Ctor_GraphicsPathTooLarge_SetsToEmpty() { using GraphicsPath path = new(); - path.AddCurve(new Point[] { new(-4194304, -4194304), new(4194304, 4194304) }); + path.AddCurve([new(-4194304, -4194304), new(4194304, 4194304)]); using Region region = new(path); using Matrix matrix = new(); diff --git a/src/System.Drawing.Common/tests/mono/System.Drawing/GraphicsTests.cs b/src/System.Drawing.Common/tests/mono/System.Drawing/GraphicsTests.cs index 65fb93d8026..b6e19ea56ae 100644 --- a/src/System.Drawing.Common/tests/mono/System.Drawing/GraphicsTests.cs +++ b/src/System.Drawing.Common/tests/mono/System.Drawing/GraphicsTests.cs @@ -728,7 +728,7 @@ public void DrawCurve_SinglePoint() { using Bitmap bitmap = new(20, 20); using Graphics g = Graphics.FromImage(bitmap); - Assert.Throws(() => g.DrawCurve(Pens.Black, new Point[1] { new(10, 10) }, 0.5f)); + Assert.Throws(() => g.DrawCurve(Pens.Black, [new(10, 10)], 0.5f)); // a single point isn't enough } @@ -2535,10 +2535,7 @@ public void DrawImage_ImagePointArray() { using Bitmap bmp = new(40, 40); using Graphics g = Graphics.FromImage(bmp); - g.DrawImage(bmp, new Point[] - { - new(0, 0), new(1, 1), new(2, 2) - }); + g.DrawImage(bmp, [ new(0, 0), new(1, 1), new(2, 2)]); } [Fact] diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StyleEditorForm.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StyleEditorForm.cs index 57603370ac8..e0009ea4eca 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StyleEditorForm.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StyleEditorForm.cs @@ -396,13 +396,8 @@ private void InitializeComponent() // absoluteNumericUpDown resources.ApplyResources(_absoluteNumericUpDown, "absoluteNumericUpDown"); - _absoluteNumericUpDown.Maximum = new decimal(new int[] - { - 99999, - 0, - 0, - 0 - }); + _absoluteNumericUpDown.Maximum = new decimal(99999u); + _absoluteNumericUpDown.Name = "absoluteNumericUpDown"; _absoluteNumericUpDown.Margin = new Padding(_scaledUpDownLeftMargin, _scaledUpDownTopMargin, 0, 0); _absoluteNumericUpDown.AutoScaleMode = AutoScaleMode.Font; @@ -435,13 +430,7 @@ private void InitializeComponent() // percentNumericUpDown resources.ApplyResources(_percentNumericUpDown, "percentNumericUpDown"); _percentNumericUpDown.DecimalPlaces = 2; - _percentNumericUpDown.Maximum = new decimal(new int[] - { - 9999, - 0, - 0, - 0 - }); + _percentNumericUpDown.Maximum = new decimal(9999u); _percentNumericUpDown.Name = "percentNumericUpDown"; _percentNumericUpDown.Margin = new Padding(_scaledUpDownLeftMargin, _scaledUpDownTopMargin, 0, 0); _percentNumericUpDown.AutoScaleMode = AutoScaleMode.Font; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationServiceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationServiceTests.cs index 52a84916066..4d75dd2f21d 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationServiceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationServiceTests.cs @@ -138,8 +138,8 @@ public void CreateStore_CloseSerialize_Success() Dictionary state = GetState(info); Assert.Equal(2, state.Count); CodeDomComponentSerializationState valueState1 = state["name1"]; - CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection(new CodeStatement[] - { + CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection( + [ new CodeVariableDeclarationStatement(typeof(DataClass), "name1"), new CodeAssignStatement(new CodeVariableReferenceExpression("name1"), new CodeObjectCreateExpression(typeof(DataClass))), new CodeCommentStatement(string.Empty), @@ -148,12 +148,12 @@ public void CreateStore_CloseSerialize_Success() new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name1"), "DefaultStringValue"), new CodePrimitiveExpression(null)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name1"), "IntValue"), new CodePrimitiveExpression(1)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name1"), "StringValue"), new CodePrimitiveExpression("Value")) - }), Assert.IsType(valueState1.Code)); + ]), Assert.IsType(valueState1.Code)); AssertAllNonCodeFieldsArNull(valueState1); CodeDomComponentSerializationState valueState2 = state["name2"]; - CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection(new CodeStatement[] - { + CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection( + [ new CodeVariableDeclarationStatement(typeof(DataClass), "name2"), new CodeAssignStatement(new CodeVariableReferenceExpression("name2"), new CodeObjectCreateExpression(typeof(DataClass))), new CodeCommentStatement(string.Empty), @@ -162,7 +162,7 @@ public void CreateStore_CloseSerialize_Success() new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name2"), "DefaultStringValue"), new CodePrimitiveExpression(null)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name2"), "IntValue"), new CodePrimitiveExpression(2)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name2"), "StringValue"), new CodePrimitiveExpression("OtherValue")) - }), Assert.IsType(valueState2.Code)); + ]), Assert.IsType(valueState2.Code)); AssertAllNonCodeFieldsArNull(valueState2); List names = Assert.IsType>(info.GetValue("Names", typeof(List))); @@ -240,8 +240,8 @@ public void CreateStore_CloseSerializeWithInvalidProvider_Success(object result) Dictionary state = GetState(info); CodeDomComponentSerializationState valueState = state["name"]; - CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection(new CodeStatement[] - { + CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection( + [ new CodeVariableDeclarationStatement(typeof(DataClass), "name"), new CodeAssignStatement(new CodeVariableReferenceExpression("name"), new CodeObjectCreateExpression(typeof(DataClass))), new CodeCommentStatement(string.Empty), @@ -250,7 +250,7 @@ public void CreateStore_CloseSerializeWithInvalidProvider_Success(object result) new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "DefaultStringValue"), new CodePrimitiveExpression(null)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "IntValue"), new CodePrimitiveExpression(1)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "StringValue"), new CodePrimitiveExpression("Value")) - }), Assert.IsType(valueState.Code)); + ]), Assert.IsType(valueState.Code)); AssertAllNonCodeFieldsArNull(valueState); List names = Assert.IsType>(info.GetValue("Names", typeof(List))); @@ -342,8 +342,8 @@ public void CreateStore_CloseSerializeWithValidProvider_Success(object component Dictionary state = GetState(info); CodeDomComponentSerializationState valueState = state["name"]; - CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection(new CodeStatement[] - { + CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection( + [ new CodeVariableDeclarationStatement(typeof(DataClass), "name"), new CodeAssignStatement(new CodeVariableReferenceExpression("name"), new CodeObjectCreateExpression(typeof(DataClass))), new CodeCommentStatement(string.Empty), @@ -352,7 +352,7 @@ public void CreateStore_CloseSerializeWithValidProvider_Success(object component new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "DefaultStringValue"), new CodePrimitiveExpression(null)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "IntValue"), new CodePrimitiveExpression(1)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "StringValue"), new CodePrimitiveExpression("Value")) - }), Assert.IsType(valueState.Code)); + ]), Assert.IsType(valueState.Code)); AssertAllNonCodeFieldsArNull(valueState); List names = Assert.IsType>(info.GetValue("Names", typeof(List))); @@ -387,8 +387,8 @@ public void CreateStore_CloseSerializeAbsolute_Success() Dictionary state = GetState(info); CodeDomComponentSerializationState valueState = state["name"]; - CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection(new CodeStatement[] - { + CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection( + [ new CodeVariableDeclarationStatement(typeof(DataClass), "name"), new CodeAssignStatement(new CodeVariableReferenceExpression("name"), new CodeObjectCreateExpression(typeof(DataClass))), new CodeCommentStatement(string.Empty), @@ -397,7 +397,7 @@ public void CreateStore_CloseSerializeAbsolute_Success() new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "DefaultStringValue"), new CodePrimitiveExpression(null)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "IntValue"), new CodePrimitiveExpression(1)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "StringValue"), new CodePrimitiveExpression("Value")) - }), Assert.IsType(valueState.Code)); + ]), Assert.IsType(valueState.Code)); AssertAllNonCodeFieldsArNull(valueState); List names = Assert.IsType>(info.GetValue("Names", typeof(List))); @@ -438,12 +438,12 @@ public void CreateStore_CloseSerializeMember_Success() Dictionary state = GetState(info); CodeDomComponentSerializationState valueState = state["name"]; - CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection(new CodeStatement[] - { + CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection( + [ new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "IntValue"), new CodePrimitiveExpression(1)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "DefaultStringValue"), new CodePrimitiveExpression(null)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "IntValue"), new CodePrimitiveExpression(1)), - }), Assert.IsType(valueState.Code)); + ]), Assert.IsType(valueState.Code)); AssertAllNonCodeFieldsArNull(valueState); List names = Assert.IsType>(info.GetValue("Names", typeof(List))); @@ -484,12 +484,12 @@ public void CreateStore_CloseSerializeMemberAbsolute_Success() Dictionary state = GetState(info); CodeDomComponentSerializationState valueState = state["name"]; - CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection(new CodeStatement[] - { + CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection( + [ new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "IntValue"), new CodePrimitiveExpression(1)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "DefaultStringValue"), new CodePrimitiveExpression(null)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "IntValue"), new CodePrimitiveExpression(1)) - }), Assert.IsType(valueState.Code)); + ]), Assert.IsType(valueState.Code)); AssertAllNonCodeFieldsArNull(valueState); List names = Assert.IsType>(info.GetValue("Names", typeof(List))); @@ -528,8 +528,8 @@ public void CreateStore_CloseSerializeThenSerializeMember_Success() Dictionary state = GetState(info); CodeDomComponentSerializationState valueState = state["name"]; - CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection(new CodeStatement[] - { + CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection( + [ new CodeVariableDeclarationStatement(typeof(DataClass), "name"), new CodeAssignStatement(new CodeVariableReferenceExpression("name"), new CodeObjectCreateExpression(typeof(DataClass))), new CodeCommentStatement(string.Empty), @@ -538,7 +538,7 @@ public void CreateStore_CloseSerializeThenSerializeMember_Success() new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "DefaultStringValue"), new CodePrimitiveExpression(null)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "IntValue"), new CodePrimitiveExpression(1)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "StringValue"), new CodePrimitiveExpression("Value")) - }), Assert.IsType(valueState.Code)); + ]), Assert.IsType(valueState.Code)); AssertAllNonCodeFieldsArNull(valueState); List names = Assert.IsType>(info.GetValue("Names", typeof(List))); @@ -577,8 +577,8 @@ public void CreateStore_CloseSerializeMemberThenSerialize_Success() Dictionary state = GetState(info); CodeDomComponentSerializationState valueState = state["name"]; - CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection(new CodeStatement[] - { + CodeDomHelpers.AssertEqualCodeStatementCollection(new CodeStatementCollection( + [ new CodeVariableDeclarationStatement(typeof(DataClass), "name"), new CodeAssignStatement(new CodeVariableReferenceExpression("name"), new CodeObjectCreateExpression(typeof(DataClass))), new CodeCommentStatement(string.Empty), @@ -587,7 +587,7 @@ public void CreateStore_CloseSerializeMemberThenSerialize_Success() new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "DefaultStringValue"), new CodePrimitiveExpression(null)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "IntValue"), new CodePrimitiveExpression(1)), new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("name"), "StringValue"), new CodePrimitiveExpression("Value")) - }), Assert.IsType(valueState.Code)); + ]), Assert.IsType(valueState.Code)); AssertAllNonCodeFieldsArNull(valueState); List names = Assert.IsType>(info.GetValue("Names", typeof(List))); diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollectionTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollectionTests.cs index 0fa1a5648c2..20a5863703d 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollectionTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollectionTests.cs @@ -69,7 +69,7 @@ public void AddRange_ShouldAddMultipleControlsToCollection() { using Control control1 = new(); using Control control2 = new(); - Control[] controls = { control1, control2 }; + Control[] controls = [control1, control2]; _collection.AddRange(controls); _control.Controls.Cast().Should().Contain(controls); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.FlatComboAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.FlatComboAdapter.cs index 96446cd3ee3..a64072d456d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.FlatComboAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.FlatComboAdapter.cs @@ -178,12 +178,11 @@ protected virtual void DrawFlatComboDropDown(ComboBox comboBox, Graphics g, Rect g.FillPolygon( brush, - new Point[] - { + [ new(middle.X - s_offsetPixels, middle.Y - 1), new(middle.X + s_offsetPixels + 1, middle.Y - 1), new(middle.X, middle.Y + s_offsetPixels) - }); + ]); } protected virtual Color GetOuterBorderColor(ComboBox comboBox) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewComboBoxCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewComboBoxCell.cs index d54ed771f62..04a2ea6eaca 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewComboBoxCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewComboBoxCell.cs @@ -2162,12 +2162,12 @@ private Rectangle PaintPrivate( // if the height is odd - favor pushing it over one pixel down. middle.Y += (dropRect.Height % 2); - g.FillPolygon(SystemBrushes.ControlText, new Point[] - { + g.FillPolygon(SystemBrushes.ControlText, + [ new(middle.X - s_offset2X, middle.Y - 1), new(middle.X + s_offset2X + 1, middle.Y - 1), new(middle.X, middle.Y + s_offset2Y) - }); + ]); } else if (!paintXPThemes) { @@ -2185,7 +2185,7 @@ private Rectangle PaintPrivate( middle.Y += (dropRect.Height % 2); Point pt1 = new(middle.X - (s_nonXPTriangleWidth - 1) / 2, middle.Y - s_nonXPTriangleHeight); Point pt2 = new(middle.X + (s_nonXPTriangleWidth - 1) / 2, middle.Y - s_nonXPTriangleHeight); - g.FillPolygon(SystemBrushes.ControlText, new Point[] { pt1, pt2, middle }); + g.FillPolygon(SystemBrushes.ControlText, [pt1, pt2, middle]); // quirk in GDI+ : if we don't draw the line below then the top right most pixel of the DropDown triangle will not paint // Would think that g.FillPolygon would have painted that... g.DrawLine(SystemPens.ControlText, pt1.X, pt1.Y, pt2.X, pt2.Y); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs index d00525e4955..865ec71707a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs @@ -1515,7 +1515,7 @@ private bool FilterReadOnlyEditKeyPress(char keyChar) int index = GetCurrentValueIndex(gridEntry); object[] values = gridEntry.GetPropertyValueList(); - string letter = new(new char[] { keyChar }); + string letter = new([keyChar]); for (int i = 0; i < values.Length; i++) { object currentValue = values[(i + index + 1) % values.Length]; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs index f7b5927d1c3..887b7775390 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs @@ -3860,21 +3860,21 @@ internal void PaintInsertionMark(Graphics g) int verticalBeamStart = start + 2; // Draw vertical lines. - g.DrawLines(SystemPens.ControlText, (ReadOnlySpan) + g.DrawLines(SystemPens.ControlText, [ new(verticalBeamStart, _lastInsertionMarkRect.Y), new(verticalBeamStart, _lastInsertionMarkRect.Bottom - 1), new(verticalBeamStart + 1, _lastInsertionMarkRect.Y), new(verticalBeamStart + 1, _lastInsertionMarkRect.Bottom - 1) ]); // Draw top horizontal lines. - g.DrawLines(SystemPens.ControlText, (ReadOnlySpan) + g.DrawLines(SystemPens.ControlText, [ new(start, _lastInsertionMarkRect.Bottom - 1), new(start + widthOfBeam - 1, _lastInsertionMarkRect.Bottom - 1), new(start + 1, _lastInsertionMarkRect.Bottom - 2), new(start + widthOfBeam - 2, _lastInsertionMarkRect.Bottom - 2) ]); // Draw bottom horizontal lines. - g.DrawLines(SystemPens.ControlText, (ReadOnlySpan) + g.DrawLines(SystemPens.ControlText, [ new(start, _lastInsertionMarkRect.Y), new(start + widthOfBeam - 1, _lastInsertionMarkRect.Y), new(start + 1, _lastInsertionMarkRect.Y + 1), new(start + widthOfBeam - 2, _lastInsertionMarkRect.Y + 1) @@ -3887,21 +3887,21 @@ internal void PaintInsertionMark(Graphics g) int horizontalBeamStart = start + 2; // Draw horizontal lines. - g.DrawLines(SystemPens.ControlText, (ReadOnlySpan) + g.DrawLines(SystemPens.ControlText, [ new(_lastInsertionMarkRect.X, horizontalBeamStart), new(_lastInsertionMarkRect.Right - 1, horizontalBeamStart), new(_lastInsertionMarkRect.X, horizontalBeamStart + 1), new(_lastInsertionMarkRect.Right - 1, horizontalBeamStart + 1) ]); // Draw left vertical lines. - g.DrawLines(SystemPens.ControlText, (ReadOnlySpan) + g.DrawLines(SystemPens.ControlText, [ new(_lastInsertionMarkRect.X, start), new(_lastInsertionMarkRect.X, start + widthOfBeam - 1), new(_lastInsertionMarkRect.X + 1, start + 1), new(_lastInsertionMarkRect.X + 1, start + widthOfBeam - 2) ]); // Draw right vertical lines. - g.DrawLines(SystemPens.ControlText, (ReadOnlySpan) + g.DrawLines(SystemPens.ControlText, [ new(_lastInsertionMarkRect.Right - 1, start), new(_lastInsertionMarkRect.Right - 1, start + widthOfBeam - 1), new(_lastInsertionMarkRect.Right - 2, start + 1), new(_lastInsertionMarkRect.Right - 2, start + widthOfBeam - 2) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs index da96be6fc91..4c032266272 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs @@ -143,12 +143,12 @@ protected override void DrawFlatComboDropDown(ComboBox comboBox, Graphics g, Rec // If the width is odd - favor pushing it over one pixel right. middle.X += (dropDownRect.Width % 2); - g.FillPolygon(brush, new Point[] - { + g.FillPolygon(brush, + [ new(middle.X - s_offsetPixels, middle.Y - 1), new(middle.X + s_offsetPixels + 1, middle.Y - 1), new(middle.X, middle.Y + s_offsetPixels) - }); + ]); } } } diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ListViewTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ListViewTests.cs index 5331d5fbcbb..2320031eecf 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ListViewTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ListViewTests.cs @@ -518,9 +518,9 @@ private void InitializeItems(ListView listView, View view, bool virtualModeEnabl ColumnHeader columnHeader2 = new() { Text = "ColumnHeader2", Width = 140 }; ColumnHeader columnHeader3 = new() { Text = "ColumnHeader3", Width = 140 }; listView.Columns.AddRange([columnHeader1, columnHeader2, columnHeader3]); - ListViewItem listViewItem1 = new(new[] { "row1", "row1Col2", "row1Col3" }, -1) { StateImageIndex = 0 }; - ListViewItem listViewItem2 = new(new[] { "row2", "row2Col2", "row2Col3" }, -1) { StateImageIndex = 0 }; - ListViewItem listViewItem3 = new(new[] { "row3", "row3Col2", "row3Col3" }, -1) { StateImageIndex = 0 }; + ListViewItem listViewItem1 = new(["row1", "row1Col2", "row1Col3"], -1) { StateImageIndex = 0 }; + ListViewItem listViewItem2 = new(["row2", "row2Col2", "row2Col3"], -1) { StateImageIndex = 0 }; + ListViewItem listViewItem3 = new(["row3", "row3Col2", "row3Col3"], -1) { StateImageIndex = 0 }; listView.RetrieveVirtualItem += (s, e) => { e.Item = e.ItemIndex switch diff --git a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/ListViewTest.cs b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/ListViewTest.cs index df3b58d1eb1..d62f52adf07 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/ListViewTest.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/ListViewTest.cs @@ -36,7 +36,7 @@ public ListViewTest() AddGroupTasks(); // Manual test for https://github.com/dotnet/winforms/issues/11658 - string[] TestItems = { "Item 1", "Item 2", "Item 3" }; + string[] TestItems = ["Item 1", "Item 2", "Item 3"]; listView3.RetrieveVirtualItem += (s, e) => { e.Item = e.ItemIndex switch diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListVIew.ListViewAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListVIew.ListViewAccessibleObjectTests.cs index 7d5f8bd67c5..08635d23100 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListVIew.ListViewAccessibleObjectTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListVIew.ListViewAccessibleObjectTests.cs @@ -1010,10 +1010,10 @@ public void ListViewAccessibleObject_GetSelectionInvoke_VirtualMode_ReturnsExpec VirtualListSize = 4 }; - ListViewItem listItem1 = new(new string[] { "Item 1", "Item A" }, -1); + ListViewItem listItem1 = new(["Item 1", "Item A"], -1); ListViewItem listItem2 = new("Group item 2"); ListViewItem listItem3 = new("Item 3"); - ListViewItem listItem4 = new(new string[] { "Item 4", "Item B" }, -1); + ListViewItem listItem4 = new(["Item 4", "Item B"], -1); listView.RetrieveVirtualItem += (s, e) => { @@ -1389,10 +1389,10 @@ private ListView GetListViewWithData(View view, bool createControl, bool virtual }; ListViewGroup listViewGroup = new("Test"); - ListViewItem listItem1 = new(new string[] { "Test Item 1", "Item A" }, -1, listViewGroup); + ListViewItem listItem1 = new(["Test Item 1", "Item A"], -1, listViewGroup); ListViewItem listItem2 = new("Group item 2", listViewGroup); ListViewItem listItem3 = new("Item 3"); - ListViewItem listItem4 = new(new string[] { "Test Item 4", "Item B", "Item C", "Item D" }, -1); + ListViewItem listItem4 = new(["Test Item 4", "Item B", "Item C", "Item D"], -1); if (!virtualMode) { diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewItemAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewItemAccessibleObjectTests.cs index 58626d261ee..fd7118e011f 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewItemAccessibleObjectTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewItemAccessibleObjectTests.cs @@ -562,23 +562,23 @@ public void ListViewItemAccessibleObject_FragmentNavigate_ListWithItems_VirtualM listView.VirtualListSize = 1; - ListViewItem listItem1 = new(new string[] - { + ListViewItem listItem1 = new( + [ "Test A", "Alpha" - }, -1); + ], -1); - ListViewItem listItem2 = new(new string[] - { + ListViewItem listItem2 = new( + [ "Test B", "Beta" - }, -1); + ], -1); - ListViewItem listItem3 = new(new string[] - { + ListViewItem listItem3 = new( + [ "Test C", "Gamma" - }, -1); + ], -1); listView.RetrieveVirtualItem += (s, e) => { @@ -652,7 +652,7 @@ public void ListViewItemAccessibleObject_State_ReturnExpected(View view, bool se Assert.NotEqual(IntPtr.Zero, listView.Handle); } - ListViewItem listItem1 = new(new string[] { "Test A", "Alpha" }, -1); + ListViewItem listItem1 = new(["Test A", "Alpha"], -1); listView.Items.Add(listItem1); listView.Items[0].Selected = selected; AccessibleObject accessibleObject = listView.Items[0].AccessibilityObject; @@ -696,7 +696,7 @@ public void ListViewItemAccessibleObject_State_Virtual_ModeReturnExpected(View v VirtualListSize = 1 }; - ListViewItem listItem1 = new(new string[] { "Test A", "Alpha" }, -1); + ListViewItem listItem1 = new(["Test A", "Alpha"], -1); listView.RetrieveVirtualItem += (s, e) => { @@ -1194,10 +1194,10 @@ private ListView GetListViewWithData(View view, bool createControl, bool virtual VirtualListSize = 4 }; - ListViewItem listItem1 = new(new string[] { "Test Item 1", "Item A" }, -1); + ListViewItem listItem1 = new(["Test Item 1", "Item A"], -1); ListViewItem listItem2 = new("Group item 2"); ListViewItem listItem3 = new("Item 3"); - ListViewItem listItem4 = new(new string[] { "Test Item 4", "Item B", "Item C", "Item D" }, -1); + ListViewItem listItem4 = new(["Test Item 4", "Item B", "Item C", "Item D"], -1); if (!virtualMode && groupsEnabled) { diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewItemDetailsAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewItemDetailsAccessibleObjectTests.cs index e391ae7f5d8..7a3edc529dc 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewItemDetailsAccessibleObjectTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewItemDetailsAccessibleObjectTests.cs @@ -163,8 +163,8 @@ private ListView GetListView() ColumnHeader columnHeader2 = new(); ColumnHeader columnHeader3 = new(); - ListViewItem listViewItem1 = new(new string[] { "Item1", "sub1", "sub2" }, 0); - ListViewItem listViewItem2 = new(new string[] { "Item2", "sub1", "sub2" }, 0); + ListViewItem listViewItem1 = new(["Item1", "sub1", "sub2"], 0); + ListViewItem listViewItem2 = new(["Item2", "sub1", "sub2"], 0); listView1.Columns.AddRange((ColumnHeader[])[columnHeader1, columnHeader2, columnHeader3]); listView1.Items.AddRange((ListViewItem[])[listViewItem1, listViewItem2]); diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObjectTests.cs index 93cff284f4f..0f09632baf0 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObjectTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObjectTests.cs @@ -14,12 +14,12 @@ public class ListViewItem_ListViewSubItem_ListViewSubItemAccessibleObjectTests public void ListViewSubItemAccessibleObject_GetChild_ReturnCorrectValue() { using ListView list = new(); - ListViewItem listViewItem1 = new(new string[] - { - "Test 1", - "Item 1", - "Something 1" - }, -1); + ListViewItem listViewItem1 = new( + [ + "Test 1", + "Item 1", + "Something 1" + ], -1); ColumnHeader columnHeader1 = new(); ColumnHeader columnHeader2 = new(); @@ -51,12 +51,12 @@ public void ListViewSubItemAccessibleObject_GetChild_ReturnCorrectValue() public void ListViewSubItemAccessibleObject_GetPropertyValue_returns_correct_values(bool labelEdit, int childId) { using ListView list = new(); - ListViewItem listViewItem1 = new(new string[] - { + ListViewItem listViewItem1 = new( + [ "Test 1", "Test 2", "Something 1" - }, -1); + ], -1); ColumnHeader columnHeader1 = new(); ColumnHeader columnHeader2 = new(); @@ -626,12 +626,12 @@ public void ListViewSubItemAccessibleObject_FragmentNavigate_NextSibling_Returns public void ListViewSubItemAccessibleObject_Bounds_ReturnCorrectValue() { using ListView list = new(); - ListViewItem listViewItem1 = new(new string[] - { + ListViewItem listViewItem1 = new( + [ "Test 1", "Item 1", "Something 1" - }, -1); + ], -1); ColumnHeader columnHeader1 = new(); ColumnHeader columnHeader2 = new(); @@ -750,12 +750,12 @@ public void ListViewSubItemAccessibleObject_ColumnProperty_ReturnMinusOne_ForNot public void ListViewSubItemAccessibleObject_RowProperty_ReturnCorrectValue() { using ListView list = new(); - ListViewItem listViewItem1 = new(new string[] - { + ListViewItem listViewItem1 = new( + [ "Test 1", "Item 1", "Something 1" - }, -1); + ], -1); ColumnHeader columnHeader1 = new(); ColumnHeader columnHeader2 = new(); diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComboBoxTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComboBoxTests.cs index 5f2a0aa650a..391e920536e 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComboBoxTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComboBoxTests.cs @@ -416,9 +416,9 @@ void AssertAutoCompleteCustomSource(string[] items, bool isHandleCreated) control.IsHandleCreated.Should().Be(isHandleCreated); } - AssertAutoCompleteCustomSource(new[] { "item1", "item2" }, false); + AssertAutoCompleteCustomSource(["item1", "item2"], false); AssertAutoCompleteCustomSource(null, false); - AssertAutoCompleteCustomSource(new[] { "item3", "item4" }, false); + AssertAutoCompleteCustomSource(["item3", "item4"], false); } [WinFormsFact] diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DomainUpDownTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DomainUpDownTests.cs index bb421adbd34..210e4905ae6 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DomainUpDownTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DomainUpDownTests.cs @@ -679,7 +679,7 @@ public void DomainUpDown_Sorted_SetWithItems_GetReturnsExpected(bool userEdit, b // Set different. _sub.Sorted = !value; _sub.Sorted.Should().Be(!value); - _sub.Items.Cast().Should().Equal(new string[] { "a", "a", "B", "c", "d" }); + _sub.Items.Cast().Should().Equal(["a", "a", "B", "c", "d"]); _sub.SelectedIndex.Should().Be(-1); _sub.UserEdit.Should().Be(userEdit); _sub.IsHandleCreated.Should().BeFalse(); @@ -722,7 +722,7 @@ public void DomainUpDown_Sorted_SetWithItemsWithSelection_GetReturnsExpected(boo // Set different. _sub.Sorted = !value; _sub.Sorted.Should().Be(!value); - _sub.Items.Cast().Should().Equal(new string[] { "a", "a", "B", "c", "d" }); + _sub.Items.Cast().Should().Equal(["a", "a", "B", "c", "d"]); _sub.SelectedIndex.Should().Be(expectedSelectedIndex); _sub.UserEdit.Should().Be(userEdit); _sub.IsHandleCreated.Should().BeFalse(); @@ -815,7 +815,7 @@ public void DomainUpDown_Sorted_SetWithItemsWithHandle_GetReturnsExpected(bool u // Set different. _sub.Sorted = !value; _sub.Sorted.Should().Be(!value); - _sub.Items.Cast().Should().Equal(new string[] { "a", "a", "B", "c", "d" }); + _sub.Items.Cast().Should().Equal(["a", "a", "B", "c", "d"]); _sub.SelectedIndex.Should().Be(-1); _sub.UserEdit.Should().Be(userEdit); _sub.IsHandleCreated.Should().BeTrue(); @@ -866,7 +866,7 @@ public void DomainUpDown_Sorted_SetWithItemsWithSelectionWithHandle_GetReturnsEx // Set different. _sub.Sorted = !value; _sub.Sorted.Should().Be(!value); - _sub.Items.Cast().Should().Equal(new string[] { "a", "a", "B", "c", "d" }); + _sub.Items.Cast().Should().Equal(["a", "a", "B", "c", "d"]); _sub.SelectedIndex.Should().Be(expectedSelectedIndex); _sub.UserEdit.Should().Be(userEdit); _sub.IsHandleCreated.Should().BeTrue(); diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewItemConverterTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewItemConverterTests.cs index f432e1d4d66..b015192279c 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewItemConverterTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewItemConverterTests.cs @@ -117,109 +117,109 @@ public static IEnumerable ConvertTo_InstanceDescriptor_TestData() // Item. yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1 }, "imageKey"), + new ListViewItem([subItem1], "imageKey"), new Type[] { typeof(string), typeof(string) }, new object[] { "text1", "imageKey" } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1 }, 1), + new ListViewItem([subItem1], 1), new Type[] { typeof(string), typeof(int) }, new object[] { "text1", 1 } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1 }, "imageKey", group), + new ListViewItem([subItem1], "imageKey", group), new Type[] { typeof(string), typeof(string) }, new object[] { "text1", "imageKey" } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1 }, 1, group), + new ListViewItem([subItem1], 1, group), new Type[] { typeof(string), typeof(int) }, new object[] { "text1", 1 } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1, subItem2 }, "imageKey"), + new ListViewItem([subItem1, subItem2], "imageKey"), new Type[] { typeof(string[]), typeof(string) }, new object[] { new string[] { "text1", "text2" }, "imageKey" } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1, subItem2 }, 1), + new ListViewItem([subItem1, subItem2], 1), new Type[] { typeof(string[]), typeof(int) }, new object[] { new string[] { "text1", "text2" }, 1 } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1, subItem2 }, "imageKey", group), + new ListViewItem([subItem1, subItem2], "imageKey", group), new Type[] { typeof(string[]), typeof(string) }, new object[] { new string[] { "text1", "text2" }, "imageKey" } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1, subItem2 }, 1, group), + new ListViewItem([subItem1, subItem2], 1, group), new Type[] { typeof(string[]), typeof(int) }, new object[] { new string[] { "text1", "text2" }, 1 } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1, subItem2, subItem3, subItem4, subItem5 }, "imageKey"), + new ListViewItem([subItem1, subItem2, subItem3, subItem4, subItem5], "imageKey"), new Type[] { typeof(ListViewItem.ListViewSubItem[]), typeof(string) }, new object[] { new ListViewItem.ListViewSubItem[] { subItem1, subItem2, subItem3, subItem4, subItem5 }, "imageKey" } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1, subItem2, subItem3, subItem4, subItem5 }, 1), + new ListViewItem([subItem1, subItem2, subItem3, subItem4, subItem5], 1), new Type[] { typeof(ListViewItem.ListViewSubItem[]), typeof(int) }, new object[] { new ListViewItem.ListViewSubItem[] { subItem1, subItem2, subItem3, subItem4, subItem5 }, 1 } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1, subItem2, subItem3, subItem4, subItem5 }, "imageKey", group), + new ListViewItem([subItem1, subItem2, subItem3, subItem4, subItem5], "imageKey", group), new Type[] { typeof(ListViewItem.ListViewSubItem[]), typeof(string) }, new object[] { new ListViewItem.ListViewSubItem[] { subItem1, subItem2, subItem3, subItem4, subItem5 }, "imageKey" } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem1, subItem2, subItem3, subItem4, subItem5 }, 1, group), + new ListViewItem([subItem1, subItem2, subItem3, subItem4, subItem5], 1, group), new Type[] { typeof(ListViewItem.ListViewSubItem[]), typeof(int) }, new object[] { new ListViewItem.ListViewSubItem[] { subItem1, subItem2, subItem3, subItem4, subItem5 }, 1 } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem3 }, 1), + new ListViewItem([subItem3], 1), new Type[] { typeof(string[]), typeof(int), typeof(Color), typeof(Color), typeof(Font) }, new object[] { new string[] { "text3" }, 1, Color.Blue, Color.Empty, null } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem4 }, 1), + new ListViewItem([subItem4], 1), new Type[] { typeof(string[]), typeof(int), typeof(Color), typeof(Color), typeof(Font) }, new object[] { new string[] { "text4" }, 1, Color.Empty, Color.Blue, null } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem5 }, 1), + new ListViewItem([subItem5], 1), new Type[] { typeof(string[]), typeof(int), typeof(Color), typeof(Color), typeof(Font) }, new object[] { new string[] { "text5" }, 1, Color.Empty, Color.Empty, SystemFonts.MenuFont } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem3 }, "imageKey"), + new ListViewItem([subItem3], "imageKey"), new Type[] { typeof(string[]), typeof(string), typeof(Color), typeof(Color), typeof(Font) }, new object[] { new string[] { "text3" }, "imageKey", Color.Blue, Color.Empty, null } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem4 }, "imageKey"), + new ListViewItem([subItem4], "imageKey"), new Type[] { typeof(string[]), typeof(string), typeof(Color), typeof(Color), typeof(Font) }, new object[] { new string[] { "text4" }, "imageKey", Color.Empty, Color.Blue, null } }; yield return new object[] { - new ListViewItem(new ListViewItem.ListViewSubItem[] { subItem5 }, "imageKey"), + new ListViewItem([subItem5], "imageKey"), new Type[] { typeof(string[]), typeof(string), typeof(Color), typeof(Color), typeof(Font) }, new object[] { new string[] { "text5" }, "imageKey", Color.Empty, Color.Empty, SystemFonts.MenuFont } }; diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewSubItemCollectionTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewSubItemCollectionTests.cs index 5102b934129..4cdfa82f478 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewSubItemCollectionTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewSubItemCollectionTests.cs @@ -916,7 +916,7 @@ public void ListViewSubItemCollection_AddRange_SetOwner() Assert.Null(subItem1._owner); Assert.Null(subItem2._owner); - listViewItem.SubItems.AddRange(new ListViewItem.ListViewSubItem[] { subItem1, subItem2 }); + listViewItem.SubItems.AddRange([subItem1, subItem2]); Assert.Same(listViewItem, subItem1._owner); Assert.Same(listViewItem, subItem2._owner); @@ -927,7 +927,7 @@ public void ListViewSubItemCollection_AddRange_String_SetOwner() { ListViewItem listViewItem = new(); - listViewItem.SubItems.AddRange(new string[] { "Test 1", "Test 2" }); + listViewItem.SubItems.AddRange(["Test 1", "Test 2"]); Assert.Same(listViewItem, listViewItem.SubItems[1]._owner); Assert.Same(listViewItem, listViewItem.SubItems[2]._owner); diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripComboBoxTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripComboBoxTests.cs index 101c48b11c5..992ca149d81 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripComboBoxTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripComboBoxTests.cs @@ -182,7 +182,7 @@ public void ToolStripComboBox_FlatStyle_SetAndGet(FlatStyle style) [WinFormsFact] public void ToolStripComboBox_Items_AddAndGet() { - string[] items = { "Item1", "Item2" }; + string[] items = ["Item1", "Item2"]; _toolStripComboBox.Items.AddRange(items); _toolStripComboBox.Items.Cast().Should().Contain(items); } diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripMenuItemTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripMenuItemTests.cs index c19782c7a2d..220dc5a5540 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripMenuItemTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripMenuItemTests.cs @@ -241,7 +241,7 @@ public void ToolStripMenuItem_Ctor_TextImageDropDownItems_ShouldInitializeCorrec { using Bitmap image = new(10, 10); string text = "Test Item"; - ToolStripItem[] dropDownItems = { new ToolStripMenuItem("SubItem1"), new ToolStripMenuItem("SubItem2") }; + ToolStripItem[] dropDownItems = [new ToolStripMenuItem("SubItem1"), new ToolStripMenuItem("SubItem2")]; using ToolStripMenuItem item = new(text, image, dropDownItems); diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripPanel.ToolStripPanelRowCollectionTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripPanel.ToolStripPanelRowCollectionTests.cs index 81a41f4197d..2ac71523c8b 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripPanel.ToolStripPanelRowCollectionTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripPanel.ToolStripPanelRowCollectionTests.cs @@ -44,7 +44,7 @@ public void ToolStripPanelRowCollection_ConstructorWithOwner_SetsOwner() public void ToolStripPanelRowCollection_ConstructorWithOwnerAndRows_SetsOwnerAndAddsRows() { using ToolStripPanelRow toolStripPanelRow1 = new(_toolStripPanel); - ToolStripPanelRow[] toolStripPanelRowArray = { toolStripPanelRow1 }; + ToolStripPanelRow[] toolStripPanelRowArray = [toolStripPanelRow1]; ToolStripPanelRowCollection toolStripPanelRowCollection = new(_toolStripPanel, toolStripPanelRowArray); ToolStripPanel toolStripPanel = toolStripPanelRowCollection.TestAccessor().Dynamic._owner; @@ -73,7 +73,7 @@ public void ToolStripPanelRowCollection_ConstructorWithOwnerAndValue_AddsRows() public void ToolStripPanelRowCollection_Add_AddsRow() { ToolStripPanelRow row = AddRowToCollection(collection: _toolStripPanelRowCollection, panel: _toolStripPanel); - ToolStripPanelRow[] rows = { row }; + ToolStripPanelRow[] rows = [row]; try { @@ -163,7 +163,7 @@ public void ToolStripPanelRowCollection_Clear_EmptyCollection_DoesNothing() public void ToolStripPanelRowCollection_Remove_RemovesRow() { var row = AddRowToCollection(collection: _toolStripPanelRowCollection, panel: _toolStripPanel); - ToolStripPanelRow[] rows = { row }; + ToolStripPanelRow[] rows = [row]; try { @@ -182,7 +182,7 @@ public void ToolStripPanelRowCollection_Remove_RowNotInCollection_DoesNothing() { var row1 = AddRowToCollection(collection: _toolStripPanelRowCollection, panel: _toolStripPanel); ToolStripPanelRow row2 = new(_toolStripPanel); - ToolStripPanelRow[] rows = { row1, row2 }; + ToolStripPanelRow[] rows = [row1, row2]; try { @@ -202,7 +202,7 @@ public void ToolStripPanelRowCollection_RemoveAt_RemovesRowAtIndex() { var row1 = AddRowToCollection(collection: _toolStripPanelRowCollection, panel: _toolStripPanel); var row2 = AddRowToCollection(collection: _toolStripPanelRowCollection, panel: _toolStripPanel); - ToolStripPanelRow[] rows = { row1, row2 }; + ToolStripPanelRow[] rows = [row1, row2]; try { @@ -221,7 +221,7 @@ public void ToolStripPanelRowCollection_RemoveAt_RemovesRowAtIndex() public void ToolStripPanelRowCollection_RemoveAt_IndexOutOfRange_ThrowsArgumentOutOfRangeException() { var row = AddRowToCollection(collection: _toolStripPanelRowCollection, panel: _toolStripPanel); - ToolStripPanelRow[] rows = { row }; + ToolStripPanelRow[] rows = [row]; try { @@ -277,7 +277,7 @@ public void ToolStripPanelRowCollection_CopyTo_NullArray_ThrowsArgumentNullExcep public void ToolStripPanelRowCollection_CopyTo_IndexOutOfRange_ThrowsArgumentException() { var row = AddRowToCollection(collection: _toolStripPanelRowCollection, panel: _toolStripPanel); - ToolStripPanelRow[] rows = { row }; + ToolStripPanelRow[] rows = [row]; var array = new ToolStripPanelRow[1]; try diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TreeViewTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TreeViewTests.cs index b3148d9ab72..e3d1d72593f 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TreeViewTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TreeViewTests.cs @@ -7534,7 +7534,7 @@ public void TreeView_ToString_Invoke_ReturnsExpected() [WinFormsFact] public void ArraySubsetEnumerator_Behavior_AfterMoveNextAndReset() { - object[] array = { "a", "b", "c" }; + object[] array = ["a", "b", "c"]; ArraySubsetEnumerator enumerator = new(array, 2); enumerator.MoveNext().Should().BeTrue();