Closed
Description
Information
- OS: any
- Version: latest (0.49.2-preview.0.73)
- Terminal: any
Describe the bug
Formatting of generic exceptions is does not work as expected. When using ExceptionFormats.ShortenTypes
, the exception type is totally mangled.
To Reproduce
FaultException.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Spectre.Console" Version="0.49.2-preview.0.73" />
<PackageReference Include="System.ServiceModel.Primitives" Version="8.1.1" />
</ItemGroup>
</Project>
Program.cs
using System;
using System.ServiceModel;
using Spectre.Console;
try
{
throw new FaultException<System.IO.DriveInfo>(null, reason: "Dummy fault reason");
}
catch (Exception exception)
{
var format = args.Length > 0 && Enum.TryParse<ExceptionFormats>(args[0], out var result) ? result : ExceptionFormats.Default;
AnsiConsole.WriteException(exception, format);
}
Run dotnet run -- ShortenEverything
and see how the exception is formatted.
I chose FaultException<>
as an example of a generic exception because it came from a real life SOAP error.
Expected behavior
The exception is printed properly, something like
FaultException<DriveInfo>: Dummy fault reason
at void <Main>$(string[] args) in Program.cs:7
Actual behavior
The output is truncated and we can't see that the exception is a FaultException
.
0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]: Dummy fault reason
at void <Main>$(string[] args) in Program.cs:7
See also this screenshot with the colors.

Additional context
I will submit a pull request to fix this issue soon.
Please upvote 👍 this issue if you are interested in it.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done 🚀