@@ -503,70 +503,6 @@ public static string ArgumentsUsage(IHostEnvironment env, Type type, object defa
503
503
return parser . GetUsageString ( env , info , showRsp , columns ) ;
504
504
}
505
505
506
- #if CORECLR
507
- /// <summary>
508
- /// Fix the window width for the Core build to remove the kernel32.dll dependency.
509
- /// </summary>
510
- /// <returns></returns>
511
- public static int GetConsoleWindowWidth ( )
512
- {
513
- return 120 ;
514
- }
515
- #else
516
- private const int StdOutputHandle = - 11 ;
517
-
518
- private struct Coord
519
- {
520
- internal Int16 X ;
521
- internal Int16 Y ;
522
- }
523
-
524
- private struct SmallRect
525
- {
526
- internal Int16 Left ;
527
- internal Int16 Top ;
528
- internal Int16 Right ;
529
- internal Int16 Bottom ;
530
- }
531
-
532
- private struct ConsoleScreenBufferInfo
533
- {
534
- internal Coord DwSize ;
535
- internal Coord DwCursorPosition ;
536
- internal Int16 WAttributes ;
537
- internal SmallRect SrWindow ;
538
- internal Coord DwMaximumWindowSize ;
539
- }
540
-
541
- [ DllImport ( "kernel32.dll" , EntryPoint = "GetStdHandle" , SetLastError = true , CharSet = CharSet . Unicode , CallingConvention = CallingConvention . StdCall ) ]
542
- private static extern int GetStdHandle ( int nStdHandle ) ;
543
-
544
- [ DllImport ( "kernel32.dll" , EntryPoint = "GetConsoleScreenBufferInfo" , SetLastError = true , CharSet = CharSet . Unicode , CallingConvention = CallingConvention . StdCall ) ]
545
- private static extern int GetConsoleScreenBufferInfo ( int hConsoleOutput , ref ConsoleScreenBufferInfo lpConsoleScreenBufferInfo ) ;
546
-
547
- /// <summary>
548
- /// Returns the number of columns in the current console window
549
- /// </summary>
550
- /// <returns>Returns the number of columns in the current console window</returns>
551
- public static int GetConsoleWindowWidth ( )
552
- {
553
- int screenWidth ;
554
- ConsoleScreenBufferInfo csbi = new ConsoleScreenBufferInfo ( ) ;
555
- // Just to remove the warning messages...
556
- csbi . DwCursorPosition . X = 0 ;
557
- csbi . DwCursorPosition . Y = 0 ;
558
- csbi . SrWindow . Bottom = 0 ;
559
- csbi . SrWindow . Top = 0 ;
560
- csbi . SrWindow . Left = 0 ;
561
- csbi . SrWindow . Right = 0 ;
562
-
563
- int rc ;
564
- rc = GetConsoleScreenBufferInfo ( GetStdHandle ( StdOutputHandle ) , ref csbi ) ;
565
- screenWidth = csbi . DwSize . X ;
566
- return screenWidth ;
567
- }
568
- #endif
569
-
570
506
private CmdParser ( IHostEnvironment env )
571
507
{
572
508
_host = env . Register ( "CmdParser" ) ;
@@ -1009,7 +945,7 @@ public ArgumentHelpStrings(string syntax, string help)
1009
945
/// </summary>
1010
946
private string GetUsageString ( IExceptionContext ectx , ArgumentInfo info , bool showRsp = true , int ? columns = null )
1011
947
{
1012
- int screenWidth = columns ?? GetConsoleWindowWidth ( ) ;
948
+ int screenWidth = columns ?? Console . BufferWidth ;
1013
949
if ( screenWidth <= 0 )
1014
950
screenWidth = 80 ;
1015
951
0 commit comments