From 612c994b4891a464f03d95ffbb43cbe13396b4a9 Mon Sep 17 00:00:00 2001 From: Sourabh Shirhatti Date: Fri, 13 Sep 2019 00:16:25 -0700 Subject: [PATCH 1/2] Workaround for bug in System.CommandLine --- src/dotnet-grpc/Commands/ListCommand.cs | 11 ++++++++++- test/dotnet-grpc.Tests/ListCommandTests.cs | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dotnet-grpc/Commands/ListCommand.cs b/src/dotnet-grpc/Commands/ListCommand.cs index 99aeabfb9..69182a58f 100644 --- a/src/dotnet-grpc/Commands/ListCommand.cs +++ b/src/dotnet-grpc/Commands/ListCommand.cs @@ -95,7 +95,16 @@ public void List() } var screen = new ScreenView(consoleRenderer, Console) { Child = table }; - screen.Render(new Region(0, 0, System.Console.WindowWidth, System.Console.WindowWidth)); + Region region; + try + { + region = new Region(0, 0, System.Console.WindowWidth, System.Console.WindowHeight); + } + catch (IOException) + { + region = new Region(0, 0, int.MaxValue, int.MaxValue); + } + screen.Child?.Render(consoleRenderer, region); } } } diff --git a/test/dotnet-grpc.Tests/ListCommandTests.cs b/test/dotnet-grpc.Tests/ListCommandTests.cs index bdc3d626a..dcb299c69 100644 --- a/test/dotnet-grpc.Tests/ListCommandTests.cs +++ b/test/dotnet-grpc.Tests/ListCommandTests.cs @@ -18,6 +18,7 @@ using System; using System.CommandLine; +using System.CommandLine.Rendering; using System.IO; using Grpc.Dotnet.Cli.Commands; using NUnit.Framework; @@ -28,7 +29,7 @@ namespace Grpc.Dotnet.Cli.Tests public class ListCommandTests : TestBase { [Test] - [Ignore("https://github.com/grpc/grpc-dotnet/issues/457")] + //[Ignore("https://github.com/grpc/grpc-dotnet/issues/457")] public void List_ListsReferences() { var currentDir = Directory.GetCurrentDirectory(); From 05bf2de307fb3a2612c64031e626f7d9cb0d48e3 Mon Sep 17 00:00:00 2001 From: Sourabh Shirhatti Date: Fri, 13 Sep 2019 08:05:18 -0700 Subject: [PATCH 2/2] Feedback --- src/dotnet-grpc/Commands/ListCommand.cs | 1 + test/dotnet-grpc.Tests/ListCommandTests.cs | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/dotnet-grpc/Commands/ListCommand.cs b/src/dotnet-grpc/Commands/ListCommand.cs index 69182a58f..40b5fc457 100644 --- a/src/dotnet-grpc/Commands/ListCommand.cs +++ b/src/dotnet-grpc/Commands/ListCommand.cs @@ -98,6 +98,7 @@ public void List() Region region; try { + // System.Console.WindowWidth can throw an IOException when runnning without a console attached region = new Region(0, 0, System.Console.WindowWidth, System.Console.WindowHeight); } catch (IOException) diff --git a/test/dotnet-grpc.Tests/ListCommandTests.cs b/test/dotnet-grpc.Tests/ListCommandTests.cs index dcb299c69..2ee889a94 100644 --- a/test/dotnet-grpc.Tests/ListCommandTests.cs +++ b/test/dotnet-grpc.Tests/ListCommandTests.cs @@ -18,7 +18,6 @@ using System; using System.CommandLine; -using System.CommandLine.Rendering; using System.IO; using Grpc.Dotnet.Cli.Commands; using NUnit.Framework; @@ -29,7 +28,6 @@ namespace Grpc.Dotnet.Cli.Tests public class ListCommandTests : TestBase { [Test] - //[Ignore("https://github.com/grpc/grpc-dotnet/issues/457")] public void List_ListsReferences() { var currentDir = Directory.GetCurrentDirectory();