runtime: SpecialFolder.MyDocuments / Personal returning wrong path for Unix
Description
Using Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) (and by extensions also SpecialFolder.Personal) on Unix based systems does not return the documents folder, and instead returns the same path as Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).
Reproduction Steps
Console.WriteLine("Environment.SpecialFolder.MyDocuments:");
Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
Console.WriteLine("Environment.SpecialFolder.UserProfile:");
Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
Expected behavior
Since Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) should return the directory that serves as a common repository for documents, it should report the directory I have set via xdg-users-dir / XDG_DOCUMENTS_DIR or ~/Documents on Mac.
Actual behavior
It reports my home directory instead.
Comparison between Linux and Windows:

Checking this it seems that it’s intentional. Why doesn’t it just use ReadXdgDirectory(home, "XDG_DOCUMENTS_DIR", "Documents"); there? I can do a PR if it’s wished for.
Regression?
No response
Known Workarounds
No response
Configuration
Dotnet version: 6.0.101 Can reproduce on the following distros: Arch Linux WSL2, Ubuntu 20.04 WSL2, Arch Linux, macOS Big Sur Architecture: x64
Other information
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 18 (15 by maintainers)
Commits related to this issue
- Fix incorrect SpecialFolder entries for Unix This fixes an incorrect Documents/Personal for Linux+Mac entry, incorrect Videos Mac entry, and an incorrect (Local) ApplicationData Mac entry. Fix... — committed to Miepee/runtime by Miepee 2 years ago
- Fix incorrect SpecialFolder entries for Unix This fixes an incorrect Documents/Personal for Linux+Mac entry, incorrect Videos Mac entry, and an incorrect (Local) ApplicationData Mac entry. Fix #6321... — committed to Miepee/runtime by Miepee 2 years ago
- Fix incorrect SpecialFolder entries for Unix This fixes an incorrect Documents/Personal for Linux+Mac entry, incorrect Videos Mac entry, and an incorrect (Local) ApplicationData Mac entry. Fix #6321... — committed to Miepee/runtime by Miepee 2 years ago
- Fix incorrect SpecialFolder entries for Unix This fixes an incorrect Documents/Personal for Linux+Mac entry, incorrect Videos Mac entry, and an incorrect (Local) ApplicationData Mac entry. Fix #6321... — committed to Miepee/runtime by Miepee 2 years ago
- Fix some incorrect SpecialFolder entries for Unix (#68610) * Fix incorrect SpecialFolder entries for Unix This fixes an incorrect Documents/Personal for Linux+Mac entry, incorrect Videos Mac entr... — committed to dotnet/runtime by Miepee 2 years ago
Is there any progress or new info on this issue? If there’s none, then I’d like to do a PR that fixes the assignments for Documents (Linux) and Movies/ApplicationData/LocalApplicationData (MacOS), and open a separate issue for the other fields which are wrong, including ios/tvOS+Android. (If there are any there. I haven’t checked that yet.)
No, Mono is not upstream.