Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs (C#)

Code before:
                    context.ExpressionDebugOutputPipe = pipe;
                    break;
                case RedirectionStream.Information:
                    oldPipes[(int)FromStream] = context.ExpressionInformationOutputPipe;
                    context.ExpressionInformationOutputPipe = pipe;
                    break;
            }

            return oldPipes;
        }

        internal Pipe GetRedirectionPipe(ExecutionContext context, PipelineProcessor parentPipelineProcessor)
        {
            if (string.IsNullOrWhiteSpace(File))
            {
                return new Pipe { NullPipe = true };
            }

            // determine whether we're trying to set a variable by inspecting the file path
            // if we can determine that it's a variable, we'll use Set-Variable rather than Out-File
            ProviderInfo p;
            PSDriveInfo d;
            CommandProcessorBase commandProcessor;
            var name = context.SessionState.Path.GetUnresolvedProviderPathFromPSPath(File, out p, out d);

            if (ExperimentalFeature.IsEnabled("PSRedirectToVariable") && p != null && p.NameEquals(context.ProviderNames.Variable))
            {
                commandProcessor = context.CreateCommand("Set-Variable", false);
                Diagnostics.Assert(commandProcessor != null, "CreateCommand returned null");
                var cpi = CommandParameterInternal.CreateParameterWithArgument(
                    /*parameterAst*/null, "Name", "-Name:",
                    /*argumentAst*/null, name,
                    false);
                commandProcessor.AddParameter(cpi);

                if (this.Appending)
                {
                    commandProcessor.AddParameter(CommandParameterInternal.CreateParameter("Append", "-Append", null));
                }
            }
            else
            {
                commandProcessor = context.CreateCommand("out-file", false);
                Diagnostics.Assert(commandProcessor != null, "CreateCommand returned null");

                // Previously, we mandated Unicode encoding here
                // Now, We can take what ever has been set if PSDefaultParameterValues
                // Unicode is still the default, but now may be overridden

                var cpi = CommandParameterInternal.CreateParameterWithArgument(
                    /*parameterAst*/null, "Filepath", "-Filepath:",

Review comment (suggestion):
```suggestion
            if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSRedirectToVariable) && p != null && p.NameEquals(context.ProviderNames.Variable))
```

Code after:
                    context.ExpressionDebugOutputPipe = pipe;
                    break;
                case RedirectionStream.Information:
                    oldPipes[(int)FromStream] = context.ExpressionInformationOutputPipe;
                    context.ExpressionInformationOutputPipe = pipe;
                    break;
            }

            return oldPipes;
        }

        internal Pipe GetRedirectionPipe(ExecutionContext context, PipelineProcessor parentPipelineProcessor)
        {
            if (string.IsNullOrWhiteSpace(File))
            {
                return new Pipe { NullPipe = true };
            }

            // determine whether we're trying to set a variable by inspecting the file path
            // if we can determine that it's a variable, we'll use Set-Variable rather than Out-File
            ProviderInfo p;
            PSDriveInfo d;
            CommandProcessorBase commandProcessor;
            var name = context.SessionState.Path.GetUnresolvedProviderPathFromPSPath(File, out p, out d);

            if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSRedirectToVariable) && p != null && p.NameEquals(context.ProviderNames.Variable))
            {
                commandProcessor = context.CreateCommand("Set-Variable", false);
                Diagnostics.Assert(commandProcessor != null, "CreateCommand returned null");
                var cpi = CommandParameterInternal.CreateParameterWithArgument(
                    /*parameterAst*/null, "Name", "-Name:",
                    /*argumentAst*/null, name,
                    false);
                commandProcessor.AddParameter(cpi);

                if (this.Appending)
                {
                    commandProcessor.AddParameter(CommandParameterInternal.CreateParameter("Append", "-Append", null));
                }
            }
            else
            {
                commandProcessor = context.CreateCommand("out-file", false);
                Diagnostics.Assert(commandProcessor != null, "CreateCommand returned null");

                // Previously, we mandated Unicode encoding here
                // Now, We can take what ever has been set if PSDefaultParameterValues
                // Unicode is still the default, but now may be overridden

                var cpi = CommandParameterInternal.CreateParameterWithArgument(
                    /*parameterAst*/null, "Filepath", "-Filepath:",