@@ -33,11 +33,12 @@ private static Markup GetMessage(Exception ex, ExceptionSettings settings)
33
33
{
34
34
var shortenTypes = ( settings . Format & ExceptionFormats . ShortenTypes ) != 0 ;
35
35
var exceptionType = ex . GetType ( ) ;
36
- var exceptionTypeFullName = exceptionType . FullName ?? exceptionType . Name ;
37
- var type = Emphasize ( exceptionTypeFullName , new [ ] { '.' } , settings . Style . Exception , shortenTypes , settings ) ;
36
+ var exceptionTypeName = TypeNameHelper . GetTypeDisplayName ( exceptionType , fullName : ! shortenTypes , includeSystemNamespace : true ) ;
37
+ var type = new StringBuilder ( ) ;
38
+ Emphasize ( type , exceptionTypeName , new [ ] { '.' } , settings . Style . Exception , shortenTypes , settings , limit : '<' ) ;
38
39
39
40
var message = $ "[{ settings . Style . Message . ToMarkup ( ) } ]{ ex . Message . EscapeMarkup ( ) } [/]";
40
- return new Markup ( string . Concat ( type , ": " , message ) ) ;
41
+ return new Markup ( $ " { type } : { message } " ) ;
41
42
}
42
43
43
44
private static Grid GetStackFrames ( Exception ex , ExceptionSettings settings )
@@ -101,7 +102,7 @@ private static Grid GetStackFrames(Exception ex, ExceptionSettings settings)
101
102
builder . Append ( ' ' ) ;
102
103
}
103
104
104
- builder . Append ( Emphasize ( methodName , new [ ] { '.' } , styles . Method , shortenMethods , settings ) ) ;
105
+ Emphasize ( builder , methodName , new [ ] { '.' } , styles . Method , shortenMethods , settings ) ;
105
106
builder . AppendWithStyle ( styles . Parenthesis , "(" ) ;
106
107
AppendParameters ( builder , method , settings ) ;
107
108
builder . AppendWithStyle ( styles . Parenthesis , ")" ) ;
@@ -168,7 +169,7 @@ private static void AppendPath(StringBuilder builder, string path, ExceptionSett
168
169
void AppendPath ( )
169
170
{
170
171
var shortenPaths = ( settings . Format & ExceptionFormats . ShortenPaths ) != 0 ;
171
- builder . Append ( Emphasize ( path , new [ ] { '/' , '\\ ' } , settings . Style . Path , shortenPaths , settings ) ) ;
172
+ Emphasize ( builder , path , new [ ] { '/' , '\\ ' } , settings . Style . Path , shortenPaths , settings ) ;
172
173
}
173
174
174
175
if ( ( settings . Format & ExceptionFormats . ShowLinks ) != 0 )
@@ -192,32 +193,25 @@ void AppendPath()
192
193
}
193
194
}
194
195
195
- private static string Emphasize ( string input , char [ ] separators , Style color , bool compact ,
196
- ExceptionSettings settings )
196
+ private static void Emphasize ( StringBuilder builder , string input , char [ ] separators , Style color , bool compact ,
197
+ ExceptionSettings settings , char ? limit = null )
197
198
{
198
- var builder = new StringBuilder ( ) ;
199
+ var limitIndex = limit . HasValue ? input . IndexOf ( limit . Value ) : - 1 ;
199
200
200
- var type = input ;
201
- var index = type . LastIndexOfAny ( separators ) ;
201
+ var index = limitIndex != - 1 ? input [ ..limitIndex ] . LastIndexOfAny ( separators ) : input . LastIndexOfAny ( separators ) ;
202
202
if ( index != - 1 )
203
203
{
204
204
if ( ! compact )
205
205
{
206
- builder . AppendWithStyle (
207
- settings . Style . NonEmphasized ,
208
- type . Substring ( 0 , index + 1 ) ) ;
206
+ builder . AppendWithStyle ( settings . Style . NonEmphasized , input [ ..( index + 1 ) ] ) ;
209
207
}
210
208
211
- builder . AppendWithStyle (
212
- color ,
213
- type . Substring ( index + 1 , type . Length - index - 1 ) ) ;
209
+ builder . AppendWithStyle ( color , input [ ( index + 1 ) ..] ) ;
214
210
}
215
211
else
216
212
{
217
- builder . Append ( type . EscapeMarkup ( ) ) ;
213
+ builder . AppendWithStyle ( color , input ) ;
218
214
}
219
-
220
- return builder . ToString ( ) ;
221
215
}
222
216
223
217
private static bool ShowInStackTrace ( StackFrame frame )
0 commit comments