Skip to content

Commit 168f352

Browse files
authored
Fix exception formatting for generic methods (#639)
The generic parameters were double escaped and would display as `[[T0,T1,TRet]]` instead of `[T0,T1,TRet]`. This is because the `builder.AppendWithStyle` method already escapes its value so the caller must not escape the passed value.
1 parent 225305f commit 168f352

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ private static string Emphasize(string input, char[] separators, Style color, bo
149149
{
150150
builder.AppendWithStyle(
151151
settings.Style.NonEmphasized,
152-
type.Substring(0, index + 1).EscapeMarkup());
152+
type.Substring(0, index + 1));
153153
}
154154

155155
builder.AppendWithStyle(
156156
color,
157-
type.Substring(index + 1, type.Length - index - 1).EscapeMarkup());
157+
type.Substring(index + 1, type.Length - index - 1));
158158
}
159159
else
160160
{

test/Spectre.Console.Tests/Expectations/Exception/CallSite.Output.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
System.InvalidOperationException: Something threw!
22
System.InvalidOperationException: Throwing!
3-
at Spectre.Console.Tests.Data.TestExceptions.GenericMethodThatThrows[[T0,T1,TRet]](Nullable`1 number) in /xyz/Exceptions.cs:nn
3+
at Spectre.Console.Tests.Data.TestExceptions.GenericMethodThatThrows[T0,T1,TRet](Nullable`1 number) in /xyz/Exceptions.cs:nn
44
at Spectre.Console.Tests.Data.TestExceptions.ThrowWithGenericInnerException() in /xyz/Exceptions.cs:nn
55
at Spectre.Console.Tests.Data.TestExceptions.ThrowWithGenericInnerException() in /xyz/Exceptions.cs:nn
66
at Spectre.Console.Tests.Unit.ExceptionTests.<>c.<Should_Write_Exceptions_With_Generic_Type_Parameters_In_Callsite_As_Expected>b__4_0() in /xyz/ExceptionTests.cs:nn

0 commit comments

Comments
 (0)