From e241b89d7a1fdadc469dfbafac98e9bb9380f233 Mon Sep 17 00:00:00 2001 From: Jeremy Kuhne Date: Thu, 6 Mar 2025 13:00:03 -0800 Subject: [PATCH] Use Path.Join instead of Path.Combine It is faster, and more predictable. Most changes are in test code. Tweak behavior in AssemblyNamesTypeResolutionService to use API based program files and add separator for proper contains checking. No need to use both paths, it will always be current process specific. --- .../TestUtilities/FileCleanupTestBase.cs | 4 +- src/Common/tests/TestUtilities/TempFile.cs | 2 +- .../Logging/FileLogTraceListener.vb | 2 +- .../Forms/FileLogTraceListenerTests.vb | 2 +- .../Forms/VbFileCleanupTestBaseTests.vb | 2 +- .../TestUtilities/VbFileCleanupTestBase.vb | 12 +-- .../InteractionTests.cs | 2 +- .../VisualBasic/Devices/AudioTests.cs | 2 +- .../MyServices/FileSystemProxyTests.cs | 92 +++++++++---------- src/System.Drawing.Common/tests/Helpers.cs | 2 +- .../System/Drawing/IconConverterTests.cs | 4 +- .../Drawing/ImageAnimator.ManualTests.cs | 6 +- .../System/Drawing/ImageConverterTests.cs | 4 +- .../Drawing/Imaging/ImageFormatTests.cs | 8 +- .../Text/PrivateFontCollectionTests.cs | 2 +- .../tests/UnitTests/CurrentReferences.cs | 18 ++-- .../tests/UnitTests/TestFileLoader.cs | 8 +- .../PlatformDetection.Windows.cs | 2 +- .../AssemblyNamesTypeResolutionService.cs | 19 ++-- .../System/Resources/ResXDataNode.cs | 2 +- .../Forms/Controls/WebBrowser/WebBrowser.cs | 2 +- .../TestHelpers.cs | 8 +- .../UIIntegrationTests/DragDropTests.cs | 14 +-- .../Infra/DataCollectionService.cs | 8 +- .../WinformsControlsTest/DragDrop.cs | 6 +- .../Windows/Forms/CursorConverterTests.cs | 6 +- .../System/Windows/Forms/CursorTests.cs | 30 +++--- .../Windows/Forms/InputLanguageTests.cs | 4 +- .../System/Windows/Forms/RichTextBoxTests.cs | 2 +- .../Forms/ToolStripControlHostTests.cs | 12 +-- .../Windows/Forms/ToolStripItemTests.cs | 40 ++++---- .../Windows/Forms/ToolStripSeparatorTests.cs | 12 +-- .../TestPassApp/CommonControl2.cs | 2 +- 33 files changed, 167 insertions(+), 174 deletions(-) diff --git a/src/Common/tests/TestUtilities/FileCleanupTestBase.cs b/src/Common/tests/TestUtilities/FileCleanupTestBase.cs index c54cc8a011e..fda9b76dca1 100644 --- a/src/Common/tests/TestUtilities/FileCleanupTestBase.cs +++ b/src/Common/tests/TestUtilities/FileCleanupTestBase.cs @@ -16,7 +16,7 @@ public string TestDirectory { if (_testDirectory is null) { - _testDirectory = Path.Combine(Path.GetTempPath(), GetUniqueName()); + _testDirectory = Path.Join(Path.GetTempPath(), GetUniqueName()); Directory.CreateDirectory(_testDirectory); } @@ -43,7 +43,7 @@ protected virtual void Dispose(bool disposing) } } - public string GetTestFilePath() => Path.Combine(TestDirectory, GetTestFileName()); + public string GetTestFilePath() => Path.Join(TestDirectory, GetTestFileName()); public static string GetTestFileName() => GetUniqueName(); diff --git a/src/Common/tests/TestUtilities/TempFile.cs b/src/Common/tests/TestUtilities/TempFile.cs index d8bff758fbe..99785c911b0 100644 --- a/src/Common/tests/TestUtilities/TempFile.cs +++ b/src/Common/tests/TestUtilities/TempFile.cs @@ -81,6 +81,6 @@ private void DeleteFile() private static string GetFilePath(string? memberName, int lineNumber) { string file = $"{IO.Path.GetRandomFileName()}_{memberName}_{lineNumber}"; - return IO.Path.Combine(IO.Path.GetTempPath(), file); + return IO.Path.Join(IO.Path.GetTempPath(), file); } } diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/FileLogTraceListener.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/FileLogTraceListener.vb index fe06c7aa46a..a5496d632c3 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/FileLogTraceListener.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/FileLogTraceListener.vb @@ -166,7 +166,7 @@ Namespace Microsoft.VisualBasic.Logging Debug.Fail("Unrecognized LogFileCreationSchedule") End Select - Return Path.Combine(basePath, fileName) + Return Path.Join(basePath, fileName) End Get End Property diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/FileLogTraceListenerTests.vb b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/FileLogTraceListenerTests.vb index c1e12773b9d..07401583f68 100644 --- a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/FileLogTraceListenerTests.vb +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/FileLogTraceListenerTests.vb @@ -45,7 +45,7 @@ Namespace Microsoft.VisualBasic.Forms.Tests listener.DiskSpaceExhaustedBehavior = DiskSpaceExhaustedOption.ThrowException listener.DiskSpaceExhaustedBehavior.Should.Be(DiskSpaceExhaustedOption.ThrowException) - listener.FullLogFileName.Should.BeEquivalentTo(Path.Combine(testDirectory, $"{expectedBaseFileName}.log")) + listener.FullLogFileName.Should.BeEquivalentTo(Path.Join(testDirectory, $"{expectedBaseFileName}.log")) listener.LogFileCreationSchedule.Should.Be(LogFileCreationScheduleOption.None) listener.LogFileCreationSchedule = LogFileCreationScheduleOption.Daily diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/VbFileCleanupTestBaseTests.vb b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/VbFileCleanupTestBaseTests.vb index c5b4f5c0e26..9b3953e2878 100644 --- a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/VbFileCleanupTestBaseTests.vb +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/VbFileCleanupTestBaseTests.vb @@ -32,7 +32,7 @@ Namespace Microsoft.VisualBasic.Forms.Tests Public Sub DirectoryIsAccessibleWithNonexistentPath() - Dim directoryPath As String = Path.Combine(CreateTempDirectory(), GetUniqueFileName) + Dim directoryPath As String = Path.Join(CreateTempDirectory(), GetUniqueFileName) DirectoryIsAccessible(directoryPath).Should.BeFalse() End Sub diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/TestUtilities/VbFileCleanupTestBase.vb b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/TestUtilities/VbFileCleanupTestBase.vb index 18bc3f06182..e086373d263 100644 --- a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/TestUtilities/VbFileCleanupTestBase.vb +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/TestUtilities/VbFileCleanupTestBase.vb @@ -9,7 +9,7 @@ Namespace Microsoft.VisualBasic.Forms.Tests Public MustInherit Class VbFileCleanupTestBase Implements IDisposable - Private Shared ReadOnly s_baseTempPath As String = Path.Combine(Path.GetTempPath, "DownLoadTest9d9e3a8-7a46-4333-a0eb-4faf76994801") + Private Shared ReadOnly s_baseTempPath As String = Path.Join(Path.GetTempPath, "DownLoadTest9d9e3a8-7a46-4333-a0eb-4faf76994801") Friend Const DefaultFileName As String = "Testing.Txt" Friend ReadOnly _testDirectories As New HashSet(Of String) @@ -46,7 +46,7 @@ Namespace Microsoft.VisualBasic.Forms.Tests ''' If size = -1 no file is create but the full path is returned. ''' Friend Shared Function CreateTempFile(sourceDirectoryName As String, Optional filename As String = DefaultFileName, Optional size As Integer = -1) As String - Dim filenameWithPath As String = Path.Combine(sourceDirectoryName, filename) + Dim filenameWithPath As String = Path.Join(sourceDirectoryName, filename) If size >= 0 Then Using destinationStream As FileStream = File.Create(filenameWithPath) @@ -68,7 +68,7 @@ Namespace Microsoft.VisualBasic.Forms.Tests If Not info.Exists Then Return False End If - Dim path As String = IO.Path.Combine(directoryPath, GetUniqueFileName()) + Dim path As String = IO.Path.Join(directoryPath, GetUniqueFileName()) Using stream As FileStream = File.Create(path) stream.Close() End Using @@ -82,7 +82,7 @@ Namespace Microsoft.VisualBasic.Forms.Tests End Function Friend Shared Function GetUniqueFileNameWithPath(testDirectory As String) As String - Return Path.Combine(testDirectory, GetUniqueFileName()) + Return Path.Join(testDirectory, GetUniqueFileName()) End Function ''' @@ -96,9 +96,9 @@ Namespace Microsoft.VisualBasic.Forms.Tests Friend Function CreateTempDirectory( Optional memberName As String = Nothing, Optional lineNumber As Integer = -1) As String Dim folder As String If lineNumber > 0 Then - folder = Path.Combine(BaseTempPath, $"{memberName}{lineNumber}") + folder = Path.Join(BaseTempPath, $"{memberName}{lineNumber}") Else - folder = Path.Combine(BaseTempPath, memberName) + folder = Path.Join(BaseTempPath, memberName) End If If _testDirectories.Add(folder) Then diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs index b4b5d5fea23..992c6710e6f 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs @@ -104,7 +104,7 @@ public void Shell_ArgumentNullException() [Fact] public void Shell_FileNotFoundException() { - string path = Path.Combine(Path.GetTempPath(), GetUniqueName()); + string path = Path.Join(Path.GetTempPath(), GetUniqueName()); // Exception.ToString() called to verify message is constructed successfully. _ = Assert.Throws(() => Interaction.Shell(path)).ToString(); } diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/AudioTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/AudioTests.cs index 54a91b1a59c..8152e479d0e 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/AudioTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/AudioTests.cs @@ -49,7 +49,7 @@ public void PlayEmptyFileNameAudioMode_Throws(string fileName) [InvalidEnumData] public void PlayModeInvalid_Throws(AudioPlayMode audioPlayMode) { - string location = Path.Combine(Path.GetTempPath(), GetUniqueName()); + string location = Path.Join(Path.GetTempPath(), GetUniqueName()); Audio audio = new(); Action testCode = () => audio.Play(location, audioPlayMode); testCode.Should().Throw(); diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs index ebe31d76f87..6ebfc1bd4f4 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs @@ -37,7 +37,7 @@ public void CombinePathTest_BaseDirectory_RelativePath() { var TestDirInfo = new DirectoryInfo(TestDirectory); string Root = TestDirInfo.Root.Name; - Assert.Equal(_fileSystem.CombinePath(Root, "Test2"), Path.Combine(Root, "Test2")); + Assert.Equal(_fileSystem.CombinePath(Root, "Test2"), Path.Join(Root, "Test2")); } [Fact] @@ -45,20 +45,20 @@ public void CombinePathTest_RootDirectory_RelativePath() { Assert.Equal(_fileSystem.CombinePath(TestDirectory, null), TestDirectory); Assert.Equal(_fileSystem.CombinePath(TestDirectory, ""), TestDirectory); - Assert.Equal(_fileSystem.CombinePath(TestDirectory, "Test"), Path.Combine(TestDirectory, "Test")); + Assert.Equal(_fileSystem.CombinePath(TestDirectory, "Test"), Path.Join(TestDirectory, "Test")); } [Fact] public void CopyDirectory_SourceDirectoryName_DestinationDirectoryName() { - string FullPathToSourceDirectory = Path.Combine(TestDirectory, "SourceDirectory"); + string FullPathToSourceDirectory = Path.Join(TestDirectory, "SourceDirectory"); Directory.CreateDirectory(FullPathToSourceDirectory); for (int i = 0; i < 6; i++) { CreateTestFile(SourceData, PathFromBase: "SourceDirectory", TestFileName: $"NewFile{i}"); } - string FullPathToTargetDirectory = Path.Combine(TestDirectory, "TargetDirectory"); + string FullPathToTargetDirectory = Path.Join(TestDirectory, "TargetDirectory"); _fileSystem.CopyDirectory(FullPathToSourceDirectory, FullPathToTargetDirectory); Assert.Equal(Directory.GetFiles(FullPathToSourceDirectory).Length, Directory.GetFiles(FullPathToTargetDirectory).Length); foreach (string CurrentFile in Directory.GetFiles(FullPathToTargetDirectory)) @@ -76,8 +76,8 @@ public void CopyDirectory_SourceDirectoryName_DestinationDirectoryName() [Fact] public void CopyDirectory_SourceDirectoryName_DestinationDirectoryName_OverwriteFalse() { - string FullPathToSourceDirectory = Path.Combine(TestDirectory, "SourceDirectory"); - string FullPathToTargetDirectory = Path.Combine(TestDirectory, "TargetDirectory"); + string FullPathToSourceDirectory = Path.Join(TestDirectory, "SourceDirectory"); + string FullPathToTargetDirectory = Path.Join(TestDirectory, "TargetDirectory"); Directory.CreateDirectory(FullPathToSourceDirectory); for (int i = 0; i < 6; i++) { @@ -106,8 +106,8 @@ public void CopyDirectory_SourceDirectoryName_DestinationDirectoryName_Overwrite [Fact] public void CopyDirectory_SourceDirectoryName_DestinationDirectoryName_OverwriteTrue() { - string FullPathToSourceDirectory = Path.Combine(TestDirectory, "SourceDirectory"); - string FullPathToTargetDirectory = Path.Combine(TestDirectory, "TargetDirectory"); + string FullPathToSourceDirectory = Path.Join(TestDirectory, "SourceDirectory"); + string FullPathToTargetDirectory = Path.Join(TestDirectory, "TargetDirectory"); Directory.CreateDirectory(FullPathToSourceDirectory); Directory.CreateDirectory(FullPathToTargetDirectory); for (int i = 0; i < 6; i++) @@ -179,7 +179,7 @@ public void CopyFile_FileSourceFileName_DestinationFileName_OverwriteTrue() [Fact] public void CreateDirectory_Directory() { - string FullPathToNewDirectory = Path.Combine(TestDirectory, "NewDirectory"); + string FullPathToNewDirectory = Path.Join(TestDirectory, "NewDirectory"); Assert.False(Directory.Exists(FullPathToNewDirectory)); _fileSystem.CreateDirectory(FullPathToNewDirectory); Assert.True(Directory.Exists(FullPathToNewDirectory)); @@ -205,7 +205,7 @@ public void CurrentDirectorySet() [Fact] public void DeleteDirectory_Directory_DeleteAllContents() { - string FullPathToNewDirectory = Path.Combine(TestDirectory, "NewDirectory"); + string FullPathToNewDirectory = Path.Join(TestDirectory, "NewDirectory"); Directory.CreateDirectory(FullPathToNewDirectory); Assert.True(Directory.Exists(FullPathToNewDirectory)); string testFileSource = CreateTestFile(SourceData, PathFromBase: "NewDirectory", TestFileName: "TestFile"); @@ -217,7 +217,7 @@ public void DeleteDirectory_Directory_DeleteAllContents() [Fact] public void DeleteDirectory_Directory_ThrowIfDirectoryNonEmpty() { - string FullPathToNewDirectory = Path.Combine(TestDirectory, "NewDirectory"); + string FullPathToNewDirectory = Path.Join(TestDirectory, "NewDirectory"); _fileSystem.CreateDirectory(FullPathToNewDirectory); Assert.True(Directory.Exists(FullPathToNewDirectory)); string testFileSource = CreateTestFile(SourceData, PathFromBase: "NewDirectory", TestFileName: "TestFile"); @@ -242,7 +242,7 @@ public void DeleteFile_File() public void DirectoryExists_Directory() { Assert.True(_fileSystem.DirectoryExists(TestDirectory)); - Assert.False(_fileSystem.DirectoryExists(Path.Combine(TestDirectory, "NewDirectory"))); + Assert.False(_fileSystem.DirectoryExists(Path.Join(TestDirectory, "NewDirectory"))); } // Not tested: @@ -269,17 +269,17 @@ public void GetDirectories_Directory() Assert.Empty(DirectoryList); for (int i = 0; i < 6; i++) { - Directory.CreateDirectory(Path.Combine(TestDirectory, $"GetDirectories_DirectoryNewSubDirectory{i}")); + Directory.CreateDirectory(Path.Join(TestDirectory, $"GetDirectories_DirectoryNewSubDirectory{i}")); } DirectoryList = _fileSystem.GetDirectories(TestDirectory); Assert.Equal(6, DirectoryList.Count); for (int i = 0; i < 6; i++) { - Assert.Contains(Path.Combine(TestDirectory, $"GetDirectories_DirectoryNewSubDirectory{i}"), DirectoryList); + Assert.Contains(Path.Join(TestDirectory, $"GetDirectories_DirectoryNewSubDirectory{i}"), DirectoryList); } - Directory.CreateDirectory(Path.Combine(TestDirectory, $"GetDirectories_DirectoryNewSubDirectory0", $"NewSubSubDirectory")); + Directory.CreateDirectory(Path.Join(TestDirectory, $"GetDirectories_DirectoryNewSubDirectory0", $"NewSubSubDirectory")); DirectoryList = _fileSystem.GetDirectories(TestDirectory); Assert.Equal(6, DirectoryList.Count); } @@ -291,17 +291,17 @@ public void GetDirectories_Directory_SearchOption() Assert.Empty(DirectoryList); for (int i = 0; i < 6; i++) { - Directory.CreateDirectory(Path.Combine(TestDirectory, $"GetDirectories_Directory_SearchOptionNewSubDirectory{i}")); + Directory.CreateDirectory(Path.Join(TestDirectory, $"GetDirectories_Directory_SearchOptionNewSubDirectory{i}")); } DirectoryList = _fileSystem.GetDirectories(TestDirectory, SearchOption.SearchTopLevelOnly); Assert.Equal(6, DirectoryList.Count); for (int i = 0; i < 6; i++) { - Assert.Contains(Path.Combine(TestDirectory, $"GetDirectories_Directory_SearchOptionNewSubDirectory{i}"), DirectoryList); + Assert.Contains(Path.Join(TestDirectory, $"GetDirectories_Directory_SearchOptionNewSubDirectory{i}"), DirectoryList); } - Directory.CreateDirectory(Path.Combine(TestDirectory, $"GetDirectories_Directory_SearchOptionNewSubDirectory0", $"NewSubSubDirectory")); + Directory.CreateDirectory(Path.Join(TestDirectory, $"GetDirectories_Directory_SearchOptionNewSubDirectory0", $"NewSubSubDirectory")); DirectoryList = _fileSystem.GetDirectories(TestDirectory, SearchOption.SearchTopLevelOnly); Assert.Equal(6, DirectoryList.Count); DirectoryList = _fileSystem.GetDirectories(TestDirectory, SearchOption.SearchAllSubDirectories); @@ -316,18 +316,18 @@ public void GetDirectories_Directory_SearchOption_Wildcards() List CreatedDirectories = []; for (int i = 0; i < 6; i++) { - CreatedDirectories.Add(Directory.CreateDirectory(Path.Combine(TestDirectory, $"NewSubDirectory00{i}")).Name); + CreatedDirectories.Add(Directory.CreateDirectory(Path.Join(TestDirectory, $"NewSubDirectory00{i}")).Name); } DirectoryList = _fileSystem.GetDirectories(TestDirectory, SearchOption.SearchTopLevelOnly, "*000", "*001"); Assert.Equal(2, DirectoryList.Count); for (int i = 0; i < 2; i++) { - string DirectoryName = Path.Combine(TestDirectory, $"NewSubDirectory00{i}"); + string DirectoryName = Path.Join(TestDirectory, $"NewSubDirectory00{i}"); Assert.Contains(DirectoryName, DirectoryList); } - Directory.CreateDirectory(Path.Combine(TestDirectory, $"NewSubDirectory000", $"NewSubSubDirectory000")); + Directory.CreateDirectory(Path.Join(TestDirectory, $"NewSubDirectory000", $"NewSubSubDirectory000")); DirectoryList = _fileSystem.GetDirectories(TestDirectory, SearchOption.SearchTopLevelOnly, "*000"); Assert.Single(DirectoryList); DirectoryList = _fileSystem.GetDirectories(TestDirectory, SearchOption.SearchAllSubDirectories, "*000"); @@ -339,10 +339,10 @@ public void GetDirectoryInfo_Directory() { for (int i = 0; i < 6; i++) { - Directory.CreateDirectory(Path.Combine(TestDirectory, $"NewSubDirectory{i}")); + Directory.CreateDirectory(Path.Join(TestDirectory, $"NewSubDirectory{i}")); } - Directory.CreateDirectory(Path.Combine(TestDirectory, $"NewSubDirectory0", $"NewSubSubDirectory")); + Directory.CreateDirectory(Path.Join(TestDirectory, $"NewSubDirectory0", $"NewSubSubDirectory")); var info = _fileSystem.GetDirectoryInfo(TestDirectory); var infoFromIO = new DirectoryInfo(TestDirectory); Assert.Equal(info.CreationTime, infoFromIO.CreationTime); @@ -400,10 +400,10 @@ public void GetFiles_Directory() Assert.Equal(6, FileList.Count); for (int i = 0; i < 6; i++) { - Assert.Contains(Path.Combine(TestDirectory, $"NewFile{i}"), FileList); + Assert.Contains(Path.Join(TestDirectory, $"NewFile{i}"), FileList); } - Directory.CreateDirectory(Path.Combine(TestDirectory, "GetFiles_DirectoryNewSubDirectory")); + Directory.CreateDirectory(Path.Join(TestDirectory, "GetFiles_DirectoryNewSubDirectory")); CreateTestFile(SourceData, PathFromBase: "GetFiles_DirectoryNewSubDirectory", TestFileName: "NewFile"); FileList = _fileSystem.GetFiles(TestDirectory); Assert.Equal(6, FileList.Count); @@ -412,7 +412,7 @@ public void GetFiles_Directory() [Fact] public void GetFiles_Directory_SearchOption() { - string NewSubDirectoryPath = Path.Combine(TestDirectory, "GetFiles_Directory_SearchOptionNewSubDirectory"); + string NewSubDirectoryPath = Path.Join(TestDirectory, "GetFiles_Directory_SearchOptionNewSubDirectory"); Directory.CreateDirectory(NewSubDirectoryPath); CreateTestFile(SourceData, PathFromBase: "GetFiles_Directory_SearchOptionNewSubDirectory", TestFileName: "NewFile"); var FileList = _fileSystem.GetFiles(TestDirectory); @@ -427,7 +427,7 @@ public void GetFiles_Directory_SearchOption() Assert.Equal(6, FileList.Count); for (int i = 0; i < 6; i++) { - Assert.Contains(Path.Combine(TestDirectory, $"NewFile{i}"), FileList); + Assert.Contains(Path.Join(TestDirectory, $"NewFile{i}"), FileList); } FileList = _fileSystem.GetFiles(TestDirectory, SearchOption.SearchAllSubDirectories); @@ -456,7 +456,7 @@ public void GetFiles_Directory_SearchOption_Wildcards() Assert.Contains(FileList[i], TestFileList); } - string NewSubDirectoryPath = Path.Combine(TestDirectory, "GetFiles_Directory_SearchOption_WildcardsNewSubDirectory"); + string NewSubDirectoryPath = Path.Join(TestDirectory, "GetFiles_Directory_SearchOption_WildcardsNewSubDirectory"); Directory.CreateDirectory(NewSubDirectoryPath); TestFileList.Add(CreateTestFile(SourceData, PathFromBase: "GetFiles_Directory_SearchOption_WildcardsNewSubDirectory", TestFileName: "NewFile.cs")); FileList = _fileSystem.GetFiles(TestDirectory, SearchOption.SearchAllSubDirectories, "*.cs"); @@ -488,8 +488,8 @@ public void GetTempFileName() [Fact] public void MoveDirectory_SourceDirectoryName_DestinationDirectoryName() { - string FullPathToSourceDirectory = Path.Combine(TestDirectory, "SourceDirectory"); - string FullPathToTargetDirectory = Path.Combine(TestDirectory, "TargetDirectory"); + string FullPathToSourceDirectory = Path.Join(TestDirectory, "SourceDirectory"); + string FullPathToTargetDirectory = Path.Join(TestDirectory, "TargetDirectory"); Directory.CreateDirectory(FullPathToSourceDirectory); for (int i = 0; i < 6; i++) { @@ -514,8 +514,8 @@ public void MoveDirectory_SourceDirectoryName_DestinationDirectoryName() [Fact] public void MoveDirectory_SourceDirectoryName_DestinationDirectoryName_OverwriteFalse() { - string FullPathToSourceDirectory = Path.Combine(TestDirectory, "SourceDirectory"); - string FullPathToTargetDirectory = Path.Combine(TestDirectory, "TargetDirectory"); + string FullPathToSourceDirectory = Path.Join(TestDirectory, "SourceDirectory"); + string FullPathToTargetDirectory = Path.Join(TestDirectory, "TargetDirectory"); Directory.CreateDirectory(FullPathToSourceDirectory); for (int i = 0; i < 6; i++) { @@ -552,8 +552,8 @@ public void MoveDirectory_SourceDirectoryName_DestinationDirectoryName_Overwrite [Fact] public void MoveDirectory_SourceDirectoryName_DestinationDirectoryName_OverwriteTrue() { - string FullPathToSourceDirectory = Path.Combine(TestDirectory, "SourceDirectory"); - string FullPathToTargetDirectory = Path.Combine(TestDirectory, "TargetDirectory"); + string FullPathToSourceDirectory = Path.Join(TestDirectory, "SourceDirectory"); + string FullPathToTargetDirectory = Path.Join(TestDirectory, "TargetDirectory"); Directory.CreateDirectory(FullPathToSourceDirectory); Directory.CreateDirectory(FullPathToTargetDirectory); for (int i = 0; i < 6; i++) @@ -575,7 +575,7 @@ public void MoveDirectory_SourceDirectoryName_DestinationDirectoryName_Overwrite public void MoveFile_SourceFileName_DestinationFileName() { string SourceFileNameWithPath = CreateTestFile(SourceData, TestFileName: GetTestFileName()); - string DestinationFileNameWithPath = Path.Combine(TestDirectory, "NewName"); + string DestinationFileNameWithPath = Path.Join(TestDirectory, "NewName"); _fileSystem.MoveFile(SourceFileNameWithPath, DestinationFileNameWithPath); Assert.False(File.Exists(SourceFileNameWithPath)); Assert.True(File.Exists(DestinationFileNameWithPath)); @@ -593,7 +593,7 @@ public void MoveFile_SourceFileName_DestinationFileName() public void MoveFile_SourceFileName_DestinationFileName_OverwriteFalse() { string SourceFileNameWithPath = CreateTestFile(SourceData, TestFileName: GetTestFileName()); - string DestinationFileNameWithPath = Path.Combine(TestDirectory, "NewName"); + string DestinationFileNameWithPath = Path.Join(TestDirectory, "NewName"); _fileSystem.MoveFile(SourceFileNameWithPath, DestinationFileNameWithPath, overwrite: false); Assert.False(File.Exists(SourceFileNameWithPath)); Assert.True(File.Exists(DestinationFileNameWithPath)); @@ -610,7 +610,7 @@ public void MoveFile_SourceFileName_DestinationFileName_OverwriteFalse() public void MoveFile_SourceFileName_DestinationFileName_OverwriteTrue() { string SourceFileNameWithPath = CreateTestFile(SourceData, TestFileName: GetTestFileName()); - string DestinationFileNameWithPath = Path.Combine(TestDirectory, "NewName"); + string DestinationFileNameWithPath = Path.Join(TestDirectory, "NewName"); _fileSystem.MoveFile(SourceFileNameWithPath, DestinationFileNameWithPath, overwrite: true); Assert.False(File.Exists(SourceFileNameWithPath)); Assert.True(File.Exists(DestinationFileNameWithPath)); @@ -638,16 +638,16 @@ public void MoveFile_SourceFileName_DestinationFileName_OverwriteTrue() public void RenameDirectory_Directory_NewName() { // If directory does not point to an existing directory. - Assert.Throws(() => _fileSystem.RenameDirectory(Path.Combine(TestDirectory, "DoesNotExistDirectory"), "NewDirectory")); - string OrigDirectoryWithPath = Path.Combine(TestDirectory, "OriginalDirectory"); + Assert.Throws(() => _fileSystem.RenameDirectory(Path.Join(TestDirectory, "DoesNotExistDirectory"), "NewDirectory")); + string OrigDirectoryWithPath = Path.Join(TestDirectory, "OriginalDirectory"); Directory.CreateDirectory(OrigDirectoryWithPath); // If newName is null or Empty String. Assert.Throws(() => _fileSystem.RenameDirectory(OrigDirectoryWithPath, "")); - string DirectoryNameWithPath = Path.Combine(TestDirectory, "DoesNotExist"); + string DirectoryNameWithPath = Path.Join(TestDirectory, "DoesNotExist"); // If contains path information. Assert.Throws(() => _fileSystem.RenameDirectory(OrigDirectoryWithPath, DirectoryNameWithPath)); _fileSystem.RenameDirectory(OrigDirectoryWithPath, "NewFDirectory"); - string NewFDirectoryPath = Path.Combine(TestDirectory, "NewFDirectory"); + string NewFDirectoryPath = Path.Join(TestDirectory, "NewFDirectory"); Assert.True(Directory.Exists(NewFDirectoryPath)); Assert.False(Directory.Exists(OrigDirectoryWithPath)); // @@ -662,7 +662,7 @@ public void RenameDirectory_Directory_NewName() public void RenameFile_File_NewName() { // If file does not point to an existing file. - Assert.Throws(() => _fileSystem.RenameFile(Path.Combine(TestDirectory, "DoesNotExistFile"), "NewFile")); + Assert.Throws(() => _fileSystem.RenameFile(Path.Join(TestDirectory, "DoesNotExistFile"), "NewFile")); string OrigFileWithPath = CreateTestFile(SourceData, TestFileName: GetTestFileName()); string ExistingFileWithPath = CreateTestFile(DestData, TestFileName: GetTestFileName()); // If newName is null or Empty String. @@ -670,12 +670,12 @@ public void RenameFile_File_NewName() // If contains path information. Assert.Throws(() => _fileSystem.RenameFile(OrigFileWithPath, ExistingFileWithPath)); _fileSystem.RenameFile(OrigFileWithPath, "NewFile"); - string NewFileWithPath = Path.Combine(TestDirectory, "NewFile"); + string NewFileWithPath = Path.Join(TestDirectory, "NewFile"); Assert.True(File.Exists(NewFileWithPath)); Assert.False(File.Exists(OrigFileWithPath)); // If there's an existing directory or an existing file with the same name. Assert.Throws(() => _fileSystem.RenameFile(NewFileWithPath, "NewFile")); - Directory.CreateDirectory(Path.Combine(TestDirectory, "NewFDirectory")); + Directory.CreateDirectory(Path.Join(TestDirectory, "NewFDirectory")); Assert.Throws(() => _fileSystem.RenameFile(NewFileWithPath, "NewFDirectory")); } @@ -698,10 +698,10 @@ private string CreateTestFile(string TestData, string TestFileName, string PathF string TempFileNameWithPath = TestDirectory; if (!string.IsNullOrEmpty(PathFromBase)) { - TempFileNameWithPath = Path.Combine(TempFileNameWithPath, PathFromBase); + TempFileNameWithPath = Path.Join(TempFileNameWithPath, PathFromBase); } - TempFileNameWithPath = Path.Combine(TempFileNameWithPath, TestFileName); + TempFileNameWithPath = Path.Join(TempFileNameWithPath, TestFileName); Assert.False(File.Exists(TempFileNameWithPath), $"File {TempFileNameWithPath} should not exist!"); WriteFile(TempFileNameWithPath, TestData); return TempFileNameWithPath; diff --git a/src/System.Drawing.Common/tests/Helpers.cs b/src/System.Drawing.Common/tests/Helpers.cs index ed63290fa40..9b31b2f456b 100644 --- a/src/System.Drawing.Common/tests/Helpers.cs +++ b/src/System.Drawing.Common/tests/Helpers.cs @@ -25,7 +25,7 @@ public static unsafe class Helpers public static string GetTestFontPath(string fileName) => GetTestPath("fonts", fileName); public static string GetTestColorProfilePath(string fileName) => GetTestPath("colorProfiles", fileName); - private static string GetTestPath(string directoryName, string fileName) => Path.Combine(AppContext.BaseDirectory, directoryName, fileName); + private static string GetTestPath(string directoryName, string fileName) => Path.Join(AppContext.BaseDirectory, directoryName, fileName); public static void VerifyBitmap(Bitmap bitmap, Color[][] colors) { diff --git a/src/System.Drawing.Common/tests/System/Drawing/IconConverterTests.cs b/src/System.Drawing.Common/tests/System/Drawing/IconConverterTests.cs index 945d897f301..246a347b511 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/IconConverterTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/IconConverterTests.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Drawing.Imaging; @@ -18,7 +18,7 @@ public class IconConverterTest public IconConverterTest() { - _icon = new Icon(Path.Combine("bitmaps", "TestIcon.ico")); + _icon = new Icon(Path.Join("bitmaps", "TestIcon.ico")); _iconStr = _icon.ToString(); using (MemoryStream destStream = new()) diff --git a/src/System.Drawing.Common/tests/System/Drawing/ImageAnimator.ManualTests.cs b/src/System.Drawing.Common/tests/System/Drawing/ImageAnimator.ManualTests.cs index 9ff6d323bdc..69f9e7507be 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/ImageAnimator.ManualTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/ImageAnimator.ManualTests.cs @@ -7,7 +7,7 @@ namespace System.Drawing.Tests; public class ImageAnimatorManualTests { - public static string OutputFolder { get; } = Path.Combine(Environment.CurrentDirectory, "ImageAnimatorManualTests", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); + public static string OutputFolder { get; } = Path.Join(Environment.CurrentDirectory, "ImageAnimatorManualTests", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); [Fact(Skip = "Manual Test")] public void AnimateAndCaptureFrames() @@ -44,7 +44,7 @@ public void AnimateAndCaptureFrames() foreach (string imageName in images) { - string testOutputFolder = Path.Combine(OutputFolder, Path.GetFileNameWithoutExtension(imageName)); + string testOutputFolder = Path.Join(OutputFolder, Path.GetFileNameWithoutExtension(imageName)); Directory.CreateDirectory(testOutputFolder); frameIndexes[imageName] = 0; @@ -57,7 +57,7 @@ public void AnimateAndCaptureFrames() // a) The images don't get saved as animated gifs again, and just a single frame is saved // b) Saving pngs in this test on Linux was leading to sporadic GDI+ errors; Jpeg is more reliable string timestamp = stopwatch.ElapsedMilliseconds.ToString("000000"); - animation.Save(Path.Combine(testOutputFolder, $"{++frameIndexes[imageName]}_{timestamp}.jpg"), ImageFormat.Jpeg); + animation.Save(Path.Join(testOutputFolder, $"{++frameIndexes[imageName]}_{timestamp}.jpg"), ImageFormat.Jpeg); })); bitmaps[imageName] = new Bitmap(Helpers.GetTestBitmapPath(imageName)); diff --git a/src/System.Drawing.Common/tests/System/Drawing/ImageConverterTests.cs b/src/System.Drawing.Common/tests/System/Drawing/ImageConverterTests.cs index 05e9fb481d8..16726a84834 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/ImageConverterTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/ImageConverterTests.cs @@ -16,7 +16,7 @@ public class ImageConverterTest public ImageConverterTest() { - _image = Image.FromFile(Path.Combine("bitmaps", "TestImage.bmp")); + _image = Image.FromFile(Path.Join("bitmaps", "TestImage.bmp")); _imageStr = _image.ToString(); using (MemoryStream destStream = new()) @@ -46,7 +46,7 @@ public void ImageConverterFromIconTest(string name) [Fact] public void ImageWithOleHeader() { - string path = Path.Combine("bitmaps", "TestImageWithOleHeader.bmp"); + string path = Path.Join("bitmaps", "TestImageWithOleHeader.bmp"); using FileStream fileStream = File.Open(path, FileMode.Open); using MemoryStream ms = new(); fileStream.CopyTo(ms); diff --git a/src/System.Drawing.Common/tests/System/Drawing/Imaging/ImageFormatTests.cs b/src/System.Drawing.Common/tests/System/Drawing/Imaging/ImageFormatTests.cs index 6e1bb80499c..45452450915 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/Imaging/ImageFormatTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/Imaging/ImageFormatTests.cs @@ -71,10 +71,10 @@ public static IEnumerable ImageFromFileToStringTestData { get { - yield return new object[] { Path.Combine("bitmaps", "nature24bits.gif"), "Gif" }; - yield return new object[] { Path.Combine("bitmaps", "nature24bits.jpg"), "Jpeg" }; - yield return new object[] { Path.Combine("bitmaps", "VisualPng.ico"), "Icon" }; - yield return new object[] { Path.Combine("bitmaps", "almogaver32bits.tif"), "Tiff" }; + yield return new object[] { Path.Join("bitmaps", "nature24bits.gif"), "Gif" }; + yield return new object[] { Path.Join("bitmaps", "nature24bits.jpg"), "Jpeg" }; + yield return new object[] { Path.Join("bitmaps", "VisualPng.ico"), "Icon" }; + yield return new object[] { Path.Join("bitmaps", "almogaver32bits.tif"), "Tiff" }; } } diff --git a/src/System.Drawing.Common/tests/System/Drawing/Text/PrivateFontCollectionTests.cs b/src/System.Drawing.Common/tests/System/Drawing/Text/PrivateFontCollectionTests.cs index 31e587141d3..6d22380bbf0 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/Text/PrivateFontCollectionTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/Text/PrivateFontCollectionTests.cs @@ -41,7 +41,7 @@ public void AddFontFile_RelativePath_Success() } using PrivateFontCollection fontCollection = new(); - string relativePath = Path.Combine("fonts", "CodeNewRoman.ttf"); + string relativePath = Path.Join("fonts", "CodeNewRoman.ttf"); fontCollection.AddFontFile(relativePath); FontFamily fontFamily = Assert.Single(fontCollection.Families); diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/CurrentReferences.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/CurrentReferences.cs index 0db9c0ae5cb..8fdcbac9f19 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/CurrentReferences.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/CurrentReferences.cs @@ -56,11 +56,11 @@ static CurrentReferences() "Release"; #endif - WinFormsRefPath = Path.Combine(RepoRootPath, "artifacts", "obj", "System.Windows.Forms", configuration, tfm, "ref", "System.Windows.Forms.dll"); + WinFormsRefPath = Path.Join(RepoRootPath, "artifacts", "obj", "System.Windows.Forms", configuration, tfm, "ref", "System.Windows.Forms.dll"); // Specify absolute path to the reference assemblies because this version is not necessarily available in the nuget packages cache. - string netCoreAppRefPath = Path.Combine(RepoRootPath, ".dotnet", "packs", RefPackageName); - if (!Directory.Exists(Path.Combine(netCoreAppRefPath, netCoreRefsVersion))) + string netCoreAppRefPath = Path.Join(RepoRootPath, ".dotnet", "packs", RefPackageName); + if (!Directory.Exists(Path.Join(netCoreAppRefPath, netCoreRefsVersion))) { netCoreRefsVersion = GetAvailableVersion(netCoreAppRefPath, $"{netCoreRefsVersion.Split('.')[0]}."); } @@ -71,8 +71,8 @@ static CurrentReferences() NetCoreAppReferences = new ReferenceAssemblies( tfm, new PackageIdentity(RefPackageName, netCoreRefsVersion), - Path.Combine("ref", tfm)) - .WithNuGetConfigFilePath(Path.Combine(RepoRootPath, "NuGet.Config")); + Path.Join("ref", tfm)) + .WithNuGetConfigFilePath(Path.Join(RepoRootPath, "NuGet.Config")); } private static string GetAvailableVersion(string netCoreAppRefPath, string major) @@ -98,7 +98,7 @@ private static bool TryGetNetCoreVersion( } // First, try to use the local .NET SDK if it's there. - string sdkFolderPath = Path.Combine(rootFolderPath, ".dotnet", "sdk", version); + string sdkFolderPath = Path.Join(rootFolderPath, ".dotnet", "sdk", version); if (!Directory.Exists(sdkFolderPath)) { return false; @@ -120,7 +120,7 @@ private static bool GetRootFolderPath([NotNullWhen(true)] out string? root) while (currentFolderPath is not null) { - string globalJsonPath = Path.Combine(currentFolderPath, "global.json"); + string globalJsonPath = Path.Join(currentFolderPath, "global.json"); if (File.Exists(globalJsonPath)) { // We've found the repo root. @@ -137,7 +137,7 @@ private static bool GetRootFolderPath([NotNullWhen(true)] out string? root) private static bool TryGetSdkVersion(string rootFolderPath, [NotNullWhen(true)] out string? version) { - string globalJsonPath = Path.Combine(rootFolderPath, "global.json"); + string globalJsonPath = Path.Join(rootFolderPath, "global.json"); string globalJsonString = File.ReadAllText(globalJsonPath); JsonObject? jsonObject = JsonNode.Parse(globalJsonString)?.AsObject(); version = (string?)jsonObject?["sdk"]?["version"]; @@ -150,7 +150,7 @@ private static bool TryGetNetCoreVersionFromJson( [NotNullWhen(true)] out string? tfm, [NotNullWhen(true)] out string? version) { - string configJsonPath = Path.Combine(sdkFolderPath, "dotnet.runtimeconfig.json"); + string configJsonPath = Path.Join(sdkFolderPath, "dotnet.runtimeconfig.json"); string configJsonString = File.ReadAllText(configJsonPath); JsonObject? jsonObject = JsonNode.Parse(configJsonString)?.AsObject(); JsonNode? runtimeOptions = jsonObject?["runtimeOptions"]; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/TestFileLoader.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/TestFileLoader.cs index 33da247df37..611ee500379 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/TestFileLoader.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/TestFileLoader.cs @@ -54,7 +54,7 @@ public static async Task GetAnalyzerTestCodeAsync( [CallerFilePath] string filePath = "") { string toolName = Path.GetFileName(Path.GetDirectoryName(filePath))!; - return await LoadTestFileAsync(Path.Combine("Analyzers", toolName), testName, SourceLanguage.None).ConfigureAwait(false); + return await LoadTestFileAsync(Path.Join("Analyzers", toolName), testName, SourceLanguage.None).ConfigureAwait(false); } public static async Task GetGeneratorTestCodeAsync( @@ -62,7 +62,7 @@ public static async Task GetGeneratorTestCodeAsync( [CallerFilePath] string filePath = "") { string toolName = Path.GetFileName(Path.GetDirectoryName(filePath))!; - return await LoadTestFileAsync(Path.Combine("Generators", toolName), testName, SourceLanguage.None).ConfigureAwait(false); + return await LoadTestFileAsync(Path.Join("Generators", toolName), testName, SourceLanguage.None).ConfigureAwait(false); } public static async Task GetCSAnalyzerTestCodeAsync( @@ -70,7 +70,7 @@ public static async Task GetCSAnalyzerTestCodeAsync( [CallerFilePath] string filePath = "") { string toolName = Path.GetFileName(Path.GetDirectoryName(filePath))!; - return await LoadTestFileAsync(Path.Combine("Analyzers", toolName), testName).ConfigureAwait(false); + return await LoadTestFileAsync(Path.Join("Analyzers", toolName), testName).ConfigureAwait(false); } public static async Task GetVBAnalyzerTestCodeAsync( @@ -78,6 +78,6 @@ public static async Task GetVBAnalyzerTestCodeAsync( [CallerFilePath] string filePath = "") { string toolName = Path.GetFileName(Path.GetDirectoryName(filePath))!; - return await LoadTestFileAsync(Path.Combine("Analyzers", toolName), testName, SourceLanguage.VisualBasic).ConfigureAwait(false); + return await LoadTestFileAsync(Path.Join("Analyzers", toolName), testName, SourceLanguage.VisualBasic).ConfigureAwait(false); } } diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs index 75dfd755092..b0ddc6cde66 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs @@ -52,7 +52,7 @@ public static partial class PlatformDetection // Windows OneCoreUAP SKU doesn't have httpapi.dll public static bool IsNotOneCoreUAP => - File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "System32", "httpapi.dll")); + File.Exists(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "System32", "httpapi.dll")); public static bool IsWindowsIoTCore => GetWindowsProductType() is PRODUCT_IOTUAPCOMMERCIAL or PRODUCT_IOTUAP; diff --git a/src/System.Windows.Forms/System/Resources/AssemblyNamesTypeResolutionService.cs b/src/System.Windows.Forms/System/Resources/AssemblyNamesTypeResolutionService.cs index 044a348151d..c99a198c9a7 100644 --- a/src/System.Windows.Forms/System/Resources/AssemblyNamesTypeResolutionService.cs +++ b/src/System.Windows.Forms/System/Resources/AssemblyNamesTypeResolutionService.cs @@ -13,8 +13,9 @@ internal class AssemblyNamesTypeResolutionService : ITypeResolutionService private ConcurrentDictionary? _cachedAssemblies; private ConcurrentDictionary? _cachedTypes; - private static readonly string s_dotNetPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles") ?? string.Empty, "dotnet\\shared"); - private static readonly string s_dotNetPathX86 = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)") ?? string.Empty, "dotnet\\shared"); + private static readonly string s_dotNetPath = Path.Join( + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), + @"dotnet\shared\"); internal AssemblyNamesTypeResolutionService(AssemblyName[]? names) => _names = names; @@ -155,12 +156,12 @@ public string GetPathOfAssembly(AssemblyName name) throw new ArgumentException(string.Format(SR.InvalidResXNoType, name)); } - if (result is not null) +#pragma warning disable IL3000 // Avoid accessing Assembly file path when publishing as a single file + if (result?.Assembly?.Location is { } location) { // Only cache types from the shared framework because they don't need to update. // For simplicity, don't cache custom types -#pragma warning disable IL3000 // Avoid accessing Assembly file path when publishing as a single file - if (IsDotNetAssembly(result.Assembly.Location)) + if (location.StartsWith(s_dotNetPath, StringComparison.OrdinalIgnoreCase)) { _cachedTypes[name] = result; } @@ -170,13 +171,5 @@ public string GetPathOfAssembly(AssemblyName name) return result; } - /// - /// This is matching %windir%\Microsoft.NET\Framework*, so both 32bit and 64bit framework will be covered. - /// - private static bool IsDotNetAssembly(string assemblyPath) - => assemblyPath is not null - && (assemblyPath.StartsWith(s_dotNetPath, StringComparison.OrdinalIgnoreCase) - || assemblyPath.StartsWith(s_dotNetPathX86, StringComparison.OrdinalIgnoreCase)); - public void ReferenceAssembly(AssemblyName name) => throw new NotSupportedException(); } diff --git a/src/System.Windows.Forms/System/Resources/ResXDataNode.cs b/src/System.Windows.Forms/System/Resources/ResXDataNode.cs index 2f18c6655c2..48a5184a867 100644 --- a/src/System.Windows.Forms/System/Resources/ResXDataNode.cs +++ b/src/System.Windows.Forms/System/Resources/ResXDataNode.cs @@ -131,7 +131,7 @@ internal ResXDataNode(DataNodeInfo nodeInfo, string? basePath) if (fileRefDetails is not null && fileRefDetails.Length > 1) { _fileRefFullPath = !Path.IsPathRooted(fileRefDetails[0]) && basePath is not null - ? Path.Combine(basePath, fileRefDetails[0]) + ? Path.Join(basePath, fileRefDetails[0]) : fileRefDetails[0]; _fileRefType = fileRefDetails[1]; diff --git a/src/System.Windows.Forms/System/Windows/Forms/Controls/WebBrowser/WebBrowser.cs b/src/System.Windows.Forms/System/Windows/Forms/Controls/WebBrowser/WebBrowser.cs index a7778b53d3d..3462b58204c 100644 --- a/src/System.Windows.Forms/System/Windows/Forms/Controls/WebBrowser/WebBrowser.cs +++ b/src/System.Windows.Forms/System/Windows/Forms/Controls/WebBrowser/WebBrowser.cs @@ -612,7 +612,7 @@ public Version Version { get { - string mshtmlPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "mshtml.dll"); + string mshtmlPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.System), "mshtml.dll"); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(mshtmlPath); return new Version(fvi.FileMajorPart, fvi.FileMinorPart, fvi.FileBuildPart, fvi.FilePrivatePart); } diff --git a/src/test/integration/System.Windows.Forms.IntegrationTests.Common/TestHelpers.cs b/src/test/integration/System.Windows.Forms.IntegrationTests.Common/TestHelpers.cs index 1972f71322c..8f80b60e51a 100644 --- a/src/test/integration/System.Windows.Forms.IntegrationTests.Common/TestHelpers.cs +++ b/src/test/integration/System.Windows.Forms.IntegrationTests.Common/TestHelpers.cs @@ -55,7 +55,7 @@ public static string GetExePath(string projectName) throw new ArgumentNullException(nameof(projectName)); string repoRoot = GetRepoRoot(); - string exePath = Path.Combine( + string exePath = Path.Join( repoRoot, $"artifacts\\bin\\{projectName}\\{Config}\\{TargetFramework}\\{projectName}.exe"); @@ -182,7 +182,7 @@ private static string GetGlobalDotNetPath() string repoRoot = GetRepoRoot(); // make sure there's a global.json - string jsonFile = Path.Combine(repoRoot, "global.json"); + string jsonFile = Path.Join(repoRoot, "global.json"); if (!File.Exists(jsonFile)) throw new FileNotFoundException("global.json does not exist"); @@ -205,7 +205,7 @@ private static string GetGlobalDotNetPath() // Check to see if the matching version is installed // The default install location is C:\Program Files\dotnet\sdk string defaultSdkRoot = @"C:\Program Files\dotnet\sdk"; - string sdkPath = Path.Combine(defaultSdkRoot, dotnetVersion); + string sdkPath = Path.Join(defaultSdkRoot, dotnetVersion); if (!Directory.Exists(sdkPath)) throw new DirectoryNotFoundException($"dotnet sdk {dotnetVersion} is not installed globally"); @@ -247,7 +247,7 @@ private static string RelativePathBackwardsUntilFind(string seek) { if (Directory.GetDirectories(currentDirectory, seek, SearchOption.TopDirectoryOnly).Length == 1) { - string ret = Path.Combine(currentDirectory, seek); + string ret = Path.Join(currentDirectory, seek); return ret; } diff --git a/src/test/integration/UIIntegrationTests/DragDropTests.cs b/src/test/integration/UIIntegrationTests/DragDropTests.cs index 7fd08a3b569..d09e21a8e37 100644 --- a/src/test/integration/UIIntegrationTests/DragDropTests.cs +++ b/src/test/integration/UIIntegrationTests/DragDropTests.cs @@ -128,7 +128,7 @@ public async Task DragDrop_RTF_FromExplorer_ToRichTextBox_ReturnsExpected_Async( await RunTestAsync(dragDropForm => { string dragAcceptRtfDestPath = string.Empty; - string dragDropDirectory = Path.Combine(Directory.GetCurrentDirectory(), DragDrop); + string dragDropDirectory = Path.Join(Directory.GetCurrentDirectory(), DragDrop); RunTest(); unsafe void RunTest() @@ -138,14 +138,14 @@ unsafe void RunTest() try { - string dragAcceptRtfSourcePath = Path.Combine(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); + string dragAcceptRtfSourcePath = Path.Join(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); if (!Directory.Exists(dragDropDirectory)) { Directory.CreateDirectory(dragDropDirectory); } - dragAcceptRtfDestPath = Path.Combine(dragDropDirectory, DragAcceptRtf); + dragAcceptRtfDestPath = Path.Join(dragDropDirectory, DragAcceptRtf); if (!File.Exists(dragAcceptRtfDestPath)) { @@ -423,7 +423,7 @@ public async Task PictureBox_SetData_DoDragDrop_RichTextBox_ReturnsExpected_Asyn { await RunFormWithoutControlAsync(() => new DragImageDropDescriptionForm(TestOutputHelper), async (form) => { - string dragAcceptRtfPath = Path.Combine(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); + string dragAcceptRtfPath = Path.Join(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); using RichTextBox richTextBox = new(); richTextBox.Rtf = File.ReadAllText(dragAcceptRtfPath); string dragAcceptRtfContent = richTextBox.Rtf; @@ -453,7 +453,7 @@ public async Task ToolStripItem_SetData_DoDragDrop_RichTextBox_ReturnsExpected_A { await RunFormWithoutControlAsync(() => new DragImageDropDescriptionForm(TestOutputHelper), async (form) => { - string dragAcceptRtfPath = Path.Combine(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); + string dragAcceptRtfPath = Path.Join(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); using RichTextBox richTextBox = new(); richTextBox.Rtf = File.ReadAllText(dragAcceptRtfPath); string dragAcceptRtfContent = richTextBox.Rtf; @@ -1082,7 +1082,7 @@ private void DragAcceptItem_MouseDown(object? sender, MouseEventArgs e) return; } - string dragAcceptRtf = Path.Combine(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); + string dragAcceptRtf = Path.Join(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); if (File.Exists(dragAcceptRtf)) { string[] dropFiles = [dragAcceptRtf]; @@ -1142,7 +1142,7 @@ private void PictureBoxDragSource_MouseDown(object? sender, MouseEventArgs e) { _testOutputHelper.WriteLine($"Mouse down on drag source at position ({e.X},{e.Y})."); - string dragAcceptRtf = Path.Combine(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); + string dragAcceptRtf = Path.Join(Directory.GetCurrentDirectory(), Resources, DragAcceptRtf); if (File.Exists(dragAcceptRtf)) { string[] dropFiles = [dragAcceptRtf]; diff --git a/src/test/integration/UIIntegrationTests/Infra/DataCollectionService.cs b/src/test/integration/UIIntegrationTests/Infra/DataCollectionService.cs index 353865b7ddd..890a42fdb23 100644 --- a/src/test/integration/UIIntegrationTests/Infra/DataCollectionService.cs +++ b/src/test/integration/UIIntegrationTests/Infra/DataCollectionService.cs @@ -234,13 +234,13 @@ static string CombineElements(string logDirectory, DateTimeOffset timestamp, str string sanitizedTestName = new(testName.Select(c => char.IsLetterOrDigit(c) ? c : '_').ToArray()); string sanitizedErrorId = new(errorId.Select(c => char.IsLetterOrDigit(c) ? c : '_').ToArray()); - return Path.Combine(Path.GetFullPath(logDirectory), $"{timestamp:HH.mm.ss}-{testName}-{errorId}{logId}.{extension}"); + return Path.Join(Path.GetFullPath(logDirectory), $"{timestamp:HH.mm.ss}-{testName}-{errorId}{logId}.{extension}"); } } internal static string GetLogDirectory() { - return Path.Combine(GetBaseLogDirectory(), "Screenshots"); + return Path.Join(GetBaseLogDirectory(), "Screenshots"); } private static string GetBaseLogDirectory() @@ -258,10 +258,10 @@ private static string GetBaseLogDirectory() if (binPathSeparator > 0) { string configuration = Path.GetFileName(Path.GetDirectoryName(assemblyDirectory))!; - return Path.Combine(assemblyDirectory[..binPathSeparator], "log", configuration); + return Path.Join(assemblyDirectory[..binPathSeparator], "log", configuration); } - return Path.Combine(assemblyDirectory, "xUnitResults"); + return Path.Join(assemblyDirectory, "xUnitResults"); } private static string GetAssemblyDirectory() diff --git a/src/test/integration/WinformsControlsTest/DragDrop.cs b/src/test/integration/WinformsControlsTest/DragDrop.cs index 5807cb9bf29..546612652cb 100644 --- a/src/test/integration/WinformsControlsTest/DragDrop.cs +++ b/src/test/integration/WinformsControlsTest/DragDrop.cs @@ -382,7 +382,7 @@ private void ClearCats() private void OpenCats() { - string dragDropDataDirectory = Path.Combine( + string dragDropDataDirectory = Path.Join( Directory.GetCurrentDirectory(), DragDropDataDirectory); @@ -400,7 +400,7 @@ private void OpenCats() private string ReadAsciiText() { - string nyanCatAsciiPath = Path.Combine( + string nyanCatAsciiPath = Path.Join( Directory.GetCurrentDirectory(), DragDropDataDirectory, NyanCatAsciiTxt); @@ -537,7 +537,7 @@ private void DragAcceptItem_MouseDown(object? sender, MouseEventArgs e) DataObject data = new(DataFormats.FileDrop, new string[] { - Path.Combine(Directory.GetCurrentDirectory(), + Path.Join(Directory.GetCurrentDirectory(), DragDropDataDirectory, DragAcceptRtf) }); diff --git a/src/test/unit/System.Windows.Forms/System/Windows/Forms/CursorConverterTests.cs b/src/test/unit/System.Windows.Forms/System/Windows/Forms/CursorConverterTests.cs index 28bbc0790bb..584f714b971 100644 --- a/src/test/unit/System.Windows.Forms/System/Windows/Forms/CursorConverterTests.cs +++ b/src/test/unit/System.Windows.Forms/System/Windows/Forms/CursorConverterTests.cs @@ -36,7 +36,7 @@ public void CursorConverter_ConvertFrom_KnownCursor_ReturnsExpected(string value public void CursorConverter_ConvertFrom_ByteArray_ReturnsExpected() { CursorConverter converter = new(); - byte[] data = File.ReadAllBytes(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")); + byte[] data = File.ReadAllBytes(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")); using Cursor cursor = Assert.IsType(converter.ConvertFrom(data)); Assert.NotEqual(IntPtr.Zero, cursor.Handle); Assert.Equal(new Point(5, 8), cursor.HotSpot); @@ -126,7 +126,7 @@ public void CursorConverter_ConvertTo_NullToInstanceDescriptor_ThrowsNotSupporte public void CursorConverter_ConvertTo_StreamToByteArray_ReturnsExpected() { CursorConverter converter = new(); - byte[] data = File.ReadAllBytes(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")); + byte[] data = File.ReadAllBytes(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")); using MemoryStream stream = new(data); using Cursor sourceCursor = new(stream); Assert.Equal(data, converter.ConvertTo(sourceCursor, typeof(byte[]))); @@ -136,7 +136,7 @@ public void CursorConverter_ConvertTo_StreamToByteArray_ReturnsExpected() public void CursorConverter_ConvertTo_FileToByteArray_ReturnsExpected() { CursorConverter converter = new(); - string fileName = Path.Combine("bitmaps", "10x16_one_entry_32bit.ico"); + string fileName = Path.Join("bitmaps", "10x16_one_entry_32bit.ico"); byte[] data = File.ReadAllBytes(fileName); using Cursor sourceCursor = new(fileName); Assert.Equal(data, converter.ConvertTo(sourceCursor, typeof(byte[]))); diff --git a/src/test/unit/System.Windows.Forms/System/Windows/Forms/CursorTests.cs b/src/test/unit/System.Windows.Forms/System/Windows/Forms/CursorTests.cs index 7457737806c..8f67b927e70 100644 --- a/src/test/unit/System.Windows.Forms/System/Windows/Forms/CursorTests.cs +++ b/src/test/unit/System.Windows.Forms/System/Windows/Forms/CursorTests.cs @@ -57,8 +57,8 @@ public void Cursor_Ctor_ZeroHandle_ThrowsArgumentException() public static IEnumerable Ctor_ValidFile_TestData() { - yield return new object[] { Path.Combine("bitmaps", "cursor.cur"), Point.Empty }; - yield return new object[] { Path.Combine("bitmaps", "10x16_one_entry_32bit.ico"), new Point(5, 8) }; + yield return new object[] { Path.Join("bitmaps", "cursor.cur"), Point.Empty }; + yield return new object[] { Path.Join("bitmaps", "10x16_one_entry_32bit.ico"), new Point(5, 8) }; } [Theory] @@ -76,7 +76,7 @@ public void Cursor_Ctor_Stream(string fileName, Point expectedHotSpot) [Fact] public void Cursor_Ctor_Stream_NonStartPosition() { - using MemoryStream stream = new(File.ReadAllBytes(Path.Combine("bitmaps", "cursor.cur"))); + using MemoryStream stream = new(File.ReadAllBytes(Path.Join("bitmaps", "cursor.cur"))); stream.Position = 5; using Cursor cursor = new(stream); Assert.NotNull(cursor); @@ -96,13 +96,13 @@ public void Cursor_Ctor_NullStream_ThrowsArgumentNullException() public static IEnumerable Ctor_InvalidFile_TestData() { - yield return new object[] { Path.Combine("bitmaps", "nature24bits.jpg") }; - yield return new object[] { Path.Combine("bitmaps", "nature24bits.gif") }; - yield return new object[] { Path.Combine("bitmaps", "1bit.png") }; - yield return new object[] { Path.Combine("bitmaps", "almogaver24bits.bmp") }; - yield return new object[] { Path.Combine("bitmaps", "telescope_01.wmf") }; - yield return new object[] { Path.Combine("bitmaps", "milkmateya01.emf") }; - yield return new object[] { Path.Combine("bitmaps", "EmptyFile") }; + yield return new object[] { Path.Join("bitmaps", "nature24bits.jpg") }; + yield return new object[] { Path.Join("bitmaps", "nature24bits.gif") }; + yield return new object[] { Path.Join("bitmaps", "1bit.png") }; + yield return new object[] { Path.Join("bitmaps", "almogaver24bits.bmp") }; + yield return new object[] { Path.Join("bitmaps", "telescope_01.wmf") }; + yield return new object[] { Path.Join("bitmaps", "milkmateya01.emf") }; + yield return new object[] { Path.Join("bitmaps", "EmptyFile") }; } [Theory] @@ -326,7 +326,7 @@ public void Cursor_Tag_Set_GetReturnsExpected(object value) [Fact] public void Cursor_CopyHandle_Invoke_Success() { - using Cursor sourceCursor = new(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")); + using Cursor sourceCursor = new(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")); IntPtr handle = sourceCursor.CopyHandle(); Assert.NotEqual(IntPtr.Zero, handle); Assert.NotEqual(sourceCursor.Handle, handle); @@ -341,7 +341,7 @@ public void Cursor_CopyHandle_Invoke_Success() [Fact] public void Cursor_Dispose_InvokeOwned_Success() { - Cursor cursor = new(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")); + Cursor cursor = new(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")); cursor.Dispose(); Assert.Throws(() => cursor.Handle); Assert.Throws(() => cursor.HotSpot); @@ -377,7 +377,7 @@ public static IEnumerable Draw_TestData() [MemberData(nameof(Draw_TestData))] public void Cursor_Draw_InvokeValidCursor_Success(Rectangle rectangle) { - using Cursor cursor = new(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")); + using Cursor cursor = new(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")); using Bitmap image = new(10, 10); using Graphics graphics = Graphics.FromImage(image); cursor.Draw(graphics, rectangle); @@ -414,7 +414,7 @@ public void Cursor_Draw_DisposedGraphics_ThrowsArgumentException() [MemberData(nameof(Draw_TestData))] public void Cursor_DrawStretched_InvokeValidCursor_Success(Rectangle rectangle) { - using Cursor cursor = new(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")); + using Cursor cursor = new(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")); using Bitmap image = new(10, 10); using Graphics graphics = Graphics.FromImage(image); cursor.DrawStretched(graphics, rectangle); @@ -499,7 +499,7 @@ public void Cursor_ToString_KnownCursor_ReturnsExpected() [Fact] public void Cursor_ToString_CursorFromFile_ReturnsExpected() { - using Cursor cursor = new(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")); + using Cursor cursor = new(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")); Assert.Equal("[Cursor: System.Windows.Forms.Cursor]", cursor.ToString()); } diff --git a/src/test/unit/System.Windows.Forms/System/Windows/Forms/InputLanguageTests.cs b/src/test/unit/System.Windows.Forms/System/Windows/Forms/InputLanguageTests.cs index 8366640707b..dc024aac310 100644 --- a/src/test/unit/System.Windows.Forms/System/Windows/Forms/InputLanguageTests.cs +++ b/src/test/unit/System.Windows.Forms/System/Windows/Forms/InputLanguageTests.cs @@ -214,7 +214,7 @@ private static void RunPowerShellScript(string path) private static void InstallUserLanguage(string languageTag) { - string file = Path.Combine(Path.GetTempPath(), $"install-language-{languageTag}.ps1"); + string file = Path.Join(Path.GetTempPath(), $"install-language-{languageTag}.ps1"); string script = $$""" $list = Get-WinUserLanguageList $list.Add("{{languageTag}}") @@ -227,7 +227,7 @@ private static void InstallUserLanguage(string languageTag) private static void UninstallUserLanguage(string languageTag) { - string file = Path.Combine(Path.GetTempPath(), $"uninstall-language-{languageTag}.ps1"); + string file = Path.Join(Path.GetTempPath(), $"uninstall-language-{languageTag}.ps1"); string script = $$""" $list = Get-WinUserLanguageList $item = $list | Where-Object {$_.LanguageTag -like "{{languageTag}}"} diff --git a/src/test/unit/System.Windows.Forms/System/Windows/Forms/RichTextBoxTests.cs b/src/test/unit/System.Windows.Forms/System/Windows/Forms/RichTextBoxTests.cs index 1d6d78fc64c..86ed3119f29 100644 --- a/src/test/unit/System.Windows.Forms/System/Windows/Forms/RichTextBoxTests.cs +++ b/src/test/unit/System.Windows.Forms/System/Windows/Forms/RichTextBoxTests.cs @@ -10678,7 +10678,7 @@ public void RichTextBox_SaveFilePath_Invoke_Success() using RichTextBox richTextBox2 = new(); string fileName = "SaveRichTextBox.rtf"; - string projectDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "..", ".."); + string projectDirectory = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "..", ".."); string filePath = $"{projectDirectory}/src/test/unit/System.Windows.Forms/TestResources/Files/{fileName}"; try diff --git a/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripControlHostTests.cs b/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripControlHostTests.cs index f9aaa63220d..830851e3da1 100644 --- a/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripControlHostTests.cs +++ b/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripControlHostTests.cs @@ -399,8 +399,8 @@ public static IEnumerable BackgroundImage_Set_TestData() { yield return new object[] { null }; yield return new object[] { new Bitmap(10, 10) }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")) }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")) }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")) }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")) }; } [WinFormsTheory] @@ -1210,8 +1210,8 @@ public static IEnumerable Image_Set_TestData() { yield return new object[] { imageTransparentColor, null }; yield return new object[] { imageTransparentColor, new Bitmap(10, 10) }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")) }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")) }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")) }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")) }; } } @@ -1336,8 +1336,8 @@ public static IEnumerable ImageTransparentColor_Set_TestData() { yield return new object[] { null, color }; yield return new object[] { new Bitmap(10, 10), color }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), color }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), color }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), color }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), color }; } } diff --git a/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripItemTests.cs b/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripItemTests.cs index bdb472aac89..aeedefc5cb4 100644 --- a/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripItemTests.cs +++ b/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripItemTests.cs @@ -1768,8 +1768,8 @@ public static IEnumerable BackgroundImage_Set_TestData() { yield return new object[] { null }; yield return new object[] { new Bitmap(10, 10) }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")) }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")) }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")) }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")) }; } [WinFormsTheory] @@ -1864,8 +1864,8 @@ public static IEnumerable BackgroundImage_SetWithParentWithHandle_Test { yield return new object[] { null, 0 }; yield return new object[] { new Bitmap(10, 10), 1 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), 1 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), 1 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), 1 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), 1 }; } [WinFormsTheory] @@ -3784,8 +3784,8 @@ public static IEnumerable Image_Set_TestData() { yield return new object[] { imageTransparentColor, null }; yield return new object[] { imageTransparentColor, new Bitmap(10, 10) }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")) }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")) }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")) }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")) }; } } @@ -3814,8 +3814,8 @@ public static IEnumerable Image_SetWithImageIndex_TestData() { yield return new object[] { imageTransparentColor, null, 1 }; yield return new object[] { imageTransparentColor, new Bitmap(10, 10), -1 }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), -1 }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), -1 }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), -1 }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), -1 }; } } @@ -3888,8 +3888,8 @@ public static IEnumerable Image_SetWithOwner_TestData() { yield return new object[] { imageTransparentColor, null, 0 }; yield return new object[] { imageTransparentColor, new Bitmap(10, 10), 1 }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), 1 }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), 1 }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), 1 }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), 1 }; } } @@ -5602,8 +5602,8 @@ public static IEnumerable ImageTransparentColor_Set_TestData() { yield return new object[] { null, color }; yield return new object[] { new Bitmap(10, 10), color }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), color }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), color }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), color }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), color }; } } @@ -5669,10 +5669,10 @@ public static IEnumerable ImageTransparentColor_SetWithOwnerWithHandle yield return new object[] { null, Color.Red, 0 }; yield return new object[] { new Bitmap(10, 10), Color.Empty, 0 }; yield return new object[] { new Bitmap(10, 10), Color.Red, 1 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), Color.Empty, 0 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), Color.Red, 1 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), Color.Empty, 0 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), Color.Red, 1 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), Color.Empty, 0 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), Color.Red, 1 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), Color.Empty, 0 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), Color.Red, 1 }; } [WinFormsTheory] @@ -5736,10 +5736,10 @@ public static IEnumerable ImageTransparentColor_SetWithParentWithHandl yield return new object[] { null, Color.Red, 1 }; yield return new object[] { new Bitmap(10, 10), Color.Empty, 0 }; yield return new object[] { new Bitmap(10, 10), Color.Red, 1 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), Color.Empty, 0 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), Color.Red, 1 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), Color.Empty, 0 }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), Color.Red, 1 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), Color.Empty, 0 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), Color.Red, 1 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), Color.Empty, 0 }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), Color.Red, 1 }; } [WinFormsTheory] diff --git a/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripSeparatorTests.cs b/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripSeparatorTests.cs index 2ff83bfb300..9cd5747ab68 100644 --- a/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripSeparatorTests.cs +++ b/src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripSeparatorTests.cs @@ -113,8 +113,8 @@ public static IEnumerable BackgroundImage_Set_TestData() { yield return new object[] { null }; yield return new object[] { new Bitmap(10, 10) }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")) }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")) }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")) }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")) }; } [WinFormsTheory] @@ -420,8 +420,8 @@ public static IEnumerable Image_Set_TestData() { yield return new object[] { imageTransparentColor, null }; yield return new object[] { imageTransparentColor, new Bitmap(10, 10) }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")) }; - yield return new object[] { imageTransparentColor, Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")) }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")) }; + yield return new object[] { imageTransparentColor, Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")) }; } } @@ -530,8 +530,8 @@ public static IEnumerable ImageTransparentColor_Set_TestData() { yield return new object[] { null, color }; yield return new object[] { new Bitmap(10, 10), color }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "nature24bits.gif")), color }; - yield return new object[] { Image.FromFile(Path.Combine("bitmaps", "10x16_one_entry_32bit.ico")), color }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "nature24bits.gif")), color }; + yield return new object[] { Image.FromFile(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")), color }; } } diff --git a/src/test/unit/accessibility/TestPassApp/CommonControl2.cs b/src/test/unit/accessibility/TestPassApp/CommonControl2.cs index 1f271de6110..4a056623af6 100644 --- a/src/test/unit/accessibility/TestPassApp/CommonControl2.cs +++ b/src/test/unit/accessibility/TestPassApp/CommonControl2.cs @@ -13,7 +13,7 @@ public CommonControl2() string executable = Environment.ProcessPath; string executablePath = Path.GetDirectoryName(executable); - string page = Path.Combine(executablePath, "HTMLPage1.html"); + string page = Path.Join(executablePath, "HTMLPage1.html"); webBrowser1.Url = new Uri($"file://{page}", UriKind.Absolute); } }