-
Notifications
You must be signed in to change notification settings - Fork 6k
GetFolderPath breaking change #33700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
docs/core/compatibility/core-libraries/8.0/getfolderpath-unix.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
title: ".NET 8 breaking change: GetFolderPath behavior on Unix" | ||
description: Learn about the .NET 8 breaking change in core .NET libraries where the behavior of Environment.GetFolderPath has changed on Unix. | ||
ms.date: 11/18/2022 | ||
--- | ||
# GetFolderPath behavior on Unix | ||
|
||
Starting in .NET 8, the behavior of <xref:System.Environment.GetFolderPath%2A?displayProperty=nameWithType> on Unix operating systems has changed. | ||
|
||
## Change description | ||
|
||
The following tables show how the returned path value changes for each Unix operating system for various special folders. | ||
|
||
### Linux | ||
|
||
| SpecialFolder value | Path (.NET 7 and earlier) | Path (.NET 8 and later) | | ||
|---------------------|---------------------------|--------------------------------------------------------------------| | ||
| `MyDocuments` | `$HOME` | Uses `XDG_DOCUMENTS_DIR` if available; otherwise `$HOME/Documents` | | ||
| `Personal` | `$HOME` | Uses `XDG_DOCUMENTS_DIR` if available; otherwise `$HOME/Documents` | | ||
|
||
### macOS | ||
|
||
| SpecialFolder value | Path (.NET 7 and earlier) | Path (.NET 8 and later) | | ||
|-|-|-| | ||
| `MyDocuments` | `$HOME` | [NSDocumentDirectory](https://developer.apple.com/documentation/foundation/nssearchpathdirectory/nsdocumentdirectory) (`$HOME/Documents`) | | ||
| `Personal` | `$HOME` | [NSDocumentDirectory](https://developer.apple.com/documentation/foundation/nssearchpathdirectory/nsdocumentdirectory) (`$HOME/Documents`) | | ||
| `ApplicationData` | `$HOME/.config` | [NSApplicationSupportDirectory](https://developer.apple.com/documentation/foundation/nssearchpathdirectory/nsapplicationsupportdirectory) (Library/Application Support) | | ||
| `LocalApplicationData` | `$HOME/.local/share` | [NSApplicationSupportDirectory](https://developer.apple.com/documentation/foundation/nssearchpathdirectory/nsapplicationsupportdirectory) (Library/Application Support) | | ||
| `MyVideos` | `$HOME/Videos` | [NSMoviesDirectory](https://developer.apple.com/documentation/foundation/nssearchpathdirectory/nsmoviesdirectory) (`$HOME/Movies`) | | ||
|
||
### Android | ||
|
||
| SpecialFolder value | Path (.NET 7 and earlier) | Path (.NET 8 and later) | | ||
|---------------------|---------------------------|-------------------------| | ||
| `MyDocuments` | `$HOME` | `$HOME/Documents` | | ||
| `Personal` | `$HOME` | `$HOME/Documents` | | ||
|
||
## Version introduced | ||
|
||
.NET 8 Preview 1 | ||
|
||
## Type of breaking change | ||
|
||
This change is a [behavioral change](../../categories.md#behavioral-change). | ||
|
||
## Reason for change | ||
|
||
The previous behavior was incorrect and didn't meet user expectations for Linux, macOS, and Android. | ||
|
||
## Recommended action | ||
|
||
The most common break is if you're passing <xref:System.Environment.SpecialFolder.Personal?displayProperty=fullName> to <xref:System.Environment.GetFolderPath(System.Environment.SpecialFolder)?displayProperty=nameWithType> on Unix to get the `$HOME` directory (`Environment.GetFolderPath(Environment.SpecialFolder.Personal)`). <xref:System.Environment.SpecialFolder.Personal?displayProperty=nameWithType> and <xref:System.Environment.SpecialFolder.MyDocuments?displayProperty=nameWithType> are aliases for the same underlying enumeration value. If you're using <xref:System.Environment.SpecialFolder.Personal?displayProperty=nameWithType> in this way, change your code to pass <xref:System.Environment.SpecialFolder.UserProfile?displayProperty=nameWithType> instead (`Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)`). | ||
|
||
For other breaks, the recommended action is to do one of the following: | ||
|
||
- Migrate your application's files to the appropriate directory. | ||
- Add a fallback check for the previous location to your code. | ||
|
||
## Affected APIs | ||
|
||
- <xref:System.Environment.GetFolderPath(System.Environment.SpecialFolder)?displayProperty=fullName> | ||
- <xref:System.Environment.GetFolderPath(System.Environment.SpecialFolder,System.Environment.SpecialFolderOption)?displayProperty=fullName> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.