dotnet / dotnet/dotnet-api-docs

UriComponents.Path documentation implies LocalPath is always returned, but this is only true for file:// URIs

Open Beginner friendly
#13,039 1 comment 0 reactions 0 assignees View on GitHub
untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### Type of issue

Missing information

### Description

`UriComponents.Path` documentation implies `LocalPath` is always returned, but this is only true for `file://` URIs`

The documentation for `UriComponents.Path` currently says:

> **Path**: The `LocalPath` data.

This wording suggests (by omission) that `LocalPath` is always returned, regardless of URI scheme.
However, this is only true for `file://` URIs.
For all non-file URIs (e.g., `http://`, `https://`, `ftp://`), `UriComponents.Path` returns the **URL path**, not `LocalPath`.

This leads to incorrect expectations about path formatting, especially regarding Windows-style backslashes.

Below is a minimal reproducible example demonstrating the actual behavior.

## Reproduction Code

```csharp
var http = new Uri("https://example.com/a/b/c.txt");
var file = new Uri("file://server/share/c.txt");

Console.WriteLine(http.GetComponents(UriComponents.Path, UriFormat.Unescaped));
Console.WriteLine(http.LocalPath);

Console.WriteLine(file.GetComponents(UriComponents.Path, UriFormat.Unescaped));
Console.WriteLine(file.LocalPath);

// The example displays the following output:
// a/b/c.txt
// /a/b/c.txt
// share/c.txt
// \\server\share\c.txt
```

### Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.uricomponents?view=net-10.0

### Content source URL

https://github.com/dotnet/dotnet-api-docs-temp/blob/live/xml/System/UriComponents.xml

### Document Version Independent Id

3d232e61-f2cd-8a85-f974-beb7ecade43c

### Platform Id

be57ca08-cf67-4666-bdce-208a89903395

### Article author

@dotnet-bot

Contributor guide

Open the contributing guide

Research direction

Open the UriComponents.xml source linked in the issue and locate the Path description. Compare its wording with the provided file:// and https:// examples, then update the documentation so the behavior for file and non-file URIs is clear. Confirm the generated API page reflects the corrected distinction.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.