Skip to content

Commit

Permalink
dotnet#51371 removed extra spaces, adjusted IsCaseSensitiveProperty a…
Browse files Browse the repository at this point in the history
…nd other review comments changes
  • Loading branch information
mkhamoyan committed Jan 20, 2022
1 parent 69ea51e commit 8696973
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ protected static bool Bidirectional(StreamPair streams) =>
streams.Stream1.CanRead && streams.Stream1.CanWrite &&
streams.Stream2.CanRead && streams.Stream2.CanWrite;

[Fact]
[Fact]
public virtual async Task ArgumentValidation_ThrowsExpectedException()
{
using StreamPair streams = await CreateConnectedStreamsAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract partial class FileCleanupTestBase : IDisposable
/// <summary>Initialize the test class base. This creates the associated test directory.</summary>
protected FileCleanupTestBase(string tempDirectory = null)
{
tempDirectory ??= PlatformDetection.IsNotRunningOnMacOS ? Path.GetTempPath() : "/tmp/";
tempDirectory ??= PlatformDetection.IsCaseSensitiveOS ? Path.GetTempPath() : "/tmp/";

// Use a unique test directory per test class. The test directory lives in the user's temp directory,
// and includes both the name of the test class and a random string. The test class name is included
Expand Down Expand Up @@ -108,7 +108,8 @@ protected string GetTestFileName(int? index = null, [CallerMemberName] string me

const int maxLength = 260 - 5; // Windows MAX_PATH minus a bit

int excessLength = testFilePath.Length - maxLength;
int excessLength = testFilePath.Length - maxLength;

if (excessLength > 0)
{
// The path will be too long for Windows -- can we
Expand Down Expand Up @@ -141,7 +142,7 @@ protected static string GetNamedPipeServerStreamName()
return @"LOCAL\" + Guid.NewGuid().ToString("N");
}

if (PlatformDetection.IsWindows || !PlatformDetection.IsNotRunningOnMacOS)
if (PlatformDetection.IsWindows || !PlatformDetection.IsCaseSensitiveOS)
{
return Guid.NewGuid().ToString("N");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public static partial class PlatformDetection
public static bool IsNotWindows => !IsWindows;

public static bool IsCaseInsensitiveOS => IsWindows || IsOSX || IsMacCatalyst;
public static bool IsCaseSensitiveOS => !IsCaseInsensitiveOS;
public static bool IsCaseSensitiveOS => !IsCaseInsensitiveOS && !RuntimeInformation.RuntimeIdentifier.StartsWith("iossimulator")
&& !RuntimeInformation.RuntimeIdentifier.StartsWith("tvossimulator");

public static bool IsThreadingSupported => !IsBrowser;
public static bool IsBinaryFormatterSupported => IsNotMobile && !IsNativeAot;
Expand All @@ -77,8 +78,6 @@ public static partial class PlatformDetection

public static bool IsUsingLimitedCultures => !IsNotMobile;
public static bool IsNotUsingLimitedCultures => IsNotMobile;
public static bool IsNotRunningOnMacOS => !RuntimeInformation.RuntimeIdentifier.StartsWith("iossimulator")
&& !RuntimeInformation.RuntimeIdentifier.StartsWith("tvossimulator") && !IsMacCatalyst;

public static bool IsLinqExpressionsBuiltWithIsInterpretingOnly => s_LinqExpressionsBuiltWithIsInterpretingOnly.Value;
public static bool IsNotLinqExpressionsBuiltWithIsInterpretingOnly => !IsLinqExpressionsBuiltWithIsInterpretingOnly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void SettingInvalidAttributes_Unix(FileAttributes attributes)
AssertSettingInvalidAttributes(path, attributes);
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotRunningOnMacOS))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsCaseSensitiveOS))]
[InlineData(FileAttributes.Hidden)]
[PlatformSpecific(TestPlatforms.AnyUnix & ~(TestPlatforms.OSX | TestPlatforms.FreeBSD))]
public void SettingInvalidAttributes_UnixExceptOSXAndFreeBSD(FileAttributes attributes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,9 @@ public void WindowsSearchPatternWhitespace()
Assert.Empty(GetEntries(TestDirectory, "\t"));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotRunningOnMacOS))]
[PlatformSpecific(CaseSensitivePlatforms)]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsCaseSensitiveOS))]
public void SearchPatternCaseSensitive()
{
{
DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
string testBase = GetTestFileName();
testDir.CreateSubdirectory(testBase + "aBBb");
Expand Down
3 changes: 1 addition & 2 deletions src/libraries/System.IO.FileSystem/tests/File/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ public void LongFileName()
Assert.False(File.Exists(path));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotRunningOnMacOS))]
[PlatformSpecific(CaseSensitivePlatforms)]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsCaseSensitiveOS))]
public void CaseSensitive()
{
DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.IO.FileSystem/tests/File/Exists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void PathAlreadyExistsAsDirectory()
}

