Repository: dotnet/runtime
File: src/libraries/System.Console/src/System/Console.cs (C#)

Code before:
        public static Stream OpenStandardOutput(int bufferSize)
        {
            // bufferSize is ignored, other than in argument validation, even in the .NET Framework
            ArgumentOutOfRangeException.ThrowIfNegative(bufferSize);
            return ConsolePal.OpenStandardOutput();
        }

        public static Stream OpenStandardError()
        {
            return ConsolePal.OpenStandardError();
        }

        public static Stream OpenStandardError(int bufferSize)
        {
            // bufferSize is ignored, other than in argument validation, even in the .NET Framework
            ArgumentOutOfRangeException.ThrowIfNegative(bufferSize);
            return ConsolePal.OpenStandardError();
        }

        /// <summary>
        /// Gets the standard input handle.
        /// </summary>
        /// <returns>A <see cref="SafeFileHandle"/> representing the standard input handle.</returns>
        /// <remarks>
        /// The returned handle does not own the underlying resource, so disposing it will not close the standard input handle.
        /// </remarks>
        [UnsupportedOSPlatform("android")]
        [UnsupportedOSPlatform("browser")]
        [UnsupportedOSPlatform("ios")]
        [UnsupportedOSPlatform("tvos")]
        public static SafeFileHandle OpenStandardInputHandle()
        {
            return ConsolePal.OpenStandardInputHandle();
        }

        /// <summary>
        /// Gets the standard output handle.
        /// </summary>
        /// <returns>A <see cref="SafeFileHandle"/> representing the standard output handle.</returns>
        /// <remarks>
        /// The returned handle does not own the underlying resource, so disposing it will not close the standard output handle.
        /// </remarks>
        public static SafeFileHandle OpenStandardOutputHandle()
        {
            return ConsolePal.OpenStandardOutputHandle();
        }

        /// <summary>
        /// Gets the standard error handle.
        /// </summary>
        /// <returns>A <see cref="SafeFileHandle"/> representing the standard error handle.</returns>

Review comment (suggestion):
Add a remark that each of this methods throws `InvalidOperationException` when current process does not have a valid STD IN/OUT/ERR.

Code after:
        public static Stream OpenStandardOutput(int bufferSize)
        {
            // bufferSize is ignored, other than in argument validation, even in the .NET Framework
            ArgumentOutOfRangeException.ThrowIfNegative(bufferSize);
            return ConsolePal.OpenStandardOutput();
        }

        public static Stream OpenStandardError()
        {
            return ConsolePal.OpenStandardError();
        }

        public static Stream OpenStandardError(int bufferSize)
        {
            // bufferSize is ignored, other than in argument validation, even in the .NET Framework
            ArgumentOutOfRangeException.ThrowIfNegative(bufferSize);
            return ConsolePal.OpenStandardError();
        }

        /// <summary>
        /// Gets the standard input handle.
        /// </summary>
        /// <returns>A <see cref="SafeFileHandle"/> representing the standard input handle.</returns>
        /// <remarks>
        /// The returned handle does not own the underlying resource, so disposing it will not close the standard input handle.
        /// </remarks>
        [UnsupportedOSPlatform("android")]
        [UnsupportedOSPlatform("browser")]
        [UnsupportedOSPlatform("ios")]
        [UnsupportedOSPlatform("tvos")]
        public static SafeFileHandle OpenStandardInputHandle()
        {
            return ConsolePal.OpenStandardInputHandle();
        }

        /// <summary>
        /// Gets the standard output handle.
        /// </summary>
        /// <returns>A <see cref="SafeFileHandle"/> representing the standard output handle.</returns>
        /// <remarks>
        /// The returned handle does not own the underlying resource, so disposing it will not close the standard output handle.
        /// </remarks>
        [UnsupportedOSPlatform("android")]
        [UnsupportedOSPlatform("ios")]
        [UnsupportedOSPlatform("tvos")]
        public static SafeFileHandle OpenStandardOutputHandle()
        {
            return ConsolePal.OpenStandardOutputHandle();
        }

        /// <summary>