Background and motivation
Environment.SpecialFolder has two enum names that map to the same underlying enum value MyDocuments and Personal.
|
Personal = SpecialFolderValues.CSIDL_PERSONAL, |
|
MyDocuments = SpecialFolderValues.CSIDL_PERSONAL, |
This is rather confusing, and also leads to bugs because consumers wrongly believe that Environment.SpecialFolder.Personal really means Environment.SpecialFolder.UserProfile. Further, with #68610, we are fixing the path returned from SpecialFolder.MyDocuments/Personal to actually be a "Documents" folder on both Linux and macOS. When doing the breaking change analysis, I found more places using Environment.SpecialFolder.Personal to mean Environment.SpecialFolder.UserProfile than I did for it to mean an actual "MyDocuments" folder.
We should deprecate and hide the Personal enum value because people are using it wrong and it means the exact same thing as "MyDocuments".
Examples of places that got it wrong:
API Proposal
namespace System;
public static partial class Environment
{
public enum SpecialFolder
{
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Obsolete("Use Environment.SpecialFolder.MyDocuments instead")]
Personal = SpecialFolderValues.CSIDL_PERSONAL,
API Usage
Don't use Environment.SpecialFolder.Personal, instead either pick SpecialFolder.MyDocuments or SpecialFolder.UserProfile, as appropriate.
Alternative Designs
No response
Risks
No response
Background and motivation
Environment.SpecialFolderhas two enum names that map to the same underlying enum valueMyDocumentsandPersonal.runtime/src/libraries/System.Private.CoreLib/src/System/Environment.SpecialFolder.cs
Lines 30 to 31 in 6214022
This is rather confusing, and also leads to bugs because consumers wrongly believe that
Environment.SpecialFolder.Personalreally meansEnvironment.SpecialFolder.UserProfile. Further, with #68610, we are fixing the path returned fromSpecialFolder.MyDocuments/Personalto actually be a "Documents" folder on both Linux and macOS. When doing the breaking change analysis, I found more places usingEnvironment.SpecialFolder.Personalto meanEnvironment.SpecialFolder.UserProfilethan I did for it to mean an actual "MyDocuments" folder.We should deprecate and hide the
Personalenum value because people are using it wrong and it means the exact same thing as "MyDocuments".Examples of places that got it wrong:
API Proposal
namespace System; public static partial class Environment { public enum SpecialFolder { + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("Use Environment.SpecialFolder.MyDocuments instead")] Personal = SpecialFolderValues.CSIDL_PERSONAL,API Usage
Don't use
Environment.SpecialFolder.Personal, instead either pickSpecialFolder.MyDocumentsorSpecialFolder.UserProfile, as appropriate.Alternative Designs
No response
Risks
No response