diff --git a/src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs b/src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs
index 7a1757a8249ac..2f0c38bfab343 100644
--- a/src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs
+++ b/src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs
@@ -10,14 +10,10 @@
#define DEBUG
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
using System.Threading.Tasks;
-using Xunit;
public static partial class MountHelper
{
@@ -35,77 +31,7 @@ public static partial class MountHelper
// Helper for ConditionalClass attributes
internal static bool IsSubstAvailable => PlatformDetection.IsSubstAvailable;
- ///
- /// In some cases (such as when running without elevated privileges),
- /// the symbolic link may fail to create. Only run this test if it creates
- /// links successfully.
- ///
- internal static bool CanCreateSymbolicLinks => s_canCreateSymbolicLinks.Value;
- private static readonly Lazy s_canCreateSymbolicLinks = new Lazy(() =>
- {
- bool success = true;
-
- // Verify file symlink creation
- string path = Path.GetTempFileName();
- string linkPath = path + ".link";
- success = CreateSymbolicLink(linkPath: linkPath, targetPath: path, isDirectory: false);
- try { File.Delete(path); } catch { }
- try { File.Delete(linkPath); } catch { }
-
- // Verify directory symlink creation
- path = Path.GetTempFileName();
- linkPath = path + ".link";
- success = success && CreateSymbolicLink(linkPath: linkPath, targetPath: path, isDirectory: true);
- try { Directory.Delete(path); } catch { }
- try { Directory.Delete(linkPath); } catch { }
-
- // Reduce the risk we accidentally stop running these altogether
- // on Windows, due to a bug in CreateSymbolicLink
- if (!success && PlatformDetection.IsWindows)
- Assert.True(!PlatformDetection.IsWindowsAndElevated);
-
- return success;
- });
-
- /// Creates a symbolic link using command line tools.
- public static bool CreateSymbolicLink(string linkPath, string targetPath, bool isDirectory)
- {
- // It's easy to get the parameters backwards.
- Assert.EndsWith(".link", linkPath);
- if (linkPath != targetPath) // testing loop
- Assert.False(targetPath.EndsWith(".link"), $"{targetPath} should not end with .link");
-
-#if NETFRAMEWORK
- bool isWindows = true;
-#else
- if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsBrowser()) // OSes that don't support Process.Start()
- {
- return false;
- }
-
- bool isWindows = OperatingSystem.IsWindows();
-#endif
- Process symLinkProcess = new Process();
- if (isWindows)
- {
- symLinkProcess.StartInfo.FileName = "cmd";
- symLinkProcess.StartInfo.Arguments = string.Format("/c mklink{0} \"{1}\" \"{2}\"", isDirectory ? " /D" : "", linkPath, targetPath);
- }
- else
- {
- symLinkProcess.StartInfo.FileName = "/bin/ln";
- symLinkProcess.StartInfo.Arguments = string.Format("-s \"{0}\" \"{1}\"", targetPath, linkPath);
- }
- symLinkProcess.StartInfo.UseShellExecute = false;
- symLinkProcess.StartInfo.RedirectStandardOutput = true;
-
- symLinkProcess.Start();
-
- symLinkProcess.WaitForExit();
-
- return (symLinkProcess.ExitCode == 0);
- }
/// On Windows, creates a junction using command line tools.
public static bool CreateJunction(string junctionPath, string targetPath)
diff --git a/src/libraries/Common/tests/System/IO/SymbolicLinkHelper.cs b/src/libraries/Common/tests/System/IO/SymbolicLinkHelper.cs
new file mode 100644
index 0000000000000..c36552889e62d
--- /dev/null
+++ b/src/libraries/Common/tests/System/IO/SymbolicLinkHelper.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using Xunit;
+
+public static class SymbolicLinkHelper
+{
+ ///
+ /// In some cases (such as when running without elevated privileges),
+ /// the symbolic link may fail to create. Only run this test if it creates
+ /// links successfully.
+ ///
+ internal static bool CanCreateSymbolicLinks => s_canCreateSymbolicLinks.Value;
+
+ private static readonly Lazy s_canCreateSymbolicLinks = new Lazy(() =>
+ {
+ bool success = true;
+
+ // Verify file symlink creation
+ string path = Path.GetTempFileName();
+ string linkPath = path + ".link";
+ success = CreateSymbolicLink(linkPath: linkPath, targetPath: path, isDirectory: false);
+ try { File.Delete(path); } catch { }
+ try { File.Delete(linkPath); } catch { }
+
+ // Verify directory symlink creation
+ path = Path.GetTempFileName();
+ linkPath = path + ".link";
+ success = success && CreateSymbolicLink(linkPath: linkPath, targetPath: path, isDirectory: true);
+ try { Directory.Delete(path); } catch { }
+ try { Directory.Delete(linkPath); } catch { }
+
+ // Reduce the risk we accidentally stop running these altogether
+ // on Windows, due to a bug in CreateSymbolicLink
+ if (!success && PlatformDetection.IsWindows)
+ Assert.True(!PlatformDetection.IsWindowsAndElevated);
+
+ return success;
+ });
+
+ /// Creates a symbolic link using command line tools.
+ public static bool CreateSymbolicLink(string linkPath, string targetPath, bool isDirectory)
+ {
+ // It's easy to get the parameters backwards.
+ Assert.EndsWith(".link", linkPath);
+ if (linkPath != targetPath) // testing loop
+ Assert.False(targetPath.EndsWith(".link"), $"{targetPath} should not end with .link");
+
+ if (PlatformDetection.IsiOS || PlatformDetection.IstvOS || PlatformDetection.IsMacCatalyst || PlatformDetection.IsBrowser)
+ {
+ return false;
+ }
+
+#if !NETFRAMEWORK
+ try
+ {
+ FileSystemInfo linkInfo = isDirectory ?
+ Directory.CreateSymbolicLink(linkPath, targetPath) : File.CreateSymbolicLink(linkPath, targetPath);
+
+ // Detect silent failures.
+ Assert.True(linkInfo.Exists);
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+#else
+ Process symLinkProcess = new Process();
+
+ symLinkProcess.StartInfo.FileName = "cmd";
+ symLinkProcess.StartInfo.Arguments = $"/c mklink{(isDirectory ? " /D" : "")} \"{linkPath}\" \"{targetPath}\"";
+ symLinkProcess.StartInfo.UseShellExecute = false;
+ symLinkProcess.StartInfo.RedirectStandardOutput = true;
+
+ symLinkProcess.Start();
+
+ symLinkProcess.WaitForExit();
+
+ return (symLinkProcess.ExitCode == 0);
+#endif
+ }
+}
diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
index 67618c7284287..31bf050d8da95 100644
--- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
+++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
@@ -89,7 +89,6 @@ public static partial class PlatformDetection
public static bool IsThreadingSupported => !IsBrowser;
public static bool IsBinaryFormatterSupported => IsNotMobile && !IsNativeAot;
- public static bool IsSymLinkSupported => !IsiOS && !IstvOS;
public static bool IsSpeedOptimized => !IsSizeOptimized;
public static bool IsSizeOptimized => IsBrowser || IsAndroid || IsAppleMobile;
@@ -327,6 +326,8 @@ public static bool IsSubstAvailable
}
}
+ public static bool CanCreateSymbolicLinks => SymbolicLinkHelper.CanCreateSymbolicLinks;
+
private static Version GetICUVersion()
{
int version = 0;
diff --git a/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj b/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
index ad1ab67e89c94..e860fa1e5d852 100644
--- a/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
+++ b/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
@@ -1,4 +1,4 @@
-
+
true
@@ -39,6 +39,8 @@
+
diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs
index 5bb0d9b2c3eb4..f732184324a43 100644
--- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs
+++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs
@@ -94,7 +94,7 @@ public void Extract_LinkEntry_TargetOutsideDirectory(TarEntryType entryType)
Assert.Equal(0, Directory.GetFileSystemEntries(root.Path).Count());
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void Extract_SymbolicLinkEntry_TargetInsideDirectory() => Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType.SymbolicLink);
[Fact]
diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs
index 298509f1c92a4..16b0a055b6649 100644
--- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs
+++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs
@@ -160,7 +160,7 @@ public void Add_Directory(TarFormat format, bool withContents)
}
}
- [ConditionalTheory(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
[InlineData(TarFormat.V7, false)]
[InlineData(TarFormat.V7, true)]
[InlineData(TarFormat.Ustar, false)]
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Changed.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Changed.cs
index bef5def6c97bc..b8dead41395d8 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Changed.cs
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Changed.cs
@@ -57,7 +57,7 @@ public void FileSystemWatcher_Directory_Changed_Nested(bool includeSubdirectorie
}
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void FileSystemWatcher_Directory_Changed_SymLink()
{
string dir = Path.Combine(TestDirectory, "dir");
@@ -68,7 +68,7 @@ public void FileSystemWatcher_Directory_Changed_SymLink()
// Setup the watcher
watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size;
watcher.IncludeSubdirectories = true;
- Assert.True(MountHelper.CreateSymbolicLink(Path.Combine(dir, GetRandomLinkName()), tempDir, true));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(Path.Combine(dir, GetRandomLinkName()), tempDir, true));
Action action = () => File.AppendAllText(file, "longtext");
Action cleanup = () => File.AppendAllText(file, "short");
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Create.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Create.cs
index 023cc679eb32b..0f0fdee5c79ee 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Create.cs
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Create.cs
@@ -81,7 +81,7 @@ public void FileSystemWatcher_Directory_Create_DeepDirectoryStructure()
}
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void FileSystemWatcher_Directory_Create_SymLink()
{
string dir = CreateTestDirectory(TestDirectory, "dir");
@@ -90,7 +90,7 @@ public void FileSystemWatcher_Directory_Create_SymLink()
{
// Make the symlink in our path (to the temp folder) and make sure an event is raised
string symLinkPath = Path.Combine(dir, GetRandomLinkName());
- Action action = () => Assert.True(MountHelper.CreateSymbolicLink(symLinkPath, temp, true));
+ Action action = () => Assert.True(SymbolicLinkHelper.CreateSymbolicLink(symLinkPath, temp, true));
Action cleanup = () => Directory.Delete(symLinkPath);
ExpectEvent(watcher, WatcherChangeTypes.Created, action, cleanup, symLinkPath);
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Delete.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Delete.cs
index a30e355acccf6..d1940072b3be7 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Delete.cs
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Delete.cs
@@ -63,7 +63,7 @@ public void FileSystemWatcher_Directory_Delete_DeepDirectoryStructure()
}
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void FileSystemWatcher_Directory_Delete_SymLink()
{
string dir = CreateTestDirectory(TestDirectory, "dir");
@@ -73,7 +73,7 @@ public void FileSystemWatcher_Directory_Delete_SymLink()
// Make the symlink in our path (to the temp folder) and make sure an event is raised
string symLinkPath = Path.Combine(dir, GetRandomLinkName());
Action action = () => Directory.Delete(symLinkPath);
- Action cleanup = () => Assert.True(MountHelper.CreateSymbolicLink(symLinkPath, tempDir, true));
+ Action cleanup = () => Assert.True(SymbolicLinkHelper.CreateSymbolicLink(symLinkPath, tempDir, true));
cleanup();
ExpectEvent(watcher, WatcherChangeTypes.Deleted, action, cleanup, expectedPath: symLinkPath);
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Changed.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Changed.cs
index 44b41c3778e20..639c6c563fd81 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Changed.cs
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Changed.cs
@@ -59,7 +59,7 @@ public void FileSystemWatcher_File_Changed_DataModification()
}
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void FileSystemWatcher_File_Changed_SymLink()
{
string dir = CreateTestDirectory(TestDirectory, "dir");
@@ -67,7 +67,7 @@ public void FileSystemWatcher_File_Changed_SymLink()
using (var watcher = new FileSystemWatcher(dir, "*"))
{
watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size;
- Assert.True(MountHelper.CreateSymbolicLink(Path.Combine(dir, GetRandomLinkName()), file, false));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(Path.Combine(dir, GetRandomLinkName()), file, false));
Action action = () => File.AppendAllText(file, "longtext");
Action cleanup = () => File.AppendAllText(file, "short");
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Create.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Create.cs
index 5c36caf0a38fd..f2e9b3317d89a 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Create.cs
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Create.cs
@@ -120,7 +120,7 @@ public void FileSystemWatcher_File_Create_DeepDirectoryStructure()
}
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void FileSystemWatcher_File_Create_SymLink()
{
string dir = CreateTestDirectory(TestDirectory, "dir");
@@ -129,7 +129,7 @@ public void FileSystemWatcher_File_Create_SymLink()
{
// Make the symlink in our path (to the temp file) and make sure an event is raised
string symLinkPath = Path.Combine(dir, GetRandomLinkName());
- Action action = () => Assert.True(MountHelper.CreateSymbolicLink(symLinkPath, temp, false));
+ Action action = () => Assert.True(SymbolicLinkHelper.CreateSymbolicLink(symLinkPath, temp, false));
Action cleanup = () => File.Delete(symLinkPath);
ExpectEvent(watcher, WatcherChangeTypes.Created, action, cleanup, symLinkPath);
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Delete.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Delete.cs
index ac076e4fd2202..5dab04336f355 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Delete.cs
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Delete.cs
@@ -84,7 +84,7 @@ public void FileSystemWatcher_File_Delete_DeepDirectoryStructure()
}
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void FileSystemWatcher_File_Delete_SymLink()
{
FileSystemWatcherTest.Execute(() =>
@@ -96,7 +96,7 @@ public void FileSystemWatcher_File_Delete_SymLink()
// Make the symlink in our path (to the temp file) and make sure an event is raised
string symLinkPath = Path.Combine(dir, GetRandomLinkName());
Action action = () => File.Delete(symLinkPath);
- Action cleanup = () => Assert.True(MountHelper.CreateSymbolicLink(symLinkPath, temp, false));
+ Action cleanup = () => Assert.True(SymbolicLinkHelper.CreateSymbolicLink(symLinkPath, temp, false));
cleanup();
ExpectEvent(watcher, WatcherChangeTypes.Deleted, action, cleanup, symLinkPath);
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs
index 0bf1d6c6f24e0..7a9e16633c119 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.SymbolicLink.cs
@@ -7,13 +7,13 @@
namespace System.IO.Tests
{
- [ConditionalClass(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public class SymbolicLink_Changed_Tests : FileSystemWatcherTest
{
private string CreateSymbolicLinkToTarget(string targetPath, bool isDirectory, string linkPath = null)
{
linkPath ??= GetRandomLinkPath();
- Assert.True(MountHelper.CreateSymbolicLink(linkPath, targetPath, isDirectory));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(linkPath, targetPath, isDirectory));
return linkPath;
}
diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj b/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj
index 1246c914ab81d..151d728003470 100644
--- a/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj
+++ b/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj
@@ -37,8 +37,6 @@
Link="Common\System\IO\TempFile.cs" />
-
(() => Delete(Directory.GetCurrentDirectory()));
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void DeletingSymLinkDoesntDeleteTarget()
{
var path = GetTestFilePath();
var linkPath = GetRandomLinkPath();
Directory.CreateDirectory(path);
- Assert.True(MountHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
// Both the symlink and the target exist
Assert.True(Directory.Exists(path), "path should exist");
@@ -294,7 +294,7 @@ public void RecursiveDelete_ShouldThrowIOExceptionIfContainedFileInUse()
Assert.True(testDir.Exists);
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void RecursiveDeletingDoesntFollowLinks()
{
var target = GetTestFilePath();
diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs
index b5daf1323139b..f5e92f6861779 100644
--- a/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs
+++ b/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs
@@ -95,14 +95,14 @@ public void DirectoryLongerThanMaxLongPath_DoesntThrow()
});
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void SymLinksMayExistIndependentlyOfTarget()
{
var path = GetTestFilePath();
var linkPath = GetRandomLinkPath();
Directory.CreateDirectory(path);
- Assert.True(MountHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
// Both the symlink and the target exist
Assert.True(Directory.Exists(path), "path should exist");
@@ -142,14 +142,14 @@ public void SymLinksMayExistIndependentlyOfTarget()
Assert.False(File.Exists(linkPath), "linkPath should no longer exist as a file");
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void SymlinkToNewDirectory()
{
string path = GetTestFilePath();
Directory.CreateDirectory(path);
string linkPath = GetRandomLinkPath();
- Assert.True(MountHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
Assert.True(Directory.Exists(path));
Assert.True(Directory.Exists(linkPath));
diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/GetDirectories.cs b/src/libraries/System.IO.FileSystem/tests/Directory/GetDirectories.cs
index ef370ff5bd6f6..be629a57d403a 100644
--- a/src/libraries/System.IO.FileSystem/tests/Directory/GetDirectories.cs
+++ b/src/libraries/System.IO.FileSystem/tests/Directory/GetDirectories.cs
@@ -16,7 +16,7 @@ public override string[] GetEntries(string path)
return Directory.GetDirectories(path);
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void EnumerateWithSymLinkToDirectory()
{
DirectoryInfo containingFolder = Directory.CreateDirectory(GetTestFilePath());
@@ -26,7 +26,7 @@ public void EnumerateWithSymLinkToDirectory()
{
// Create a symlink to a folder that exists
string linkPath = Path.Combine(containingFolder.FullName, GetRandomLinkName());
- Assert.True(MountHelper.CreateSymbolicLink(linkPath, targetDir.FullName, isDirectory: true));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(linkPath, targetDir.FullName, isDirectory: true));
Assert.True(Directory.Exists(linkPath));
Assert.Equal(1, GetEntries(containingFolder.FullName).Count());
diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/GetFiles.cs b/src/libraries/System.IO.FileSystem/tests/Directory/GetFiles.cs
index f214f08899bcd..cd9c33a9a101a 100644
--- a/src/libraries/System.IO.FileSystem/tests/Directory/GetFiles.cs
+++ b/src/libraries/System.IO.FileSystem/tests/Directory/GetFiles.cs
@@ -16,7 +16,7 @@ public override string[] GetEntries(string path)
return Directory.GetFiles(path);
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void EnumerateWithSymLinkToFile()
{
DirectoryInfo containingFolder = Directory.CreateDirectory(GetTestFilePath());
@@ -26,7 +26,7 @@ public void EnumerateWithSymLinkToFile()
targetFile.Create().Dispose();
string linkPath = Path.Combine(containingFolder.FullName, GetRandomLinkName());
- Assert.True(MountHelper.CreateSymbolicLink(linkPath, targetFile.FullName, isDirectory: false));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(linkPath, targetFile.FullName, isDirectory: false));
Assert.True(File.Exists(linkPath));
Assert.Equal(1, GetEntries(containingFolder.FullName).Count());
diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/SetCurrentDirectory.cs b/src/libraries/System.IO.FileSystem/tests/Directory/SetCurrentDirectory.cs
index ce3339efed2a9..bcfddefc7663d 100644
--- a/src/libraries/System.IO.FileSystem/tests/Directory/SetCurrentDirectory.cs
+++ b/src/libraries/System.IO.FileSystem/tests/Directory/SetCurrentDirectory.cs
@@ -47,7 +47,7 @@ public void SetToValidOtherDirectory()
public sealed class Directory_SetCurrentDirectory_SymLink : FileSystemTest
{
- private static bool CanCreateSymbolicLinksAndRemoteExecutorSupported => MountHelper.CanCreateSymbolicLinks && RemoteExecutor.IsSupported;
+ private static bool CanCreateSymbolicLinksAndRemoteExecutorSupported => PlatformDetection.CanCreateSymbolicLinks && RemoteExecutor.IsSupported;
[ConditionalFact(nameof(CanCreateSymbolicLinksAndRemoteExecutorSupported))]
public void SetToPathContainingSymLink()
@@ -58,7 +58,7 @@ public void SetToPathContainingSymLink()
var linkPath = GetRandomLinkPath();
Directory.CreateDirectory(path);
- Assert.True(MountHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
// Both the symlink and the target exist
Assert.True(Directory.Exists(path), "path should exist");
diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/SymbolicLinks.cs b/src/libraries/System.IO.FileSystem/tests/Directory/SymbolicLinks.cs
index 1052ddfc22b9b..3b5c1dbfb1855 100644
--- a/src/libraries/System.IO.FileSystem/tests/Directory/SymbolicLinks.cs
+++ b/src/libraries/System.IO.FileSystem/tests/Directory/SymbolicLinks.cs
@@ -7,7 +7,7 @@
namespace System.IO.Tests
{
- [ConditionalClass(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public class Directory_SymbolicLinks : BaseSymbolicLinks_FileSystem
{
protected override bool IsDirectoryTest => true;
diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs
index d0f3d095d2da0..e01004e3d2735 100644
--- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs
+++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs
@@ -118,20 +118,20 @@ public void FalseForNonRegularFile()
Assert.False(di.Exists);
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void SymlinkToNewDirectoryInfo()
{
string path = GetTestFilePath();
new DirectoryInfo(path).Create();
string linkPath = GetRandomLinkPath();
- Assert.True(MountHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
Assert.True(new DirectoryInfo(path).Exists);
Assert.True(new DirectoryInfo(linkPath).Exists);
}
- [ConditionalFact(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public void SymLinksMayExistIndependentlyOfTarget()
{
var path = GetTestFilePath();
@@ -141,7 +141,7 @@ public void SymLinksMayExistIndependentlyOfTarget()
var linkPathFI = new DirectoryInfo(linkPath);
pathFI.Create();
- Assert.True(MountHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
+ Assert.True(SymbolicLinkHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));
// Both the symlink and the target exist
pathFI.Refresh();
diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/SymbolicLinks.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/SymbolicLinks.cs
index 254c00df40133..4cf6d60d6c20e 100644
--- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/SymbolicLinks.cs
+++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/SymbolicLinks.cs
@@ -7,7 +7,7 @@
namespace System.IO.Tests
{
- [ConditionalClass(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.CanCreateSymbolicLinks))]
public class DirectoryInfo_SymbolicLinks : BaseSymbolicLinks_FileSystemInfo
{
protected override bool IsDirectoryTest => true;
diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/AttributeTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/AttributeTests.cs
index a27fb3c87464a..e9e85a6e8a17c 100644
--- a/src/libraries/System.IO.FileSystem/tests/Enumeration/AttributeTests.cs
+++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/AttributeTests.cs
@@ -64,7 +64,7 @@ public static IEnumerable