Skip to content

Commit

Permalink
Moved to SDK RC2 (dotnet#12254)
Browse files Browse the repository at this point in the history
* Moved to SDK RC2 to get the same build errors in VS and CLI build and be able to fix them.

Before this change the IntPreview version of VS was correctly complaining about a redundant cast(IDE0004) in ToolStrip.cs
    g.DrawLines(SystemPens.ControlText, (ReadOnlySpan<Point>)
        [
            new(verticalBeamStart, _lastInsertionMarkRect.Y), new(verticalBeamStart, _lastInsertionMarkRect.Bottom - 1),
            new(verticalBeamStart + 1, _lastInsertionMarkRect.Y), new(verticalBeamStart + 1, _lastInsertionMarkRect.Bottom - 1)
        ]);

But the CLI build required this cast.

After the upgrade to RC2, IDE0300 - Collection initialization can be simplified - became more robust and required code fixes that use collection expressions applied to the solution.
  • Loading branch information
Tanya-Solyanik authored and paul1956 committed Oct 4, 2024
1 parent a4224c5 commit 2b5f268
Show file tree
Hide file tree
Showing 32 changed files with 194 additions and 209 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -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)"
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) });
Expand Down Expand Up @@ -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<ArgumentException, ArgumentOutOfRangeException>(
() => 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]
Expand All @@ -615,15 +615,15 @@ 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<ArgumentException, ArgumentOutOfRangeException>(
() => 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]
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);

Expand All @@ -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) });
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -1194,11 +1194,11 @@ public void Flatten_ClosedCurve_Success()
{
using GraphicsPath gp = new();
using GraphicsPath clone = Assert.IsType<GraphicsPath>(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);
Expand All @@ -1209,11 +1209,11 @@ public void Flatten_Curve_Success()
{
using GraphicsPath gp = new();
using GraphicsPath clone = Assert.IsType<GraphicsPath>(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);
Expand Down Expand Up @@ -1254,11 +1254,11 @@ public void Flatten_Polygon_Success()
{
using GraphicsPath gp = new();
using GraphicsPath clone = Assert.IsType<GraphicsPath>(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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/System.Drawing.Common/tests/System/Drawing/GraphicsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ public void TransformPoints_InvalidDestSpace_ThrowsArgumentException(CoordinateS
{
using Bitmap image = new(10, 10);
using Graphics graphics = Graphics.FromImage(image);
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(destSpace, CoordinateSpace.World, new Point[] { new(1, 1) }));
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(destSpace, CoordinateSpace.World, [new(1, 1)]));
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(destSpace, CoordinateSpace.World, new PointF[] { new(1, 1) }));
}

Expand All @@ -1861,7 +1861,7 @@ public void TransformPoints_InvalidSourceSpace_ThrowsArgumentException(Coordinat
{
using Bitmap image = new(10, 10);
using Graphics graphics = Graphics.FromImage(image);
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.World, srcSpace, new Point[] { new(1, 1) }));
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.World, srcSpace, [new(1, 1)]));
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.World, srcSpace, new PointF[] { new(1, 1) }));
}

Expand Down Expand Up @@ -1891,8 +1891,8 @@ public void TransformPoints_Busy_ThrowsInvalidOperationException()
graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new Point[] { Point.Empty }));
Assert.Throws<InvalidOperationException>(() => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new PointF[] { PointF.Empty }));
Assert.Throws<InvalidOperationException>(() => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, [Point.Empty]));
Assert.Throws<InvalidOperationException>(() => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, [PointF.Empty]));
}
finally
{
Expand All @@ -1907,8 +1907,8 @@ public void TransformPoints_Disposed_ThrowsArgumentException()
Graphics graphics = Graphics.FromImage(image);
graphics.Dispose();

AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new Point[] { Point.Empty }));
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new PointF[] { PointF.Empty }));
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, [Point.Empty]));
AssertExtensions.Throws<ArgumentException>(null, () => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, [PointF.Empty]));
}

public static IEnumerable<object[]> GetNearestColor_TestData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<IndexOutOfRangeException>(() => _ = cm[5, 5]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
[
Expand Down Expand Up @@ -114,14 +114,14 @@ public static IEnumerable<object[]> 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);
Expand Down
Loading

0 comments on commit 2b5f268

Please sign in to comment.