elexon-data / iris-clients

Clients for connecting to the Insights Real-time Information Service
MIT License
17 stars 7 forks source link

.NET Client Console.ReadKey() errors when running in Git Bash #2

Open robin-leach opened 1 year ago

robin-leach commented 1 year ago

Overview

The .NET Client throws an exception when you try and run it in Git Bash.

Steps to reproduce

  1. Build and run the .NET Client in Git Bash
  2. Observe that you get the following error message:
    Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.

Further details and cause

The full stack trace is as follows:

Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
   at System.ConsolePal.ReadKey(Boolean intercept)
   at System.Console.ReadKey()
   at Program.<Main>$(String[] args) in github\iris-clients\dotnet\IrisClient\Program.cs:line 26
   at Program.<Main>$(String[] args) in github\iris-clients\dotnet\IrisClient\Program.cs:line 36
   at Program.<Main>(String[] args)

Specifically, the Console.ReadKey() line in Program.cs is where the exception is thrown. It looks like this is incompatible with the Git Bash terminal.

Anything else worth noting

This appears to be the same issue as described in this StackExchange post. It may be sufficient to replace the Console.ReadKey() line with Console.Read(), but this will require confirmation.