File tree Expand file tree Collapse file tree 7 files changed +10
-22
lines changed
src/libraries/System.Console/src/System Expand file tree Collapse file tree 7 files changed +10
-22
lines changed Original file line number Diff line number Diff line change @@ -538,7 +538,7 @@ public static string Title
538538 [ UnsupportedOSPlatform ( "tvos" ) ]
539539 public static void Beep ( )
540540 {
541- ConsolePal . Beep ( ) ;
541+ ConsolePal . Beep ( s_isOutTextWriterRedirected ) ;
542542 }
543543
544544 [ SupportedOSPlatform ( "windows" ) ]
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ public static string Title
9494 set => throw new PlatformNotSupportedException ( ) ;
9595 }
9696
97- public static void Beep ( ) => throw new PlatformNotSupportedException ( ) ;
97+ public static void Beep ( bool _ ) => throw new PlatformNotSupportedException ( ) ;
9898
9999 public static void Beep ( int frequency , int duration ) => throw new PlatformNotSupportedException ( ) ;
100100
Original file line number Diff line number Diff line change @@ -205,7 +205,7 @@ public static string Title
205205 }
206206 }
207207
208- public static void Beep ( )
208+ public static void Beep ( bool _ )
209209 {
210210 if ( ! Console . IsOutputRedirected )
211211 {
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ public static string Title
9696 set => throw new PlatformNotSupportedException ( ) ;
9797 }
9898
99- public static void Beep ( ) => throw new PlatformNotSupportedException ( ) ;
99+ public static void Beep ( bool _ ) => throw new PlatformNotSupportedException ( ) ;
100100
101101 public static void Clear ( ) => throw new PlatformNotSupportedException ( ) ;
102102 public static void SetCursorPosition ( int left , int top ) => throw new PlatformNotSupportedException ( ) ;
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ public static string Title
155155 set => throw new PlatformNotSupportedException ( ) ;
156156 }
157157
158- public static void Beep ( ) => throw new PlatformNotSupportedException ( ) ;
158+ public static void Beep ( bool _ ) => throw new PlatformNotSupportedException ( ) ;
159159
160160 public static void Beep ( int frequency , int duration ) => throw new PlatformNotSupportedException ( ) ;
161161
Original file line number Diff line number Diff line change @@ -675,30 +675,18 @@ public static unsafe string Title
675675 }
676676 }
677677
678- public static void Beep ( )
678+ public static void Beep ( bool isOutTextWriterRedirected )
679679 {
680680 const char BellCharacter = '\u0007 ' ; // Windows doesn't use terminfo, so the codepoint is hardcoded.
681681
682- if ( ! Console . IsOutputRedirected )
682+ if ( ! Console . IsOutputRedirected && ! isOutTextWriterRedirected )
683683 {
684684 Console . Out . Write ( BellCharacter ) ;
685- return ;
686685 }
687-
688- if ( ! Console . IsErrorRedirected )
686+ else
689687 {
690- Console . Error . Write ( BellCharacter ) ;
691- return ;
688+ Interop . Kernel32 . Beep ( frequency : 800 , duration : 200 ) ;
692689 }
693-
694- BeepFallback ( ) ;
695- }
696-
697- private static void BeepFallback ( )
698- {
699- const int BeepFrequencyInHz = 800 ;
700- const int BeepDurationInMs = 200 ;
701- Interop . Kernel32 . Beep ( BeepFrequencyInHz , BeepDurationInMs ) ;
702690 }
703691
704692 public static void Beep ( int frequency , int duration )
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ public static string Title
9999 set => throw new PlatformNotSupportedException ( ) ;
100100 }
101101
102- public static void Beep ( ) => throw new PlatformNotSupportedException ( ) ;
102+ public static void Beep ( bool _ ) => throw new PlatformNotSupportedException ( ) ;
103103
104104 public static void Beep ( int frequency , int duration ) => throw new PlatformNotSupportedException ( ) ;
105105
You can’t perform that action at this time.
0 commit comments