dotnet-api-docs
dotnet-api-docs copied to clipboard
`Path.IsPathRooted` documentation is Windows-centric
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 */ }
Cross platform documentation would be helpful here.