Repository: PowerShell/PowerShell
File: src/System.Management.Automation/namespaces/FileSystemProvider.cs (C#)

Code before:
        internal const sbyte PHCM_ERROR_INVALID_PARAMETER = -1;
        internal const sbyte PHCM_ERROR_NO_TEB = -2;
#endif

        /// <summary>
        /// Starts the File System provider.  This method sets the Home for the
        /// provider to providerInfo.Home if specified, and %USERPROFILE%
        /// otherwise.
        /// </summary>
        /// <param name="providerInfo">
        /// The ProviderInfo object that holds the provider's configuration.
        /// </param>
        /// <returns>
        /// The updated ProviderInfo object that holds the provider's configuration.
        /// </returns>
        protected override ProviderInfo Start(ProviderInfo providerInfo)
        {
            // Set the home folder for the user
            if (providerInfo != null && string.IsNullOrEmpty(providerInfo.Home))
            {
                // %USERPROFILE% - indicate where a user's home directory is located in the file system.
                string homeDirectory = Environment.GetEnvironmentVariable(Platform.CommonEnvVariableNames.Home);

                if (!string.IsNullOrEmpty(homeDirectory))
                {
                    if (Directory.Exists(homeDirectory))
                    {
                        s_tracer.WriteLine("Home = {0}", homeDirectory);
                        providerInfo.Home = homeDirectory;
                    }
                    else
                        s_tracer.WriteLine("Not setting home directory {0} - does not exist", homeDirectory);
                }
            }
           
            // OneDrive placeholder support (issue #8315)
            // make it so OneDrive placeholders are perceived as such with *all* their attributes accessible
#if !UNIX
            Version minBuildForPlaceHolderAPIs = new Version(10, 0, 17134, 0);
            if (Environment.OSVersion.Version >= minBuildForPlaceHolderAPIs)
            {
                // let's be safe, don't change the PlaceHolderCompatibilityMode if the current one is not what we expect
                if (PHCM_DISGUISE_PLACEHOLDER == RtlQueryProcessPlaceholderCompatibilityMode())
                {
                    RtlSetProcessPlaceholderCompatibilityMode(PHCM_EXPOSE_PLACEHOLDERS);
                }
            }
#endif

            return providerInfo;
        }

Review comment (suggestion):
It would be good to have an explicit comment on top of this line like `// The ProcessPlaceholderCompatibilityMode APIs are only available on Win10 build 17134 or newer`.

Code after:
        protected override ProviderInfo Start(ProviderInfo providerInfo)
        {
            // Set the home folder for the user
            if (providerInfo != null && string.IsNullOrEmpty(providerInfo.Home))
            {
                // %USERPROFILE% - indicate where a user's home directory is located in the file system.
                string homeDirectory = Environment.GetEnvironmentVariable(Platform.CommonEnvVariableNames.Home);

                if (!string.IsNullOrEmpty(homeDirectory))
                {
                    if (Directory.Exists(homeDirectory))
                    {
                        s_tracer.WriteLine("Home = {0}", homeDirectory);
                        providerInfo.Home = homeDirectory;
                    }
                    else
                        s_tracer.WriteLine("Not setting home directory {0} - does not exist", homeDirectory);
                }
            }

            // OneDrive placeholder support (issue #8315)
            // make it so OneDrive placeholders are perceived as such with *all* their attributes accessible
#if !UNIX
            // The placeholder mode management APIs Rtl(Set|Query)(Process|Thread)PlaceholderCompatibilityMode
            // are only supported starting with Windows 10 version 1803 (build 17134)
            Version minBuildForPlaceHolderAPIs = new Version(10, 0, 17134, 0);
            if (Environment.OSVersion.Version >= minBuildForPlaceHolderAPIs)
            {
                // let's be safe, don't change the PlaceHolderCompatibilityMode if the current one is not what we expect
                if (NativeMethods.PHCM_DISGUISE_PLACEHOLDER == NativeMethods.RtlQueryProcessPlaceholderCompatibilityMode())
                {
                    NativeMethods.RtlSetProcessPlaceholderCompatibilityMode(NativeMethods.PHCM_EXPOSE_PLACEHOLDERS);
                }
            }
#endif

            return providerInfo;
        }

        #endregion CmdletProvider members

        #region DriveCmdletProvider members

        /// <summary>
        /// Determines if the specified drive can be mounted.
        /// </summary>
        /// <param name="drive">
        /// The drive that is going to be mounted.
        /// </param>
        /// <returns>
        /// The same drive that was passed in, if the drive can be mounted.