Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rafaelsc opened this issue Dec 5, 2023 · 2 comments · May be fixed by #1403
Labels
bug Something isn't working needs triage

Comments

@rafaelsc
Copy link

rafaelsc commented Dec 5, 2023

Information

  • OS: Windows 10
  • Version: 0.48.0
  • Terminal: Any
  • Runtime: NET 8 with Publish Trimmed

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.

  • Create a new Console Application with NET8, with PublishTrimmed, SelfContained, PublishSingleFile, PublishReadyToRun.
  • Use ExceptionFormatter with a Exception with a stack trace.
  • ExceptionFormatter can some times throw a System.NullReferenceException when using reflection.
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

  • No Exception when Formation a Exception.

Screenshots
image


Please upvote 👍 this issue if you are interested in it.

@rafaelsc rafaelsc added bug Something isn't working needs triage labels Dec 5, 2023
@github-project-automation github-project-automation bot moved this to Todo 🕑 in Spectre Console Dec 5, 2023
@rafaelsc rafaelsc changed the title Error when using C# PublishTrimmed, Trimmer can remove Types and Properties that spectre.console expects the type to have. ( Error when using C# PublishTrimmed, Trimmer can remove Types and Properties that spectre.console expects the type to have. (ExceptionFormatter) Dec 5, 2023
@patriksvensson
Copy link
Contributor

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

@rafaelsc rafaelsc linked a pull request Dec 6, 2023 that will close this issue
6 tasks
@ricardoboss
Copy link

See also: #955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
Status: Todo 🕑
Development

Successfully merging a pull request may close this issue.

3 participants