[Tizen] Fix ArgumentOutOfRangeException
authorHyungju Lee <leee.lee@samsung.com>
Tue, 13 Sep 2022 05:09:12 +0000 (14:09 +0900)
committerMikhail Kurinnoi <m.kurinnoi@samsung.com>
Thu, 29 Sep 2022 10:58:47 +0000 (13:58 +0300)
[root@localhost tmp]# dotnet dump analyze core_19700108_100550
Loading core dump: core_19700108_100550 ...
Ready to process analysis commands. Type 'help' to list available commands or 'help [command]' to get detailed help on a command.
Type 'quit' or 'exit' to exit the session.
Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. (Parameter 'top')
Actual value was -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at System.Console.set_CursorLeft(Int32 value)
   at Microsoft.Diagnostics.Repl.ConsoleProvider.ClearLine()
   at Microsoft.Diagnostics.Repl.ConsoleProvider.RefreshLine()
   at Microsoft.Diagnostics.Repl.ConsoleProvider.AppendNewText(String text)
   at Microsoft.Diagnostics.Repl.ConsoleProvider.ProcessKeyInfo(ConsoleKeyInfo keyInfo, Action`2 dispatchCommand)
   at Microsoft.Diagnostics.Repl.ConsoleProvider.Start(Action`2 dispatchCommand)
   at Microsoft.Diagnostics.Tools.Dump.Analyzer.Analyze(FileInfo dump_path, String[] command)
   --- End of inner exception stack trace ---

src/Microsoft.Diagnostics.Repl/ConsoleService.cs

index fa4687baea4f2a8329ee9b28c6ef148082ff6a22..7145a79af3dd2aeefa957ca8a3cf211351ed25a8 100644 (file)
@@ -274,7 +274,7 @@ namespace Microsoft.Diagnostics.Repl
 
             Console.Write(m_clearLine);
 
-            if (!m_outputRedirected) {
+            if (!m_outputRedirected && Console.CursorTop >= 0) {
                 Console.CursorLeft = 0;
             }
         }
@@ -320,7 +320,7 @@ namespace Microsoft.Diagnostics.Repl
 
             Console.Write("{0}{1}", prompt, text);
 
-            if (!m_outputRedirected) {
+            if (!m_outputRedirected && Console.CursorTop >= 0) {
                 Console.CursorLeft = prompt.Length + (m_cursorPosition - m_scrollPosition);
             }
         }