spectreconsole / spectre.console

A .NET library that makes it easier to create beautiful console applications.
https://spectreconsole.net
MIT License
9.12k stars 468 forks source link

Error when using C# PublishTrimmed, Trimmer can remove Types and Properties that spectre.console expects the type to have. (ExceptionFormatter) #1401

Open rafaelsc opened 8 months ago

rafaelsc commented 8 months ago

Information

Describe the bug A clear and concise description of what the bug is.

To Reproduce I Tried without success creating a standalone minimal console app to reproduce, but look like trimmer is not removing the same types/properties in the same way in my application.

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Spectre.Console.ExceptionFormatter.TryGetTupleName(ParameterInfo parameter, Type parameterType, String& tupleName) in /_/src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs:line 314
   at Spectre.Console.ExceptionFormatter.GetParameterName(ParameterInfo parameter) in /_/src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs:line 280
   at Spectre.Console.ExceptionFormatter.GetStackFrames(Exception ex, ExceptionSettings settings) in /_/src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs:line 79
   at Spectre.Console.ExceptionFormatter.GetException(Exception exception, ExceptionSettings settings) in /_/src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs:line 22
   at Program.<>c__DisplayClass0_1.<<Main>$>b__0(LiveDisplayContext ctx)
   at Spectre.Console.LiveDisplay.<>c__DisplayClass15_0.<Start>b__0(LiveDisplayContext ctx) in /_/src/Spectre.Console/Live/LiveDisplay.cs:line 47
   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 Spectre.Console.LiveDisplay.Start(Action`1 action) in /_/src/Spectre.Console/Live/LiveDisplay.cs:line 51
   at Program.<Main>$(String[] args)

Expected behavior

Screenshots image


Please upvote :+1: this issue if you are interested in it.

patriksvensson commented 8 months ago

Spectre.Console does not yet support AOT, so errors like this are to expected. Pull requests are most welcome.

ricardoboss commented 8 months ago

See also: #955