DriveFormat returns null on WSL (dotnet/corefx#32372)
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>
Thu, 20 Sep 2018 22:56:01 +0000 (15:56 -0700)
committerGitHub <noreply@github.com>
Thu, 20 Sep 2018 22:56:01 +0000 (15:56 -0700)
* added default value for isHFS

* using and operator

Commit migrated from https://github.com/dotnet/corefx/commit/3a206a056f765b4d0df02e5d0ff6d0f7bdfe23c2

src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs

index eb7a5d0..717cb9f 100644 (file)
@@ -16,7 +16,7 @@ namespace System.IO.Tests
         // AppContainer restricts access to DriveFormat (::GetVolumeInformation)
         private static string driveFormat = PlatformDetection.IsInAppContainer ? string.Empty : new DriveInfo(Path.GetTempPath()).DriveFormat;
 
-        protected static bool isHFS => driveFormat.Equals(HFS, StringComparison.InvariantCultureIgnoreCase);
+        protected static bool isHFS => driveFormat != null && driveFormat.Equals(HFS, StringComparison.InvariantCultureIgnoreCase);
         protected static bool isNotHFS => !isHFS;
 
         public abstract T GetExistingItem();