@@ -36,11 +36,20 @@ public static void ChangeExtension(string path, string newExtension, string expe
3636 }
3737
3838 [ Fact ]
39- public static void GetDirectoryName_EmptyThrows ( )
39+ [ SkipOnTargetFramework ( ~ TargetFrameworkMonikers . NetFramework ) ]
40+ public static void GetDirectoryName_EmptyThrows_Desktop ( )
4041 {
4142 AssertExtensions . Throws < ArgumentException > ( "path" , null , ( ) => Path . GetDirectoryName ( string . Empty ) ) ;
4243 }
4344
45+ [ Fact ]
46+ [ ActiveIssue ( 27269 ) ]
47+ [ SkipOnTargetFramework ( TargetFrameworkMonikers . NetFramework ) ]
48+ public static void GetDirectoryName_Empty_Core ( )
49+ {
50+ Assert . Null ( Path . GetDirectoryName ( string . Empty ) ) ;
51+ }
52+
4453 [ Theory ,
4554 InlineData ( " " ) ,
4655 InlineData ( "\r \n " ) ]
@@ -60,19 +69,10 @@ public static void GetDirectoryName_SpaceOrControlCharsThrowOnWindows(string pat
6069 }
6170
6271 [ Fact ]
63- public static void GetDirectoryName_SpaceThrowOnWindows_Core ( )
72+ [ ActiveIssue ( 27269 ) ]
73+ public static void GetDirectoryName_Space_Core ( )
6474 {
65- string path = " " ;
66- Action action = ( ) => Path . GetDirectoryName ( path ) ;
67- if ( PlatformDetection . IsWindows )
68- {
69- AssertExtensions . Throws < ArgumentException > ( "path" , null , ( ) => Path . GetDirectoryName ( path ) ) ;
70- }
71- else
72- {
73- // This is a valid path on Unix
74- action ( ) ;
75- }
75+ Assert . Null ( Path . GetDirectoryName ( " " ) ) ;
7676 }
7777
7878 public static TheoryData < string > GetDirectoryName_NonControl_Test_Data => new TheoryData < string >
@@ -116,14 +116,17 @@ public static void GetDirectoryName(string path, string expected)
116116 { @"..\..\files.txt" , @"..\.." } ,
117117 { @"C:\" , null } ,
118118 { @"C:" , null } ,
119+ // { @"dir\\baz", "dir" }, https://github.com/dotnet/corefx/issues/27269
120+ { @"C:\foo" , @"C:\" } ,
121+ { @"\foo" , @"\" } ,
122+ { @"C:foo" , @"C:" }
119123 } ;
120124
121125 public static TheoryData < string , string > GetDirectoryName_Windows_string_Test_Data => new TheoryData < string , string >
122126 {
123- { @" C:\dir\baz" , @"C:\dir" } ,
124- { @"dir\\baz" , "dir" } ,
127+ // { @" C:\dir\baz", @"C:\dir" }, https://github.com/dotnet/corefx/issues/27269
125128 { @" dir\baz" , " dir" } ,
126- { @" C:\dir\baz" , @"C:\dir" } ,
129+ // { @" C:\dir\baz", @"C:\dir" }, https://github.com/dotnet/corefx/issues/27269
127130 } ;
128131
129132 [ PlatformSpecific ( TestPlatforms . Windows ) ] // Tests Windows-specific paths
@@ -133,6 +136,19 @@ public static void GetDirectoryName_Windows(string path, string expected)
133136 Assert . Equal ( expected , Path . GetDirectoryName ( path ) ) ;
134137 }
135138
139+ [ PlatformSpecific ( TestPlatforms . Windows ) ]
140+ public static void GetDirectoryName_WindowsDevicePath ( )
141+ {
142+ if ( PathFeatures . IsUsingLegacyPathNormalization ( ) )
143+ {
144+ Assert . Equal ( @"\\?\C:" , Path . GetDirectoryName ( @"\\?\C:\foo" ) ) ;
145+ }
146+ else
147+ {
148+ Assert . Equal ( @"\\?\C:\" , Path . GetDirectoryName ( @"\\?\C:\foo" ) ) ;
149+ }
150+ }
151+
136152 public static TheoryData < string , string > GetDirectoryName_Unix_Test_Data => new TheoryData < string , string >
137153 {
138154 { @"dir/baz" , @"dir" } ,
@@ -284,11 +300,20 @@ public static void GetPathRoot_NullReturnsNull()
284300 }
285301
286302 [ Fact ]
287- public static void GetPathRoot_EmptyThrows ( )
303+ [ SkipOnTargetFramework ( ~ TargetFrameworkMonikers . NetFramework ) ]
304+ public static void GetPathRoot_EmptyThrows_Desktop ( )
288305 {
289306 AssertExtensions . Throws < ArgumentException > ( "path" , null , ( ) => Path . GetPathRoot ( string . Empty ) ) ;
290307 }
291308
309+ [ Fact ]
310+ [ ActiveIssue ( 27269 ) ]
311+ [ SkipOnTargetFramework ( ~ TargetFrameworkMonikers . NetFramework ) ]
312+ public static void GetPathRoot_EmptyIsNull_Core ( )
313+ {
314+ Assert . Null ( Path . GetPathRoot ( string . Empty ) ) ;
315+ }
316+
292317 [ Fact ]
293318 public static void GetPathRoot_Basic ( )
294319 {
@@ -887,7 +912,6 @@ public static void GetFullPath_Windows_ValidLegacy_ValidExtendedPaths(string pat
887912 // https://github.com/dotnet/corefx/issues/11965
888913 [ InlineData ( @"\\LOCALHOST\share\test.txt.~SS" , @"\\LOCALHOST\share\test.txt.~SS" ) ]
889914 [ InlineData ( @"\\LOCALHOST\share1" , @"\\LOCALHOST\share1" ) ]
890- [ InlineData ( @"\\LOCALHOST\share2" , @" \\LOCALHOST\share2" ) ]
891915 [ InlineData ( @"\\LOCALHOST\share3\dir" , @"\\LOCALHOST\share3\dir" ) ]
892916 [ InlineData ( @"\\LOCALHOST\share4" , @"\\LOCALHOST\share4\." ) ]
893917 [ InlineData ( @"\\LOCALHOST\share5" , @"\\LOCALHOST\share5\.." ) ]
0 commit comments