I have a Console application build in dotnetcorapp2.1. It's running fine on Windows.
When trying to run on Ubuntu it raise an Exception error:
System.PlatformNotSupportedException: Operation is not supported on this platform. at System.ConsolePal.set_BufferHeight(Int32 value)
That is because This line:
Console.BufferHeight = Int16.MaxValue - 1;
This document didn't mention the limitation that I take into account for Console.BufferHeight
Googling didn't help like this and this
What is the limitation of Console.BufferHeight (and BufferWidth) on Ubuntu?
I have posted this question to corefx team and submitted an issue there.
All credit in this answer go to @danmosemsft
The member
Console.BufferHeightis not supported on Unix. The docs didn't state the Unix specific behaviors on the Console methods/properties.The class
ConsolePalin the document ConsolePal.Unix.cs include also other NotSupported members.A new document is created to show the PlatformNotSupportedExceptions in System.Console
I modified the code and catch
PlatformNotSupportedExceptionseparate and application is running on Ubuntu without a problem.Edit
Discovering the code that raise PlatformNotSupportedExceptions:
Install the nuget package
Microsoft.DotNet.Analyzers.CompatibilityConfigure the tool as described here
Select the rule PC001 and select Set Rule Set Severity as error