eduherminio / AoCHelper

Helper .NET library for solving Advent of Code puzzles

Home Page:https://adventofcode.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exceptions that contain brackets break the console

jfheins opened this issue · comments

Hi :-)
When I run my project using SolveAll in Debug mide, all is well and I get a nice pribntout of the 7 days so far.
Using release more, however, trips at day 3:
image

I think this happens when my code throws an exception and then the exception message and stack trace contain brackets []
the console format thing assumes special meaning so I suppose you need to escape those brackets before sending them into the console.

I believe this is the same as #47.

I also experienced something similar today:

$> AoC2022\src\AoC_2022 [main ↑1 +0 ~1 -0 !]> dotnet run

Unhandled exception. System.InvalidOperationException: Could not find color or style 'T'.
   at Spectre.Console.StyleParser.Parse(String text) in /_/src/Spectre.Console/StyleParser.cs:line 10
   at Spectre.Console.MarkupParser.Parse(String text, Style style) in /_/src/Spectre.Console/Internal/Text/Markup/MarkupParser.cs:line 29
   at Spectre.Console.Markup..ctor(String text, Style style) in /_/src/Spectre.Console/Widgets/Markup.cs:line 42
   at Spectre.Console.TableExtensions.<>c.<AddRow>b__6_0(String column) in /_/src/Spectre.Console/Extensions/TableExtensions.cs:line 160
   at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
   at Spectre.Console.TableExtensions.AddRow(Table table, String[] columns) in /_/src/Spectre.Console/Extensions/TableExtensions.cs:line 160
   at AoCHelper.Solver.RenderRow(Table table, String problemTitle, String part, String solution, Double elapsedMilliseconds, SolverConfiguration configuration)
   at AoCHelper.Solver.SolveProblem(BaseProblem problem, Table table, Double constructorElapsedTime, SolverConfiguration configuration)
   at AoCHelper.Solver.<>c__DisplayClass2_0.<<SolveLast>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Spectre.Console.LiveDisplay.<>c__DisplayClass17_0.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/LiveDisplay.cs:line 80
--- End of stack trace from previous location ---
   at Spectre.Console.LiveDisplay.<>c__DisplayClass18_0`1.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/LiveDisplay.cs:line 110
--- End of stack trace from previous location ---
   at Spectre.Console.Internal.DefaultExclusivityMode.RunAsync[T](Func`1 func) in /_/src/Spectre.Console/Internal/DefaultExclusivityMode.cs:line 40
   at Spectre.Console.LiveDisplay.StartAsync[T](Func`2 func) in /_/src/Spectre.Console/Live/LiveDisplay.cs:line 98
   at Spectre.Console.LiveDisplay.StartAsync(Func`2 func) in /_/src/Spectre.Console/Live/LiveDisplay.cs:line 78
   at AoCHelper.Solver.SolveLast(Action`1 options)
   at Program.<Main>$(String[] args) in AoC_2022\Program.cs:line 3
   at Program.<Main>(String[] args)

Thanks for using AoCHelper and raising this bug @jfheins.

Your diagnostic was correct and thanks to you repo I could reproduce the bug and test the fix easily.
The fix is available in v2.0.1, please let me know if you experience any regressions.