[Fact]
public void DirectoryLongerThanMaxDirectoryAsPath_DoesntThrow()
public void DirectoryLongerThanMaxDirectoryAsPath_DoesntThrow()
{
Assert.All((IOInputs.GetPathsLongerThanMaxDirectory(GetTestFilePath())), (path) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,7 @@ public NamedPipeClientStream(string serverName, string pipeName, PipeDirection d
{
IsCurrentUserOnly = true;
}
if (RuntimeInformation.RuntimeIdentifier.StartsWith("iossimulator")
|| RuntimeInformation.RuntimeIdentifier.StartsWith("tvossimulator"))
{
_normalizedPipePath = $"/tmp/{pipeName}";
}
else
{
_normalizedPipePath = GetPipePath(serverName, pipeName);
}
_normalizedPipePath = GetPipePath(serverName, pipeName);
_direction = direction;
_inheritability = inheritability;
_impersonationLevel = impersonationLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ private void Create(string pipeName, PipeDirection direction, int maxNumberOfSer
// We don't have a good way to enforce maxNumberOfServerInstances across processes; we only factor it in
// for streams created in this process. Between processes, we behave similarly to maxNumberOfServerInstances == 1,
// in that the second process to come along and create a stream will find the pipe already in existence and will fail.
var pipePath = !RuntimeInformation.RuntimeIdentifier.StartsWith("iossimulator")
&& !RuntimeInformation.RuntimeIdentifier.StartsWith("tvossimulator") ? GetPipePath(".", pipeName) : $"/tmp/{pipeName}";
_instance = SharedServer.Get(
pipePath,
GetPipePath(".", pipeName),
(maxNumberOfServerInstances == MaxAllowedServerInstances) ? int.MaxValue : maxNumberOfServerInstances);

_direction = direction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ internal static string GetPipePath(string serverName, string pipeName)
throw new ArgumentOutOfRangeException(nameof(pipeName), SR.ArgumentOutOfRange_AnonymousReserved);
}

if (RuntimeInformation.RuntimeIdentifier.StartsWith("iossimulator")
|| RuntimeInformation.RuntimeIdentifier.StartsWith("tvossimulator"))
{
return $"/tmp/{pipeName}";
}

// Since pipes are stored as files in the system we support either an absolute path to a file name
// or a file name. The support of absolute path was added to allow working around the limited
// length available for the pipe name when concatenated with the temp path, while being
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ public override void EndWrite(IAsyncResult asyncResult)

internal static string GetPipePath(string serverName, string pipeName)
{
if (RuntimeInformation.RuntimeIdentifier.StartsWith("iossimulator")
|| RuntimeInformation.RuntimeIdentifier.StartsWith("tvossimulator"))
{
return $"/tmp/{pipeName}";
}

string normalizedPipePath = Path.GetFullPath(@"\\" + serverName + @"\pipe\" + pipeName);
if (string.Equals(normalizedPipePath, @"\\.\pipe\" + AnonymousPipeName, StringComparison.OrdinalIgnoreCase))
{
Expand Down

0 comments on commit 8696973

Please sign in to comment.