From 4c61c6325014dc2e617c9663069be6cbc460bdf2 Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Wed, 2 Oct 2024 14:37:15 -0800 Subject: [PATCH 01/15] No code Chnages just formatting --- .../SingleInstanceHelpers.vb | 73 +++++++++++++------ 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb index 5895efb9536..7e017d14482 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb @@ -12,20 +12,25 @@ Namespace Microsoft.VisualBasic.ApplicationServices Friend Module SingleInstanceHelpers Private Const NamedPipeOptions As PipeOptions = PipeOptions.Asynchronous Or PipeOptions.CurrentUserOnly - Private Async Function ReadArgsAsync(pipeServer As NamedPipeServerStream, cancellationToken As CancellationToken) As Task(Of String()) + Private Async Function ReadArgsAsync( + pipeServer As NamedPipeServerStream, + cancellationToken As CancellationToken) As Task(Of String()) + Const bufferLength As Integer = 1024 Dim buffer As Byte() = New Byte(bufferLength - 1) {} Using stream As New MemoryStream While True Dim bytesRead As Integer = Await pipeServer.ReadAsync( - buffer.AsMemory(0, bufferLength), - cancellationToken).ConfigureAwait(False) + buffer:=buffer.AsMemory(start:=0, length:=bufferLength), + cancellationToken) _ + .ConfigureAwait(continueOnCapturedContext:=False) If bytesRead = 0 Then Exit While End If Await stream.WriteAsync( - buffer.AsMemory(0, bytesRead), - cancellationToken).ConfigureAwait(False) + buffer:=buffer.AsMemory(start:=0, length:=bytesRead), + cancellationToken) _ + .ConfigureAwait(continueOnCapturedContext:=False) End While stream.Seek(0, SeekOrigin.Begin) Dim serializer As New DataContractSerializer(GetType(String())) @@ -37,35 +42,51 @@ Namespace Microsoft.VisualBasic.ApplicationServices End Using End Function - Private Async Function WriteArgsAsync(pipeClient As NamedPipeClientStream, args As String(), cancellationToken As CancellationToken) As Task + Private Async Function WriteArgsAsync( + pipeClient As NamedPipeClientStream, + args As String(), + cancellationToken As CancellationToken) As Task + Dim content As Byte() Using stream As New MemoryStream Dim serializer As New DataContractSerializer(GetType(String())) serializer.WriteObject(stream, args) content = stream.ToArray() End Using - Await pipeClient.WriteAsync(content.AsMemory(0, content.Length), cancellationToken).ConfigureAwait(False) + Await pipeClient.WriteAsync( + buffer:=content.AsMemory(start:=0, length:=content.Length), cancellationToken) _ + .ConfigureAwait(continueOnCapturedContext:=False) End Function - Friend Async Function SendSecondInstanceArgsAsync(pipeName As String, args As String(), cancellationToken As CancellationToken) As Task + Friend Async Function SendSecondInstanceArgsAsync( + pipeName As String, + args As String(), + cancellationToken As CancellationToken) As Task + Using pipeClient As New NamedPipeClientStream( - serverName:=".", - pipeName:=pipeName, - direction:=PipeDirection.Out, - options:=NamedPipeOptions) - Await pipeClient.ConnectAsync(cancellationToken).ConfigureAwait(False) - Await WriteArgsAsync(pipeClient, args, cancellationToken).ConfigureAwait(False) + serverName:=".", + pipeName:=pipeName, + direction:=PipeDirection.Out, + options:=NamedPipeOptions) + + Await pipeClient.ConnectAsync(cancellationToken) _ + .ConfigureAwait(continueOnCapturedContext:=False) + Await WriteArgsAsync(pipeClient, args, cancellationToken) _ + .ConfigureAwait(continueOnCapturedContext:=False) End Using End Function - Friend Function TryCreatePipeServer(pipeName As String, ByRef pipeServer As NamedPipeServerStream) As Boolean + Friend Function TryCreatePipeServer( + pipeName As String, + ByRef pipeServer As NamedPipeServerStream) As Boolean + Try pipeServer = New NamedPipeServerStream( - pipeName:=pipeName, - direction:=PipeDirection.In, - maxNumberOfServerInstances:=1, - transmissionMode:=PipeTransmissionMode.Byte, - options:=NamedPipeOptions) + pipeName:=pipeName, + direction:=PipeDirection.In, + maxNumberOfServerInstances:=1, + transmissionMode:=PipeTransmissionMode.Byte, + options:=NamedPipeOptions) Return True Catch ex As Exception pipeServer = Nothing @@ -73,12 +94,18 @@ Namespace Microsoft.VisualBasic.ApplicationServices End Try End Function - Friend Async Function WaitForClientConnectionsAsync(pipeServer As NamedPipeServerStream, callback As Action(Of String()), cancellationToken As CancellationToken) As Task + Friend Async Function WaitForClientConnectionsAsync( + pipeServer As NamedPipeServerStream, + callback As Action(Of String()), + cancellationToken As CancellationToken) As Task + While True cancellationToken.ThrowIfCancellationRequested() - Await pipeServer.WaitForConnectionAsync(cancellationToken).ConfigureAwait(False) + Await pipeServer.WaitForConnectionAsync(cancellationToken) _ + .ConfigureAwait(continueOnCapturedContext:=False) Try - Dim args() As String = Await ReadArgsAsync(pipeServer, cancellationToken).ConfigureAwait(False) + Dim args() As String = Await ReadArgsAsync(pipeServer, cancellationToken) _ + .ConfigureAwait(continueOnCapturedContext:=False) If args IsNot Nothing Then callback(args) End If From a4224c5cc33cc33f4fc822067c117c9bfd88302e Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Wed, 2 Oct 2024 14:46:14 -0800 Subject: [PATCH 02/15] Add tests for SignleInstanceHelper from #11863 --- .../Forms/SingleInstanceHelpersTests.vb | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb new file mode 100644 index 00000000000..14f1cd7b4bf --- /dev/null +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb @@ -0,0 +1,85 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. + +Imports System.IO.Pipes +Imports System.Runtime.CompilerServices +Imports System.Threading +Imports FluentAssertions +Imports Microsoft.VisualBasic.ApplicationServices + +Imports Xunit + +Namespace Microsoft.VisualBasic.Forms.Tests + + Public Class SingleInstanceHelpersTests + Private _resultArgs As String() + + Private Sub OnStartupNextInstanceMarshallingAdaptor(args As String()) + If args.Length = 1 Then + _resultArgs = {"Hello"} + End If + End Sub + + + Public Sub TryCreatePipeServerTests() + Dim pipeName As String = GetUniqueText() + Dim pipeServer As NamedPipeServerStream = Nothing + TryCreatePipeServer(pipeName, pipeServer).Should.BeTrue() + Using pipeServer + pipeServer.CanRead.Should.BeTrue() + pipeServer.CanSeek.Should.BeFalse() + pipeServer.CanWrite.Should.BeFalse() + pipeServer.TransmissionMode.Should.Be(PipeTransmissionMode.Byte) + End Using + End Sub + + + Public Sub TryCreatePipeServerTwiceTests_Fail() + Dim pipeName As String = GetUniqueText() + Dim pipeServer As NamedPipeServerStream = Nothing + TryCreatePipeServer(pipeName, pipeServer).Should.BeTrue() + Dim pipeServer1 As NamedPipeServerStream = Nothing + TryCreatePipeServer(pipeName, pipeServer1).Should.BeFalse() + Using pipeServer + pipeServer1.Should.BeNull() + End Using + End Sub + + + Public Async Function WaitForClientConnectionsAsyncTests() As Task + Dim pipeName As String = GetUniqueText() + Dim pipeServer As NamedPipeServerStream = Nothing + If TryCreatePipeServer(pipeName, pipeServer) Then + + Using pipeServer + Dim tokenSource As New CancellationTokenSource() + Dim clientConnection As Task = WaitForClientConnectionsAsync( + pipeServer, + callback:=AddressOf OnStartupNextInstanceMarshallingAdaptor, + cancellationToken:=tokenSource.Token) + + Dim commandLine As String() = {"Hello"} + Dim awaitable As ConfiguredTaskAwaitable = SendSecondInstanceArgsAsync( + pipeName, + args:=commandLine, + cancellationToken:=tokenSource.Token) _ + .ConfigureAwait(continueOnCapturedContext:=False) + + awaitable.GetAwaiter().GetResult() + Dim CancelToken As New CancellationToken + Dim buffer As Byte() = New Byte(commandLine.Length) {} + Dim count As Integer = Await pipeServer.ReadAsync( + buffer:=buffer.AsMemory(start:=0, length:=commandLine.Length)) + + ' Ensure the result is set + Do + Await Task.Delay(5) + Loop Until _resultArgs IsNot Nothing + _resultArgs(0).Should.Be("Hello") + Await tokenSource.CancelAsync() + End Using + End If + End Function + + End Class +End Namespace From 2b5f2687df2e15516f78e2986d4b29d464b09b8b Mon Sep 17 00:00:00 2001 From: Tanya Solyanik Date: Wed, 2 Oct 2024 18:23:28 -0700 Subject: [PATCH 03/15] Moved to SDK RC2 (#12254) * 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) [ 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. --- .editorconfig | 2 +- global.json | 4 +- .../Drawing/Drawing2D/GraphicsPathTests.cs | 82 +++++++++---------- .../tests/System/Drawing/GraphicsTests.cs | 12 +-- .../System/Drawing/Graphics_DrawLineTests.cs | 2 +- .../Drawing/Imaging/ColorMatrixTests.cs | 12 +-- .../Drawing/Imaging/ImageAttributesTests.cs | 18 ++-- .../tests/System/Drawing/PenTests.cs | 2 +- .../tests/System/Drawing/RegionTests.cs | 8 +- .../mono/System.Drawing/GraphicsTests.cs | 7 +- .../Windows/Forms/Design/StyleEditorForm.cs | 17 +--- ...deDomComponentSerializationServiceTests.cs | 54 ++++++------ ...Designer.DesignerControlCollectionTests.cs | 2 +- .../ComboBox/ComboBox.FlatComboAdapter.cs | 5 +- .../DataGridView/DataGridViewComboBoxCell.cs | 8 +- .../PropertyGridInternal/PropertyGridView.cs | 2 +- .../Forms/Controls/ToolStrips/ToolStrip.cs | 12 +-- ...ntrol.ToolStripComboBoxFlatComboAdapter.cs | 6 +- .../UIIntegrationTests/ListViewTests.cs | 6 +- .../WinformsControlsTest/ListViewTest.cs | 2 +- .../ListVIew.ListViewAccessibleObjectTests.cs | 8 +- ...wItem.ListViewItemAccessibleObjectTests.cs | 26 +++--- ...istViewItemDetailsAccessibleObjectTests.cs | 4 +- ...em.ListViewSubItemAccessibleObjectTests.cs | 30 +++---- .../System/Windows/Forms/ComboBoxTests.cs | 4 +- .../System/Windows/Forms/DomainUpDownTests.cs | 8 +- .../Forms/ListViewItemConverterTests.cs | 36 ++++---- .../Forms/ListViewSubItemCollectionTests.cs | 4 +- .../Windows/Forms/ToolStripComboBoxTests.cs | 2 +- .../Windows/Forms/ToolStripMenuItemTests.cs | 2 +- ...pPanel.ToolStripPanelRowCollectionTests.cs | 14 ++-- .../System/Windows/Forms/TreeViewTests.cs | 2 +- 32 files changed, 194 insertions(+), 209 deletions(-) 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(); From 1bcf23919b8bf5a204fed18412d6b952766ff266 Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Wed, 2 Oct 2024 20:43:30 -0700 Subject: [PATCH 04/15] Adds XML Comments to FileSystemProxy and SpecialDirectoriesProxy (#12141) * Add XML Comments related to FileSystemProxy which includes SpecialDirectoriesProxy * Fix some types * Add some language keywords * Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb Co-authored-by: Loni Tra * Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb Co-authored-by: Loni Tra * Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb Co-authored-by: Loni Tra * Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb Co-authored-by: Loni Tra * PR feedback * Update all XML comments * Fix Typo in FileSystemProxy that caused build to fail. * Update XML Coments * Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb Co-authored-by: Tanya Solyanik * Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb Co-authored-by: Tanya Solyanik * Redo all the comments in SpecialDirectoriesProxy * Add cref per PR feedback and changed type to Namespace * PR Feedback to add see cref's --------- Co-authored-by: Loni Tra Co-authored-by: Tanya Solyanik --- .../VisualBasic/MyServices/FileSystemProxy.vb | 1225 ++++++++++++++++- .../MyServices/SpecialDirectoriesProxy.vb | 107 +- 2 files changed, 1324 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb index 40ef540cbf5..46387be5f97 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb @@ -3,13 +3,17 @@ Imports System.Collections.ObjectModel Imports System.ComponentModel +Imports System.Security Imports System.Text Imports Microsoft.VisualBasic.FileIO Namespace Microsoft.VisualBasic.MyServices ''' - ''' An extremely thin wrapper around to expose the type through . + ''' This class represents the on a computer. + ''' It allows browsing the existing drives, special directories; + ''' and also contains some commonly use methods for IO tasks. + ''' It exposes them through the ''' Public Class FileSystemProxy @@ -22,6 +26,10 @@ Namespace Microsoft.VisualBasic.MyServices Friend Sub New() End Sub + ''' + ''' Gets or sets the current working directory. + ''' + ''' A String containing the path to the directory. Public Property CurrentDirectory() As String Get Return FileIO.FileSystem.CurrentDirectory @@ -31,12 +39,22 @@ Namespace Microsoft.VisualBasic.MyServices End Set End Property + ''' + ''' Returns the names of all available drives on the computer. + ''' + ''' A containing all the current drive names. Public ReadOnly Property Drives() As ReadOnlyCollection(Of IO.DriveInfo) Get Return FileIO.FileSystem.Drives End Get End Property + ''' + ''' Returns an instance of + ''' specific to the current user (My Documents, My Music ...) and those specific + ''' to the current Application that a developer expects to be able to find quickly. + ''' + ''' a cached instance of Public ReadOnly Property SpecialDirectories() As SpecialDirectoriesProxy Get If _specialDirectoriesProxy Is Nothing Then @@ -46,22 +64,154 @@ Namespace Microsoft.VisualBasic.MyServices End Get End Property + ''' + ''' Combines two path strings by adding a path separator. + ''' + ''' The first part of the path. + ''' The second part of the path, must be a relative path. + ''' A String contains the combined path. + ''' + ''' or are malformed paths. + ''' Public Function CombinePath(baseDirectory As String, relativePath As String) As String Return FileIO.FileSystem.CombinePath(baseDirectory, relativePath) End Function + ''' + ''' Copy an existing directory to a new directory, + ''' throwing exception if there are existing files with the same name. + ''' + ''' The path to the source directory, can be relative or absolute. + ''' + ''' The path to the target directory, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The source directory does not exist. + ''' The source path and target path are the same. + ''' The path exceeds the system-defined maximum length. + ''' The operation is cyclic. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' The user lacks necessary permissions to view the path. + ''' A destination file exists but cannot be accessed. Public Sub CopyDirectory(sourceDirectoryName As String, destinationDirectoryName As String) FileIO.FileSystem.CopyDirectory(sourceDirectoryName, destinationDirectoryName) End Sub + ''' + ''' Copy an existing directory to a new directory, + ''' overwriting existing files with the same name if specified. + ''' + ''' The path to the source directory, can be relative or absolute. + ''' + ''' The path to the target directory, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' to overwrite existing files with the same name. + ''' Otherwise . + ''' + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The source directory does not exist. + ''' The source path and target path are the same. + ''' The path exceeds the system-defined maximum length. + ''' The operation is cyclic. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' The user lacks necessary permissions to view the path. + ''' A destination file exists but cannot be accessed. Public Sub CopyDirectory(sourceDirectoryName As String, destinationDirectoryName As String, overwrite As Boolean) FileIO.FileSystem.CopyDirectory(sourceDirectoryName, destinationDirectoryName, overwrite) End Sub + ''' + ''' Copy an existing directory to a new directory, + ''' displaying and confirmation dialogs if specified, + ''' throwing if user cancels the operation + ''' (only applies if displaying ProgressDialog and confirmation dialogs). + ''' + ''' The path to the source directory, can be relative or absolute. + ''' + ''' The path to the target directory, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The source directory does not exist. + ''' The source path and target path are the same. + ''' The path exceeds the system-defined maximum length. + ''' The operation is cyclic. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' The user lacks necessary permissions to view the path. + ''' A destination file exists but cannot be accessed. + ''' The user cancels the operation or the directory cannot be copied. Public Sub CopyDirectory(sourceDirectoryName As String, destinationDirectoryName As String, showUI As UIOption) FileIO.FileSystem.CopyDirectory(sourceDirectoryName, destinationDirectoryName, showUI) End Sub + ''' + ''' Copy an existing directory to a new directory, + ''' displaying and confirmation messages if specified, + ''' throwing exception if user cancels the operation if specified. + ''' (only applies if displaying ProgressDialog and confirmation messages). + ''' + ''' The path to the source directory, can be relative or absolute. + ''' + ''' The path to the target directory, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' Specifies whether to throw an if the user clicks Cancel.>. + ''' + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The source directory does not exist. + ''' The source path and target path are the same. + ''' The path exceeds the system-defined maximum length. + ''' The operation is cyclic. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' The user lacks necessary permissions to view the path. + ''' A destination file exists but cannot be accessed. + ''' + ''' The user cancelled the operation and is set to . + ''' Public Sub CopyDirectory( sourceDirectoryName As String, destinationDirectoryName As String, @@ -71,38 +221,260 @@ Namespace Microsoft.VisualBasic.MyServices FileIO.FileSystem.CopyDirectory(sourceDirectoryName, destinationDirectoryName, showUI, onUserCancel) End Sub + ''' + ''' Copy an existing file to a new file. Overwriting a file of the same name is not allowed. + ''' + ''' The path to the source file, can be relative or absolute. + ''' + ''' The path to the destination file, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' contains path information. + ''' + ''' + ''' or is Nothing or an empty string. + ''' + ''' The source file is not valid or does not exist. + ''' A file in the target directory with the same name is in use. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have required permission. + ''' The user lacks necessary permissions to view the path. Public Sub CopyFile(sourceFileName As String, destinationFileName As String) FileIO.FileSystem.CopyFile(sourceFileName, destinationFileName) End Sub + ''' + ''' Copy an existing file to a new file. Overwriting a file of the same name if specified. + ''' + ''' The path to the source file, can be relative or absolute. + ''' + ''' The path to the destination file, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' to overwrite existing file with the same name. + ''' Otherwise . + ''' + ''' + ''' contains path information. + ''' + ''' + ''' or is Nothing or an empty string. + ''' + ''' The source file is not valid or does not exist. + ''' A file in the target directory with the same name is in use. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have required permission. + ''' The user lacks necessary permissions to view the path. Public Sub CopyFile(sourceFileName As String, destinationFileName As String, overwrite As Boolean) FileIO.FileSystem.CopyFile(sourceFileName, destinationFileName, overwrite) End Sub + ''' + ''' Copy an existing file to a new file, + ''' displaying and confirmation messages if specified, + ''' will throw exception if user cancels the operation. + ''' + ''' The path to the source file, can be relative or absolute. + ''' + ''' The path to the destination file, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' contains path information. + ''' + ''' + ''' or is Nothing or an empty string. + ''' + ''' The source file is not valid or does not exist. + ''' A file in the target directory with the same name is in use. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have required permission. + ''' The user lacks necessary permissions to view the path. Public Sub CopyFile(sourceFileName As String, destinationFileName As String, showUI As UIOption) FileIO.FileSystem.CopyFile(sourceFileName, destinationFileName, showUI) End Sub + ''' + ''' Copy an existing file to a new file, + ''' displaying and confirmation messages if specified, + ''' will throw if user cancels the operation if specified. + ''' + ''' The path to the source file, can be relative or absolute. + ''' + ''' The path to the destination file, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' Specifies whether to throw an if the user clicks Cancel.>. + ''' + ''' + ''' contains path information. + ''' + ''' + ''' or is Nothing or an empty string. + ''' + ''' The source file is not valid or does not exist. + ''' A file in the target directory with the same name is in use. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have required permission. + ''' The user lacks necessary permissions to view the path. + ''' + ''' The user cancelled the operation and is set to . + ''' Public Sub CopyFile( sourceFileName As String, destinationFileName As String, showUI As UIOption, onUserCancel As UICancelOption) + FileIO.FileSystem.CopyFile(sourceFileName, destinationFileName, showUI, onUserCancel) End Sub + ''' + ''' Creates a directory from the given path (including all parent directories). + ''' + ''' The path to create the directory at. + ''' + ''' The directory name is malformed. For example, it contains illegal characters or is only white space. + ''' + ''' + ''' is or an empty string. + ''' + ''' The directory name is too long. + ''' + ''' The directory name is only a colon (:). + ''' + ''' The parent directory of the directory to be created is read-only. + ''' The user does not have permission to create the directory. Public Sub CreateDirectory(directory As String) FileIO.FileSystem.CreateDirectory(directory) End Sub - Public Sub DeleteDirectory(directory As String, showUI As UIOption, recycle As RecycleOption) - FileIO.FileSystem.DeleteDirectory(directory, showUI, recycle) - End Sub - + ''' + ''' Deletes the given directory, with options to recursively delete. + ''' + ''' The path to the directory. + ''' + ''' to delete everything. + ''' + ''' to throw if the directory is not empty. + ''' + ''' + ''' + ''' The path is a zero-length string, is malformed, contains only white space, + ''' or contains invalid characters (including wildcard characters). + ''' The path is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The directory does not exist or is a file. + ''' A file in the directory or subdirectory is in use. + ''' + ''' The directory name is only a colon (:). + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have permission to create the directory. + ''' The user lacks necessary permissions to view the path. Public Sub DeleteDirectory(directory As String, onDirectoryNotEmpty As DeleteDirectoryOption) FileIO.FileSystem.DeleteDirectory(directory, onDirectoryNotEmpty) End Sub + ''' + ''' Deletes the given directory, + ''' with UI options to show , and + ''' throwing if user cancels. + ''' recycle options to or , + ''' + ''' The path to the directory. + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' Specifies whether or not the deleted file should be sent to the Recycle Bin. + ''' Default is + ''' + ''' + ''' The path is a zero-length string, is malformed, contains only white space, + ''' or contains invalid characters (including wildcard characters). + ''' The path is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The directory does not exist or is a file. + ''' The source is a root directory or The source path and the target path are the same. + ''' + ''' The directory name is only a colon (:). + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have permission to create the directory. + ''' The user lacks necessary permissions to view the path. + ''' The user cancels the operation or the directory cannot be deleted. + Public Sub DeleteDirectory(directory As String, showUI As UIOption, recycle As RecycleOption) + FileIO.FileSystem.DeleteDirectory(directory, showUI, recycle) + End Sub + + ''' + ''' Deletes the given directory, + ''' with UI options to show , + ''' recycle options , , + ''' and UI cancel options to , or . + ''' + ''' The path to the directory. + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' Specifies whether or not the deleted file should be sent to the Recycle Bin. + ''' Default is + ''' + ''' + ''' Specifies whether to throw an if the user clicks Cancel.>. + ''' + ''' + ''' The path is a zero-length string, is malformed, contains only white space, + ''' or contains invalid characters (including wildcard characters). + ''' The path is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The directory does not exist or is a file. + ''' A file in the directory or subdirectory is in use. + ''' + ''' The directory name is only a colon (:). + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have permission to create the directory. + ''' The user lacks necessary permissions to view the path. + ''' + ''' The user cancelled the operation and is set to . + ''' Public Sub DeleteDirectory( directory As String, showUI As UIOption, @@ -112,10 +484,63 @@ Namespace Microsoft.VisualBasic.MyServices FileIO.FileSystem.DeleteDirectory(directory, showUI, recycle, onUserCancel) End Sub + ''' + ''' Delete the given file. + ''' + ''' The path to the file. + ''' + ''' The path Is Not valid For one Of the following reasons: + ''' It Is a zero-length string; + ''' It contains only white space; + ''' It contains invalid characters; + ''' It has a trailing slash where a file must be specified; + ''' It Is a device path (starts with \.\). + ''' + ''' File is or an empty string. + ''' The path exceeds the system-defined maximum length. + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' The file is in use. + ''' The user lacks necessary permissions to view the path. + ''' The file does not exist. + ''' The user does not have permission to delete the file or the file is read-only. Public Sub DeleteFile(file As String) FileIO.FileSystem.DeleteFile(file) End Sub + ''' + ''' Delete the given file, with options to show , delete to recycle bin, + ''' and whether to throw exception if user cancels. + ''' + ''' The path to the file. + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' Specifies whether or not the deleted file should be sent to the Recycle Bin. + ''' Default is + ''' + ''' + ''' Specifies whether to throw an if the user clicks Cancel.>. + ''' + ''' + ''' The path Is Not valid For one Of the following reasons: + ''' It Is a zero-length string; + ''' It contains only white space; + ''' It contains invalid characters; + ''' It has a trailing slash where a file must be specified; + ''' It Is a device path (starts with \.\). + ''' + ''' File is or an empty string. + ''' The path exceeds the system-defined maximum length. + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' The file is in use. + ''' The user lacks necessary permissions to view the path. + ''' The file does not exist. + ''' The user does not have permission to delete the file or the file is read-only. + ''' + ''' The user cancelled the operation and is set to . + ''' Public Sub DeleteFile( file As String, showUI As UIOption, @@ -125,24 +550,126 @@ Namespace Microsoft.VisualBasic.MyServices FileIO.FileSystem.DeleteFile(file, showUI, recycle, onUserCancel) End Sub + ''' + ''' Delete the given file, with options to show , delete to recycle bin. + ''' + ''' The path to the file. + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' Specifies whether or not the deleted file should be sent to the Recycle Bin. + ''' Default is + ''' + ''' + ''' The path Is Not valid For one Of the following reasons: + ''' It Is a zero-length string; + ''' It contains only white space; + ''' It contains invalid characters; + ''' It has a trailing slash where a file must be specified; + ''' It Is a device path (starts with \.\). + ''' + ''' File is or an empty string. + ''' The path exceeds the system-defined maximum length. + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' The file is in use. + ''' The user lacks necessary permissions to view the path. + ''' The file does not exist. + ''' The user does not have permission to delete the file or the file is read-only. Public Sub DeleteFile(file As String, showUI As UIOption, recycle As RecycleOption) FileIO.FileSystem.DeleteFile(file, showUI, recycle) End Sub + ''' + ''' Determines whether the given path refers to an existing directory on disk. + ''' + ''' The path to verify. + ''' + ''' if DirectoryPath refers to an existing directory. + ''' Otherwise, . + ''' Public Function DirectoryExists(directory As String) As Boolean Return FileIO.FileSystem.DirectoryExists(directory) End Function + ''' + ''' Determines whether the given path refers to an existing file on disk. + ''' + ''' The path to verify. + ''' + ''' if FilePath refers to an existing file on disk. + ''' Otherwise, . + ''' Public Function FileExists(file As String) As Boolean Return FileIO.FileSystem.FileExists(file) End Function - Public Function FindInFiles(directory As String, - containsText As String, ignoreCase As Boolean, searchType As SearchOption) As ReadOnlyCollection(Of String) + ''' + ''' Find files in the given folder that contain the given text. + ''' + ''' The folder path to start from. + ''' The text to be found in file. + ''' + ''' to ignore case. + ''' Otherwise, . + ''' + ''' + ''' to find recursively, + ''' otherwise, . + ''' + ''' A string array containing the files that match the search condition. + ''' File is or an empty string. + ''' The does not exist. + ''' The specified points to an existing file. + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or + ''' is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user lacks necessary permissions. + Public Function FindInFiles( + directory As String, + containsText As String, + ignoreCase As Boolean, + searchType As SearchOption) As ReadOnlyCollection(Of String) Return FileIO.FileSystem.FindInFiles(directory, containsText, ignoreCase, searchType) End Function + ''' + ''' Find files in the given folder that contain the given text. + ''' + ''' The folder path to start from. + ''' The text to be found in file. + ''' + ''' to ignore case. + ''' Otherwise, . + ''' + ''' + ''' to find recursively, + ''' otherwise, . + ''' + ''' The search patterns to use for the file name ("*.*") + ''' A string array containing the files that match the search condition. + ''' + ''' is Nothing or an empty string. + ''' + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; or it is a device path. + ''' + ''' File is or an empty string. + ''' The does not exist. + ''' The specified points to an existing file. + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or + ''' is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user lacks necessary permissions. Public Function FindInFiles( directory As String, containsText As String, @@ -153,10 +680,51 @@ Namespace Microsoft.VisualBasic.MyServices Return FileIO.FileSystem.FindInFiles(directory, containsText, ignoreCase, searchType, fileWildcards) End Function + ''' + ''' Return the paths of sub directories found directly under a directory. + ''' + ''' The directory to find the sub directories inside. + ''' A ReadOnlyCollection(Of String) containing the matched directories' paths. + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The source directory does not exist. + ''' The specified directory points to an existing file. + ''' The path exceeds the system-defined maximum length. + ''' The operation is cyclic. + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' The user lacks necessary permissions to view the path. + ''' A destination file exists but cannot be accessed. Public Function GetDirectories(directory As String) As ReadOnlyCollection(Of String) Return FileIO.FileSystem.GetDirectories(directory) End Function + ''' + ''' Return the paths of sub directories found under a directory with the specified name patterns. + ''' + ''' The directory to find the sub directories inside. + ''' + ''' to find recursively, + ''' otherwise, . + ''' + ''' The wildcards for the file name, for example "*.bmp", "*.txt" + ''' A ReadOnlyCollection(Of String) containing the matched directories' paths. + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The directory path contains a colon (:) or is in an invalid format. + ''' The user lacks necessary permissions to view the path. Public Function GetDirectories( directory As String, searchType As SearchOption, @@ -165,22 +733,117 @@ Namespace Microsoft.VisualBasic.MyServices Return FileIO.FileSystem.GetDirectories(directory, searchType, wildcards) End Function + ''' + ''' Returns the information object about the specified directory. + ''' + ''' The path to the directory. + ''' A DirectoryInfo object containing the information about the specified directory. + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user lacks necessary permissions to view the path. Public Function GetDirectoryInfo(directory As String) As IO.DirectoryInfo Return FileIO.FileSystem.GetDirectoryInfo(directory) End Function + ''' + ''' Return the information about the specified drive. + ''' + ''' The path to the drive. + ''' A DriveInfo object containing the information about the specified drive. + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user lacks necessary permissions to view the path. Public Function GetDriveInfo(drive As String) As IO.DriveInfo Return FileIO.FileSystem.GetDriveInfo(drive) End Function + ''' + ''' Returns the information about the specified file. + ''' + ''' The path to the file. + ''' A FileInfo object containing the information about the specified file. + ''' + ''' The path name is malformed. + ''' For example, it contains invalid characters or is only white space. + ''' The file name has a trailing slash mark. + ''' + ''' + ''' is or an empty string. + ''' + ''' The path contains a colon in the middle of the string. + ''' The path exceeds the system-defined maximum length. + ''' The user lacks necessary permissions to view the path. + ''' The user lacks ACL (access control list) access to the file. Public Function GetFileInfo(file As String) As IO.FileInfo Return FileIO.FileSystem.GetFileInfo(file) End Function + ''' + ''' Return an unordered collection of file paths found directly under a directory. + ''' + ''' The directory to find the files inside. + ''' A containing the matched files' paths. + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The directory to search does not exist + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or + ''' is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user lacks necessary permissions. Public Function GetFiles(directory As String) As ReadOnlyCollection(Of String) Return FileIO.FileSystem.GetFiles(directory) End Function + ''' + ''' Return an unordered collection of file paths found under a directory + ''' with the specified name patterns and containing the specified text. + ''' + ''' The directory to find the files inside. + ''' + ''' to find recursively, + ''' otherwise, . + ''' + ''' The wildcards for the file name, for example "*.bmp", "*.txt" + ''' A ReadOnlyCollection(Of String) containing the matched files' paths. + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The directory to search does not exist + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or + ''' is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user lacks necessary permissions. Public Function GetFiles( directory As String, searchType As SearchOption, @@ -189,30 +852,193 @@ Namespace Microsoft.VisualBasic.MyServices Return FileIO.FileSystem.GetFiles(directory, searchType, wildcards) End Function + ''' + ''' Return the name (and extension) from the given path string. + ''' + ''' The path string from which to obtain the file name (and extension). + ''' A String containing the name of the file or directory. + ''' path contains one or more of the invalid characters + ''' defined in InvalidPathChars. Public Function GetName(path As String) As String Return FileIO.FileSystem.GetName(path) End Function + ''' + ''' Returns the parent directory's path from a specified path. + ''' + ''' The path to a file or directory, this can be absolute or relative. + ''' + ''' The path to the parent directory of that file or directory + ''' (whether absolute or relative depends on the input), or an empty string if Path is a root directory. + ''' + ''' See IO.Path.GetFullPath: If path is an invalid path. + ''' + ''' The path will be normalized (for example: C:\Dir1////\\\Dir2 will become C:\Dir1\Dir2) + ''' but will not be resolved (for example: C:\Dir1\Dir2\..\Dir3 WILL NOT become C:\Dir1\Dir3). Use CombinePath. + ''' + ''' + ''' Path does not have a parent path because it is a root path. + ''' + ''' + ''' is or an empty string. + ''' + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' Public Function GetParentPath(path As String) As String Return FileIO.FileSystem.GetParentPath(path) End Function + ''' + ''' Create a uniquely named zero-byte temporary file on disk and return the full path to that file. + ''' + ''' A String containing the name of the temporary file. Public Function GetTempFileName() As String Return FileIO.FileSystem.GetTempFileName() End Function + ''' + ''' Move an existing directory to a new directory, + ''' throwing exception if there are existing files with the same name. + ''' + ''' The path to the source directory, can be relative or absolute. + ''' + ''' The path to the target directory, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The directory does not exist. + ''' The path exceeds the system-defined maximum length. + ''' The operation is cyclic. + ''' + ''' A file or directory name in the path contains a colon (:) or + ''' is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user lacks necessary permissions. Public Sub MoveDirectory(sourceDirectoryName As String, destinationDirectoryName As String) FileIO.FileSystem.MoveDirectory(sourceDirectoryName, destinationDirectoryName) End Sub + ''' + ''' Move an existing directory to a new directory, overwriting existing files with the same name if specified. + ''' + ''' The path to the source directory, can be relative or absolute. + ''' + ''' The path to the target directory, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' to overwrite existing files with the same name. + ''' Otherwise . + ''' + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The directory does not exist. + ''' The path exceeds the system-defined maximum length. + ''' The operation is cyclic. + ''' + ''' A file or directory name in the path contains a colon (:) or + ''' is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user lacks necessary permissions. Public Sub MoveDirectory(sourceDirectoryName As String, destinationDirectoryName As String, overwrite As Boolean) FileIO.FileSystem.MoveDirectory(sourceDirectoryName, destinationDirectoryName, overwrite) End Sub + ''' + ''' Move an existing directory to a new directory, + ''' displaying progress dialog and confirmation dialogs if specified, + ''' throwing exception if user cancels the operation + ''' (only applies if displaying progress dialog and confirmation dialogs). + ''' + ''' The path to the source directory, can be relative or absolute. + ''' + ''' The path to the target directory, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The directory does not exist. + ''' The path exceeds the system-defined maximum length. + ''' The operation is cyclic. + ''' + ''' A file or directory name in the path contains a colon (:) or + ''' is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user lacks necessary permissions. Public Sub MoveDirectory(sourceDirectoryName As String, destinationDirectoryName As String, showUI As UIOption) FileIO.FileSystem.MoveDirectory(sourceDirectoryName, destinationDirectoryName, showUI) End Sub + ''' + ''' Move an existing directory to a new directory, + ''' displaying progress dialog and confirmation dialogs if specified, + ''' throwing exception if user cancels the operation if specified. + ''' (only applies if displaying progress dialog and confirmation dialogs). + ''' + ''' The path to the source directory, can be relative or absolute. + ''' + ''' The path to the target directory, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' Specifies whether to throw an if the user clicks Cancel.>. + ''' + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The directory does not exist. + ''' The path exceeds the system-defined maximum length. + ''' The operation is cyclic. + ''' + ''' A file or directory name in the path contains a colon (:) or + ''' is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user lacks necessary permissions. + ''' + ''' The user cancelled the operation and is set to . + ''' Public Sub MoveDirectory( sourceDirectoryName As String, destinationDirectoryName As String, @@ -222,18 +1048,129 @@ Namespace Microsoft.VisualBasic.MyServices FileIO.FileSystem.MoveDirectory(sourceDirectoryName, destinationDirectoryName, showUI, onUserCancel) End Sub + ''' + ''' Move an existing file to a new file. Overwriting a file of the same name is not allowed. + ''' + ''' The path to the source file, can be relative or absolute. + ''' + ''' The path to the destination file, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' contains path information. + ''' + ''' + ''' or is Nothing or an empty string. + ''' + ''' The source file is not valid or does not exist. + ''' A file in the target directory with the same name is in use. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have required permission. + ''' The user lacks necessary permissions to view the path. Public Sub MoveFile(sourceFileName As String, destinationFileName As String) FileIO.FileSystem.MoveFile(sourceFileName, destinationFileName) End Sub + ''' + ''' Move an existing file to a new file. Overwriting a file of the same name if specified. + ''' + ''' The path to the source file, can be relative or absolute. + ''' + ''' The path to the destination file, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' + ''' to overwrite existing file with the same name. + ''' Otherwise . + ''' + ''' + ''' contains path information. + ''' + ''' + ''' or is Nothing or an empty string. + ''' + ''' The source file is not valid or does not exist. + ''' A file in the target directory with the same name is in use. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have required permission. + ''' The user lacks necessary permissions to view the path. Public Sub MoveFile(sourceFileName As String, destinationFileName As String, overwrite As Boolean) FileIO.FileSystem.MoveFile(sourceFileName, destinationFileName, overwrite) End Sub + ''' + ''' Move an existing file to a new file, + ''' displaying progress dialog and confirmation dialogs if specified, + ''' will throw exception if user cancels the operation. + ''' + ''' The path to the source file, can be relative or absolute. + ''' + ''' The path to the destination file, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' contains path information. + ''' + ''' + ''' or is Nothing or an empty string. + ''' + ''' The source file is not valid or does not exist. + ''' A file in the target directory with the same name is in use. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have required permission. + ''' The user lacks necessary permissions to view the path. Public Sub MoveFile(sourceFileName As String, destinationFileName As String, showUI As UIOption) FileIO.FileSystem.MoveFile(sourceFileName, destinationFileName, showUI) End Sub + ''' + ''' Move an existing file to a new file, + ''' displaying progress dialog and confirmation dialogs if specified, + ''' will throw exception if user cancels the operation if specified. + ''' + ''' The path to the source file, can be relative or absolute. + ''' + ''' The path to the destination file, can be relative or absolute. + ''' Parent directory will always be created. + ''' + ''' + ''' Specifies whether To visually track the operation's progress. + ''' Default is . + ''' + ''' + ''' Specifies whether to throw an if the user clicks Cancel.>. + ''' + ''' + ''' contains path information. + ''' + ''' + ''' or is Nothing or an empty string. + ''' + ''' The source file is not valid or does not exist. + ''' A file in the target directory with the same name is in use. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The path exceeds the system-defined maximum length. + ''' The user does not have required permission. + ''' The user lacks necessary permissions to view the path. + ''' + ''' The user cancelled the operation and is set to . + ''' Public Sub MoveFile( sourceFileName As String, destinationFileName As String, @@ -243,30 +1180,146 @@ Namespace Microsoft.VisualBasic.MyServices FileIO.FileSystem.MoveFile(sourceFileName, destinationFileName, showUI, onUserCancel) End Sub + ''' + ''' Return an instance of a TextFieldParser for the given file. + ''' + ''' The path to the file to parse. + ''' An instance of a TextFieldParser. + ''' + ''' is Nothing or an empty string. + ''' + ''' The file does not exist. + ''' The file is in use by another process, or an I/O error occurs. + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' + ''' A row cannot be parsed using the specified format. The exception message + ''' specifies the line causing the exception, while the ErrorLine property is assigned + ''' the text contained in the line. + ''' + ''' The user lacks necessary permissions to view the path. Public Function OpenTextFieldParser(file As String) As TextFieldParser Return FileIO.FileSystem.OpenTextFieldParser(file) End Function + ''' + ''' Return an instance of a TextFieldParser for the given file using the given delimiters. + ''' + ''' The path to the file to parse. + ''' A list of delimiters. + ''' An instance of a TextFieldParser + ''' + ''' is Nothing or an empty string. + ''' + ''' The file does not exist. + ''' The file is in use by another process, or an I/O error occurs. + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' + ''' A row cannot be parsed using the specified format. The exception message + ''' specifies the line causing the exception, while the ErrorLine property is assigned + ''' the text contained in the line. + ''' + ''' The user lacks necessary permissions to view the path. Public Function OpenTextFieldParser(file As String, ParamArray delimiters As String()) As TextFieldParser Return FileIO.FileSystem.OpenTextFieldParser(file, delimiters) End Function + ''' + ''' Return an instance of a TextFieldParser for the given file using the given field widths. + ''' + ''' The path to the file to parse. + ''' A list of field widths. + ''' An instance of a TextFieldParser + ''' + ''' is Nothing or an empty string. + ''' + ''' The file does not exist. + ''' The file is in use by another process, or an I/O error occurs. + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' + ''' A row cannot be parsed using the specified format. The exception message + ''' specifies the line causing the exception, while the ErrorLine property is assigned + ''' the text contained in the line. + ''' + ''' The user lacks necessary permissions to view the path. Public Function OpenTextFieldParser(file As String, ParamArray fieldWidths As Integer()) As TextFieldParser Return FileIO.FileSystem.OpenTextFieldParser(file, fieldWidths) End Function + ''' + ''' Return a StreamReader for reading the given file using UTF-8 as preferred encoding. + ''' + ''' The file to open the StreamReader on. + ''' An instance of System.IO.StreamReader opened on the file (with FileShare.Read). + ''' + ''' ends with a backslash (\). + ''' + ''' The file does not exist. + ''' The user lacks necessary permissions to view the path. Public Function OpenTextFileReader(file As String) As IO.StreamReader Return FileIO.FileSystem.OpenTextFileReader(file) End Function + ''' + ''' Return a StreamReader for reading the given file using the given encoding as preferred encoding. + ''' + ''' The file to open the StreamReader on. + ''' + ''' The preferred encoding that will be used if the encoding of the file could not be detected. + ''' + ''' An instance of System.IO.StreamReader opened on the file (with FileShare.Read). + ''' + ''' ends with a backslash (\). + ''' + ''' The file does not exist. + ''' The user lacks necessary permissions to view the path. Public Function OpenTextFileReader(file As String, encoding As Encoding) As IO.StreamReader Return FileIO.FileSystem.OpenTextFileReader(file, encoding) End Function + ''' + ''' Return a StreamWriter for writing to the given file using UTF-8 encoding. + ''' + ''' The file to write to. + ''' + ''' to append to the content of the file. + ''' to overwrite the content of the file. + ''' + ''' An instance of StreamWriter opened on the file (with FileShare.Read). + ''' + ''' ends with a trailing slash. + ''' + ''' + ''' is Nothing or an empty string. + ''' Public Function OpenTextFileWriter(file As String, append As Boolean) As IO.StreamWriter Return FileIO.FileSystem.OpenTextFileWriter(file, append) End Function + ''' + ''' Return a StreamWriter for writing to the given file using the given encoding. + ''' + ''' The file to write to. + ''' + ''' to append to the content of the file. + ''' to overwrite the content of the file. + ''' + ''' The encoding to use to write to the file. + ''' An instance of StreamWriter opened on the file (with FileShare.Read). + ''' + ''' ends with a trailing slash. + ''' + ''' + ''' is Nothing or an empty string. + ''' Public Function OpenTextFileWriter( file As String, append As Boolean, @@ -275,34 +1328,192 @@ Namespace Microsoft.VisualBasic.MyServices Return FileIO.FileSystem.OpenTextFileWriter(file, append, encoding) End Function + ''' + ''' Read the whole content of a file into a byte array. + ''' + ''' The path to the file. + ''' A byte array contains the content of the file. + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The file does not exist. + ''' The file is in use by another process, or an I/O error occurs. + ''' The path exceeds the system-defined maximum length. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' There is not enough memory to write the string to buffer. + ''' The user lacks necessary permissions to view the path. Public Function ReadAllBytes(file As String) As Byte() Return FileIO.FileSystem.ReadAllBytes(file) End Function + ''' + ''' Read the whole content of a text file into a string using UTF-8 encoding. + ''' + ''' The path to the text file. + ''' A String contains the content of the given file. + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The file does not exist. + ''' The file is in use by another process, or an I/O error occurs. + ''' The path exceeds the system-defined maximum length. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' There is not enough memory to write the string to buffer. + ''' The user lacks necessary permissions to view the path. Public Function ReadAllText(file As String) As String Return FileIO.FileSystem.ReadAllText(file) End Function + ''' + ''' Read the whole content of a text file into a string using the given encoding. + ''' + ''' The path to the text file. + ''' The character encoding to use if the encoding was not detected. + ''' A String contains the content of the given file. + ''' + ''' The path is not valid for one of the following reasons: it is a zero-length string; + ''' it contains only white space; it contains invalid characters; + ''' or it is a device path (starts with \.\). + ''' + ''' + ''' is or an empty string. + ''' + ''' The file does not exist. + ''' The file is in use by another process, or an I/O error occurs. + ''' The path exceeds the system-defined maximum length. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' There is not enough memory to write the string to buffer. + ''' The user lacks necessary permissions to view the path. Public Function ReadAllText(file As String, encoding As Encoding) As String Return FileIO.FileSystem.ReadAllText(file, encoding) End Function + ''' + ''' Rename a directory, does not act like a move. + ''' + ''' The path of the directory to be renamed. + ''' The new name to change to. This must not contain path information. + ''' + ''' contains path information. + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The directory does not exist. + ''' + ''' There is an existing file or directory with the name specified in . + ''' + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user does not have required permission. Public Sub RenameDirectory(directory As String, newName As String) FileIO.FileSystem.RenameDirectory(directory, newName) End Sub + ''' + ''' Renames a file, does not change the file location. + ''' + ''' The path to the file. + ''' The new name to change to. This must not contain path information. + ''' + ''' contains path information or ends with a backslash (\). + ''' + ''' + ''' or + ''' is or an empty string. + ''' + ''' The directory does not exist. + ''' + ''' There is an existing file or directory with the name specified in . + ''' + ''' The path exceeds the system-defined maximum length. + ''' + ''' A file or directory name in the path contains a colon (:) or is in an invalid format. + ''' + ''' The user lacks necessary permissions to view the path. + ''' The user does not have required permission. Public Sub RenameFile(file As String, newName As String) FileIO.FileSystem.RenameFile(file, newName) End Sub + ''' + ''' Overwrites or appends the specified byte array to the specified file, + ''' creating the file if it does not exist. + ''' + ''' The path to the file. + ''' The byte array to write to the file. + ''' + ''' to append the text to the existing content. + ''' to overwrite the existing content. + ''' + ''' + ''' is or an empty string. + ''' + ''' The file does not exist. + ''' The file is in use by another process, or an I/O error occurs. + ''' The path exceeds the system-defined maximum length. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' There is not enough memory to write the string to buffer. + ''' The user lacks necessary permissions to view the path. Public Sub WriteAllBytes(file As String, data() As Byte, append As Boolean) FileIO.FileSystem.WriteAllBytes(file, data, append) End Sub + ''' + ''' Overwrites or appends the given text using UTF-8 encoding to the given file, + ''' creating the file if it does not exist. + ''' + ''' The path to the file. + ''' The text to write to the file. + ''' + ''' to append the text to the existing content. + ''' to overwrite the existing content. + ''' + ''' is or an empty string. + ''' + ''' The file does not exist. + ''' The file is in use by another process, or an I/O error occurs. + ''' The path exceeds the system-defined maximum length. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' There is not enough memory to write the string to buffer. + ''' The user lacks necessary permissions to view the path. Public Sub WriteAllText(file As String, text As String, append As Boolean) FileIO.FileSystem.WriteAllText(file, text, append) End Sub + ''' + ''' Overwrites or appends the given text using the given encoding to the given file, + ''' creating the file if it does not exist. + ''' + ''' The path to the file. + ''' The text to write to the file. + ''' + ''' to append the text to the existing content. + ''' to overwrite the existing content. + ''' The encoding to use. + ''' + ''' is or an empty string. + ''' + ''' The file does not exist. + ''' The file is in use by another process, or an I/O error occurs. + ''' The path exceeds the system-defined maximum length. + ''' A folder name in the path contains a colon (:) or is in an invalid format. + ''' There is not enough memory to write the string to buffer. + ''' The user lacks necessary permissions to view the path. Public Sub WriteAllText( file As String, text As String, diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb index 781103586d4..c6e66fa7471 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb @@ -2,12 +2,15 @@ ' The .NET Foundation licenses this file to you under the MIT license. Imports System.ComponentModel +Imports System.IO Imports Microsoft.VisualBasic.FileIO Namespace Microsoft.VisualBasic.MyServices ''' - ''' An extremely thin wrapper around Microsoft.VisualBasic.FileIO.SpecialDirectories to expose the type through My. + ''' This class contains properties that will return the Special Directories + ''' specific to the current user (My Documents, My Music ...) and those specific + ''' to the current Application that a developer expects to be able to find quickly. ''' Public Class SpecialDirectoriesProxy @@ -18,54 +21,156 @@ Namespace Microsoft.VisualBasic.MyServices Friend Sub New() End Sub + ''' + ''' Returns the directory that serves as a common repository for data files + ''' from your application used by all users. + ''' + ''' + ''' + ''' The path is empty, usually because the operating system does not support the directory. + ''' + ''' + ''' If a path does not exist, one is created. + ''' For additional details + ''' . + ''' Public ReadOnly Property AllUsersApplicationData() As String Get Return SpecialDirectories.AllUsersApplicationData End Get End Property + ''' + ''' The path to the Application Data directory for the current user. + ''' + ''' + ''' + ''' If a path does not exist, one is created. + ''' For additional details + ''' . + ''' + ''' + ''' The path is empty, usually because the operating system does not support the directory. + ''' Public ReadOnly Property CurrentUserApplicationData() As String Get Return SpecialDirectories.CurrentUserApplicationData End Get End Property + ''' + ''' The path to the Desktop directory. + ''' + ''' + ''' + ''' If a path does not exist, one is created. + ''' For additional details + ''' . + ''' + ''' + ''' The path is empty, usually because the operating system does not support the directory. + ''' Public ReadOnly Property Desktop() As String Get Return SpecialDirectories.Desktop End Get End Property + ''' + ''' The path to the My Documents directory + ''' + ''' + ''' + ''' If a path does not exist, one is created. + ''' For additional details + ''' . + ''' + ''' + ''' The path is empty, usually because the operating system does not support the directory. + ''' Public ReadOnly Property MyDocuments() As String Get Return SpecialDirectories.MyDocuments End Get End Property + ''' + ''' The path to the My Music directory. + ''' + ''' + ''' + ''' If a path does not exist, one is created. + ''' For additional details + ''' . + ''' + ''' + ''' The path is empty, usually because the operating system does not support the directory. + ''' Public ReadOnly Property MyMusic() As String Get Return SpecialDirectories.MyMusic End Get End Property + ''' + ''' The path to the My Pictures directory. + ''' + ''' + ''' + ''' If a path does not exist, one is created. + ''' For additional details + ''' . + ''' + ''' + ''' The path is empty, usually because the operating system does not support the directory. + ''' Public ReadOnly Property MyPictures() As String Get Return SpecialDirectories.MyPictures End Get End Property + ''' + ''' The path to the ProgramFiles directory. + ''' + ''' + ''' + ''' If a path does not exist, one is created. + ''' For additional details + ''' . + ''' + ''' + ''' The path is empty, usually because the operating system does not support the directory. + ''' Public ReadOnly Property ProgramFiles() As String Get Return SpecialDirectories.ProgramFiles End Get End Property + ''' + ''' The path to the Programs directory. + ''' + ''' + ''' + ''' If a path does not exist, one is created. + ''' For additional details + ''' . + ''' + ''' + ''' The path is empty, usually because the operating system does not support the directory. + ''' Public ReadOnly Property Programs() As String Get Return SpecialDirectories.Programs End Get End Property + ''' + ''' The path to the Temp directory. + ''' + ''' + ''' This property will always return a valid value. Public ReadOnly Property Temp() As String Get Return SpecialDirectories.Temp From b4f93e31a27fa4c6d43e9aab5dabd5162b28c602 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:41:10 +0000 Subject: [PATCH 05/15] [main] Update dependencies from dotnet/runtime (#12266) [main] Update dependencies from dotnet/runtime --- eng/Version.Details.xml | 180 ++++++++++++++++++++-------------------- eng/Versions.props | 58 ++++++------- global.json | 2 +- 3 files changed, 120 insertions(+), 120 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index c4126b67c26..0daaee8411b 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,186 +7,186 @@ Note: if the Uri is a new place, you will need to add a subscription from that p --> - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d - + https://github.com/dotnet/runtime - e6d9f74bb6383daf71ed70a5a6ec4b07d58f9d9b + 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d diff --git a/eng/Versions.props b/eng/Versions.props index 5d61937d7e2..8d7d829ffcd 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -13,37 +13,37 @@ - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 5.0.0-preview.7.20320.5 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 6.0.0 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 - 10.0.0-alpha.1.24501.8 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.1 diff --git a/global.json b/global.json index 44994b52eb5..c9d57d3de47 100644 --- a/global.json +++ b/global.json @@ -18,7 +18,7 @@ "Microsoft.DotNet.CMake.Sdk": "10.0.0-beta.24501.6", "Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.24501.6", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", - "Microsoft.NET.Sdk.IL": "10.0.0-alpha.1.24501.8" + "Microsoft.NET.Sdk.IL": "10.0.0-alpha.1.24503.1" }, "native-tools": { "cmake": "latest" From 756e030350946a55f603a9e944535a1808afbd4b Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Thu, 3 Oct 2024 13:41:50 -0700 Subject: [PATCH 06/15] Fix IDE0002 in LogTests.cs (#12265) Fix IDE0002 in LogTests.cs --- .../UnitTests/Microsoft/VisualBasic/Logging/LogTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/LogTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/LogTests.cs index ff84c2d5177..d7be57e497b 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/LogTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/LogTests.cs @@ -22,11 +22,11 @@ public void Write() listener.CustomLocation = GetTestFilePath(); log.WriteEntry("WriteEntry"); - log.WriteEntry("WriteEntry", severity: System.Diagnostics.TraceEventType.Warning); - log.WriteEntry("WriteEntry", severity: System.Diagnostics.TraceEventType.Error, id: 3); + log.WriteEntry("WriteEntry", severity: TraceEventType.Warning); + log.WriteEntry("WriteEntry", severity: TraceEventType.Error, id: 3); log.WriteException(new ArgumentException()); - log.WriteException(new ArgumentException(), severity: System.Diagnostics.TraceEventType.Warning, additionalInfo: "AdditionalInfo"); - log.WriteException(new ArgumentException(), severity: System.Diagnostics.TraceEventType.Warning, additionalInfo: "AdditionalInfo", id: 6); + log.WriteException(new ArgumentException(), severity: TraceEventType.Warning, additionalInfo: "AdditionalInfo"); + log.WriteException(new ArgumentException(), severity: TraceEventType.Warning, additionalInfo: "AdditionalInfo", id: 6); } } From 026754639f4211c39354d429643dddef3a9a860f Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:36:49 +0000 Subject: [PATCH 07/15] [main] Update dependencies from dotnet/arcade (#12271) [main] Update dependencies from dotnet/arcade --- eng/Version.Details.xml | 24 +++++++++++------------ eng/Versions.props | 6 +++--- eng/common/internal/Tools.csproj | 10 +++++----- eng/common/templates-official/job/job.yml | 1 + eng/common/templates/job/job.yml | 1 + global.json | 6 +++--- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 0daaee8411b..add46570930 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -191,29 +191,29 @@ Note: if the Uri is a new place, you will need to add a subscription from that p - + https://github.com/dotnet/arcade - 121ea593b1d0860ae0e5f5747850a60b23cc2968 + 36084e26cde6e5902e0d7ada5b097efd79835682 - + https://github.com/dotnet/arcade - 121ea593b1d0860ae0e5f5747850a60b23cc2968 + 36084e26cde6e5902e0d7ada5b097efd79835682 - + https://github.com/dotnet/arcade - 121ea593b1d0860ae0e5f5747850a60b23cc2968 + 36084e26cde6e5902e0d7ada5b097efd79835682 - + https://github.com/dotnet/arcade - 121ea593b1d0860ae0e5f5747850a60b23cc2968 + 36084e26cde6e5902e0d7ada5b097efd79835682 - + https://github.com/dotnet/arcade - 121ea593b1d0860ae0e5f5747850a60b23cc2968 + 36084e26cde6e5902e0d7ada5b097efd79835682 - + https://github.com/dotnet/arcade - 121ea593b1d0860ae0e5f5747850a60b23cc2968 + 36084e26cde6e5902e0d7ada5b097efd79835682 diff --git a/eng/Versions.props b/eng/Versions.props index 8d7d829ffcd..7415aafb073 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -56,9 +56,9 @@ - 10.0.0-beta.24501.6 - 10.0.0-beta.24501.6 - 10.0.0-beta.24501.6 + 10.0.0-beta.24503.1 + 10.0.0-beta.24503.1 + 10.0.0-beta.24503.1 17.4.0-preview-20220707-01 diff --git a/eng/common/internal/Tools.csproj b/eng/common/internal/Tools.csproj index 6ac414a1747..32f79dfb340 100644 --- a/eng/common/internal/Tools.csproj +++ b/eng/common/internal/Tools.csproj @@ -9,11 +9,11 @@ - - - - - + + + + + diff --git a/eng/common/templates-official/job/job.yml b/eng/common/templates-official/job/job.yml index 3d16b41c78c..605692d2fb7 100644 --- a/eng/common/templates-official/job/job.yml +++ b/eng/common/templates-official/job/job.yml @@ -1,6 +1,7 @@ parameters: # Sbom related params enableSbom: true + runAsPublic: false PackageVersion: 9.0.0 BuildDropPath: '$(Build.SourcesDirectory)/artifacts' diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml index 07d317bf8f9..d1aeb92fcea 100644 --- a/eng/common/templates/job/job.yml +++ b/eng/common/templates/job/job.yml @@ -4,6 +4,7 @@ parameters: componentGovernanceIgnoreDirectories: '' # Sbom related params enableSbom: true + runAsPublic: false PackageVersion: 9.0.0 BuildDropPath: '$(Build.SourcesDirectory)/artifacts' diff --git a/global.json b/global.json index c9d57d3de47..6bd6d42d380 100644 --- a/global.json +++ b/global.json @@ -14,9 +14,9 @@ "version": "9.0.100-rc.2.24474.12" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.24501.6", - "Microsoft.DotNet.CMake.Sdk": "10.0.0-beta.24501.6", - "Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.24501.6", + "Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.24503.1", + "Microsoft.DotNet.CMake.Sdk": "10.0.0-beta.24503.1", + "Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.24503.1", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", "Microsoft.NET.Sdk.IL": "10.0.0-alpha.1.24503.1" }, From d049e5c5fc3a9a39b9df1823b1c4ab976d659e99 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:37:18 +0000 Subject: [PATCH 08/15] [main] Update dependencies from dotnet/runtime (#12272) [main] Update dependencies from dotnet/runtime --- eng/Version.Details.xml | 180 ++++++++++++++++++++-------------------- eng/Versions.props | 58 ++++++------- global.json | 2 +- 3 files changed, 120 insertions(+), 120 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index add46570930..cfad28ab655 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,186 +7,186 @@ Note: if the Uri is a new place, you will need to add a subscription from that p --> - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 - + https://github.com/dotnet/runtime - 2358c592c2efb5b9e5fe48d3332f105c1b2fff0d + f05bfc40ce500b108f5eccb1f2e76b57e6d43bf6 diff --git a/eng/Versions.props b/eng/Versions.props index 7415aafb073..2812d6f3990 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -13,37 +13,37 @@ - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 5.0.0-preview.7.20320.5 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 6.0.0 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 - 10.0.0-alpha.1.24503.1 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 + 10.0.0-alpha.1.24503.11 diff --git a/global.json b/global.json index 6bd6d42d380..7048f755115 100644 --- a/global.json +++ b/global.json @@ -18,7 +18,7 @@ "Microsoft.DotNet.CMake.Sdk": "10.0.0-beta.24503.1", "Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.24503.1", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", - "Microsoft.NET.Sdk.IL": "10.0.0-alpha.1.24503.1" + "Microsoft.NET.Sdk.IL": "10.0.0-alpha.1.24503.11" }, "native-tools": { "cmake": "latest" From d90caed4afa345727436f4a2c46aabf6f7cf3e92 Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Fri, 4 Oct 2024 09:25:22 -0700 Subject: [PATCH 09/15] Improve code coverage for FileLogTraceListener from simplifying PR #11863 (#12264) * Improve code coverage for FileLogTraceListener * Update src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/FileLogTraceListenerTests.cs Thanks I had no idea about boolData Co-authored-by: Loni Tra --------- Co-authored-by: Loni Tra --- .../VisualBasic/Logging/FileLogTraceListenerTests.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/FileLogTraceListenerTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/FileLogTraceListenerTests.cs index c303f3f14df..985df01bd63 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/FileLogTraceListenerTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/FileLogTraceListenerTests.cs @@ -24,14 +24,16 @@ public void Properties() _ = listener.CustomLocation; } - [Fact] - public void Write() + [Theory] + [BoolData] + public void Write(bool includeHostName) { TraceEventCache cache = new(); using FileLogTraceListener listener = new() { Location = LogFileLocation.Custom, - CustomLocation = GetTestFilePath() + CustomLocation = GetTestFilePath(), + IncludeHostName = includeHostName }; listener.Write("Write"); From a62995829e7081885272e2a823ee175f09025d71 Mon Sep 17 00:00:00 2001 From: Rich Lander Date: Fri, 4 Oct 2024 09:28:17 -0700 Subject: [PATCH 10/15] Switch default feed to use wildcards only (#12268) * Switch default feed to full wildcard * Add other wildcards back --- NuGet.config | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/NuGet.config b/NuGet.config index 6552c403980..3895ea7719d 100644 --- a/NuGet.config +++ b/NuGet.config @@ -40,44 +40,15 @@ + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + From 03cb5dd6ae58ee4abbda44402cef2f6913fbdcd5 Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Fri, 4 Oct 2024 14:45:52 -0900 Subject: [PATCH 11/15] Move local closer to usage --- .../ApplicationServices/SingleInstanceHelpers.vb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb index 7e017d14482..2ada30d079b 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb @@ -13,13 +13,14 @@ Namespace Microsoft.VisualBasic.ApplicationServices Private Const NamedPipeOptions As PipeOptions = PipeOptions.Asynchronous Or PipeOptions.CurrentUserOnly Private Async Function ReadArgsAsync( - pipeServer As NamedPipeServerStream, - cancellationToken As CancellationToken) As Task(Of String()) + pipeServer As NamedPipeServerStream, + cancellationToken As CancellationToken) As Task(Of String()) Const bufferLength As Integer = 1024 - Dim buffer As Byte() = New Byte(bufferLength - 1) {} + Using stream As New MemoryStream While True + Dim buffer As Byte() = New Byte(bufferLength - 1) {} Dim bytesRead As Integer = Await pipeServer.ReadAsync( buffer:=buffer.AsMemory(start:=0, length:=bufferLength), cancellationToken) _ From 0119ea3c55ebd9315ba581670895d7b6a1c8f35f Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Mon, 7 Oct 2024 14:53:52 -0900 Subject: [PATCH 12/15] PR Feedback --- .../VisualBasic/ApplicationServices/SingleInstanceHelpers.vb | 4 ++-- .../System/Windows/Forms/SingleInstanceHelpersTests.vb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb index 2ada30d079b..80198167496 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb @@ -24,14 +24,14 @@ Namespace Microsoft.VisualBasic.ApplicationServices Dim bytesRead As Integer = Await pipeServer.ReadAsync( buffer:=buffer.AsMemory(start:=0, length:=bufferLength), cancellationToken) _ - .ConfigureAwait(continueOnCapturedContext:=False) + .ConfigureAwait(continueOnCapturedContext:=False) If bytesRead = 0 Then Exit While End If Await stream.WriteAsync( buffer:=buffer.AsMemory(start:=0, length:=bytesRead), cancellationToken) _ - .ConfigureAwait(continueOnCapturedContext:=False) + .ConfigureAwait(continueOnCapturedContext:=False) End While stream.Seek(0, SeekOrigin.Begin) Dim serializer As New DataContractSerializer(GetType(String())) diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb index 14f1cd7b4bf..e95ab746fc1 100644 --- a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb @@ -38,9 +38,9 @@ Namespace Microsoft.VisualBasic.Forms.Tests Dim pipeName As String = GetUniqueText() Dim pipeServer As NamedPipeServerStream = Nothing TryCreatePipeServer(pipeName, pipeServer).Should.BeTrue() - Dim pipeServer1 As NamedPipeServerStream = Nothing - TryCreatePipeServer(pipeName, pipeServer1).Should.BeFalse() Using pipeServer + Dim pipeServer1 As NamedPipeServerStream = Nothing + TryCreatePipeServer(pipeName, pipeServer1).Should.BeFalse() pipeServer1.Should.BeNull() End Using End Sub From a82f4023ead1573a69bd42b141a4a8a4dbd07a6a Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Tue, 8 Oct 2024 16:21:08 -1000 Subject: [PATCH 13/15] Address PR Feedback --- .../Windows/Forms/SingleInstanceHelpersTests.vb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb index e95ab746fc1..d9b7ee0a90a 100644 --- a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb @@ -14,12 +14,6 @@ Namespace Microsoft.VisualBasic.Forms.Tests Public Class SingleInstanceHelpersTests Private _resultArgs As String() - Private Sub OnStartupNextInstanceMarshallingAdaptor(args As String()) - If args.Length = 1 Then - _resultArgs = {"Hello"} - End If - End Sub - Public Sub TryCreatePipeServerTests() Dim pipeName As String = GetUniqueText() @@ -45,6 +39,12 @@ Namespace Microsoft.VisualBasic.Forms.Tests End Using End Sub + Private Sub OnStartupNextInstanceMarshallingAdaptor(args As String()) + If args.Length = 1 Then + _resultArgs = {"Hello"} + End If + End Sub + Public Async Function WaitForClientConnectionsAsyncTests() As Task Dim pipeName As String = GetUniqueText() From a278a8b9d3ff7cda40aa0adf2e602ae69e9ab610 Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Tue, 8 Oct 2024 18:58:05 -1000 Subject: [PATCH 14/15] PR Feedback --- .../VisualBasic/ApplicationServices/SingleInstanceHelpers.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb index 80198167496..4801df5276b 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb @@ -56,7 +56,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices End Using Await pipeClient.WriteAsync( buffer:=content.AsMemory(start:=0, length:=content.Length), cancellationToken) _ - .ConfigureAwait(continueOnCapturedContext:=False) + .ConfigureAwait(continueOnCapturedContext:=False) End Function Friend Async Function SendSecondInstanceArgsAsync( From ef78e8ca3b726cc4a54e326b1479cfcb25986d19 Mon Sep 17 00:00:00 2001 From: Paul M Cohen Date: Wed, 9 Oct 2024 17:00:37 -1000 Subject: [PATCH 15/15] PR Feedback inline private Sub, reuse commandLine --- .../Windows/Forms/SingleInstanceHelpersTests.vb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb index d9b7ee0a90a..ede0967cedb 100644 --- a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb @@ -39,31 +39,30 @@ Namespace Microsoft.VisualBasic.Forms.Tests End Using End Sub - Private Sub OnStartupNextInstanceMarshallingAdaptor(args As String()) - If args.Length = 1 Then - _resultArgs = {"Hello"} - End If - End Sub - Public Async Function WaitForClientConnectionsAsyncTests() As Task Dim pipeName As String = GetUniqueText() Dim pipeServer As NamedPipeServerStream = Nothing + If TryCreatePipeServer(pipeName, pipeServer) Then Using pipeServer Dim tokenSource As New CancellationTokenSource() + Dim commandLine As String() = {"Hello"} Dim clientConnection As Task = WaitForClientConnectionsAsync( pipeServer, - callback:=AddressOf OnStartupNextInstanceMarshallingAdaptor, + callback:=Sub(args As String()) + If args.Length = 1 Then + _resultArgs = commandLine + End If + End Sub, cancellationToken:=tokenSource.Token) - Dim commandLine As String() = {"Hello"} Dim awaitable As ConfiguredTaskAwaitable = SendSecondInstanceArgsAsync( pipeName, args:=commandLine, cancellationToken:=tokenSource.Token) _ - .ConfigureAwait(continueOnCapturedContext:=False) + .ConfigureAwait(continueOnCapturedContext:=False) awaitable.GetAwaiter().GetResult() Dim CancelToken As New CancellationToken