dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

`Path.IsPathRooted` documentation is Windows-centric

Open colejohnson66 opened this issue 1 year ago • 1 comments

Many methods in Path have Windows-centric documentation.

For example, Path.IsPathRooted claims that a "rooted" path is one where "[...] the first character is a directory separator character such as "", or if the path starts with a drive letter and colon (:)." This is correct for Windows, but is a lie for Unix-like systems. For those, a simple "first character is a forward slash" check is all that's necessary:

/* 130 */ public static bool IsPathRooted([NotNullWhen(true)] string? path)
/* 131 */ {
/* 132 */     if (path == null)
/* 133 */         return false;
/* 134 */
/* 135 */     return IsPathRooted(path.AsSpan());
/* 136 */ }
/* 137 */
/* 138 */ public static bool IsPathRooted(ReadOnlySpan<char> path)
/* 139 */ {
/* 140 */     return path.Length > 0 && path[0] == PathInternal.DirectorySeparatorChar;
/* 141 */ }

colejohnson66 avatar Feb 29 '24 12:02 colejohnson66

Cross platform documentation would be helpful here.

adamfk avatar Mar 21 '24 16:03 adamfk