Skip to content

Commit

Permalink
Merge branch 'main' into topic/add-gettempfilename
Browse files Browse the repository at this point in the history
  • Loading branch information
vbreuss authored Apr 20, 2024
2 parents 4aecdaf + 066fb69 commit a3c8fab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,15 @@ public bool HasExtension(ReadOnlySpan<char> path)

/// <inheritdoc cref="IPath.HasExtension(string)" />
public bool HasExtension([NotNullWhen(true)] string? path)
=> System.IO.Path.HasExtension(path);
{
if (path == null)
{
return false;
}

return TryGetExtensionIndex(path, out var dotIndex)
&& dotIndex < path.Length - 1;
}

#if FEATURE_SPAN
/// <inheritdoc cref="IPath.IsPathFullyQualified(ReadOnlySpan{char})" />
Expand Down Expand Up @@ -405,7 +413,11 @@ public ReadOnlySpan<char> TrimEndingDirectorySeparator(ReadOnlySpan<char> path)
#if FEATURE_PATH_ADVANCED
/// <inheritdoc cref="IPath.TrimEndingDirectorySeparator(string)" />
public string TrimEndingDirectorySeparator(string path)
=> System.IO.Path.TrimEndingDirectorySeparator(path);
{
return EndsInDirectorySeparator(path) && path.Length != GetRootLength(path)
? path.Substring(0, path.Length - 1)
: path;
}
#endif

#if FEATURE_PATH_JOIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,11 @@ private bool IncludeSimulatedTests(ClassModel @class)
"GetRandomFileNameTests",
"GetTempFileNameTests",
"GetTempPathTests",
"HasExtensionTests",
"IsPathRootedTests",
"JoinTests",
"Tests",
"TrimEndingDirectorySeparatorTests",
"TryJoinTests"
];
return @class.Namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void HasExtension_Null_ShouldReturnFalse()
}

[SkippableTheory]
[InlineAutoData("abc.", false)]
[InlineAutoData(".foo", true)]
[InlineAutoData(".abc.xyz", true)]
[InlineAutoData("foo", false)]
Expand All @@ -30,6 +31,7 @@ public void HasExtension_ShouldReturnExpectedResult(

#if FEATURE_SPAN
[SkippableTheory]
[InlineAutoData("abc.", false)]
[InlineAutoData(".foo", true)]
[InlineAutoData(".abc.xyz", true)]
[InlineAutoData("foo", false)]
Expand Down

0 comments on commit a3c8fab

Please sign in to comment.