File tree 3 files changed +18
-2
lines changed
Source/Testably.Abstractions.Testing/Helpers
Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators
Testably.Abstractions.Tests/FileSystem/Path
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,15 @@ public bool HasExtension(ReadOnlySpan<char> path)
319
319
320
320
/// <inheritdoc cref="IPath.HasExtension(string)" />
321
321
public bool HasExtension ( [ NotNullWhen ( true ) ] string ? path )
322
- => System . IO . Path . HasExtension ( path ) ;
322
+ {
323
+ if ( path == null )
324
+ {
325
+ return false ;
326
+ }
327
+
328
+ return TryGetExtensionIndex ( path , out var dotIndex )
329
+ && dotIndex < path . Length - 1 ;
330
+ }
323
331
324
332
#if FEATURE_SPAN
325
333
/// <inheritdoc cref="IPath.IsPathFullyQualified(ReadOnlySpan{char})" />
@@ -406,7 +414,11 @@ public ReadOnlySpan<char> TrimEndingDirectorySeparator(ReadOnlySpan<char> path)
406
414
#if FEATURE_PATH_ADVANCED
407
415
/// <inheritdoc cref="IPath.TrimEndingDirectorySeparator(string)" />
408
416
public string TrimEndingDirectorySeparator ( string path )
409
- => System . IO . Path . TrimEndingDirectorySeparator ( path ) ;
417
+ {
418
+ return EndsInDirectorySeparator ( path ) && path . Length != GetRootLength ( path )
419
+ ? path . Substring ( 0 , path . Length - 1 )
420
+ : path ;
421
+ }
410
422
#endif
411
423
412
424
#if FEATURE_PATH_JOIN
Original file line number Diff line number Diff line change @@ -273,9 +273,11 @@ private bool IncludeSimulatedTests(ClassModel @class)
273
273
"GetPathRootTests" ,
274
274
"GetRandomFileNameTests" ,
275
275
"GetTempPathTests" ,
276
+ "HasExtensionTests" ,
276
277
"IsPathRootedTests" ,
277
278
"JoinTests" ,
278
279
"Tests" ,
280
+ "TrimEndingDirectorySeparatorTests" ,
279
281
"TryJoinTests"
280
282
] ;
281
283
return @class . Namespace
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ public void HasExtension_Null_ShouldReturnFalse()
14
14
}
15
15
16
16
[ SkippableTheory ]
17
+ [ InlineAutoData ( "abc." , false ) ]
17
18
[ InlineAutoData ( ".foo" , true ) ]
18
19
[ InlineAutoData ( ".abc.xyz" , true ) ]
19
20
[ InlineAutoData ( "foo" , false ) ]
@@ -30,6 +31,7 @@ public void HasExtension_ShouldReturnExpectedResult(
30
31
31
32
#if FEATURE_SPAN
32
33
[ SkippableTheory ]
34
+ [ InlineAutoData ( "abc." , false ) ]
33
35
[ InlineAutoData ( ".foo" , true ) ]
34
36
[ InlineAutoData ( ".abc.xyz" , true ) ]
35
37
[ InlineAutoData ( "foo" , false ) ]
You can’t perform that action at this time.
0 commit comments