@@ -25,70 +25,48 @@ public static IList<StackFrameInfo> GetFrames(Exception exception, out Aggregate
25
25
return frames ;
26
26
}
27
27
28
- using ( var portablePdbReader = new PortablePdbReader ( ) )
28
+ var needFileInfo = true ;
29
+ var stackTrace = new System . Diagnostics . StackTrace ( exception , needFileInfo ) ;
30
+ var stackFrames = stackTrace . GetFrames ( ) ;
31
+
32
+ if ( stackFrames == null )
29
33
{
30
- var needFileInfo = true ;
31
- var stackTrace = new System . Diagnostics . StackTrace ( exception , needFileInfo ) ;
32
- var stackFrames = stackTrace . GetFrames ( ) ;
34
+ error = default ;
35
+ return frames ;
36
+ }
33
37
34
- if ( stackFrames == null )
35
- {
36
- error = default ;
37
- return frames ;
38
- }
38
+ List < Exception > exceptions = null ;
39
39
40
- List < Exception > exceptions = null ;
40
+ for ( var i = 0 ; i < stackFrames . Length ; i ++ )
41
+ {
42
+ var frame = stackFrames [ i ] ;
43
+ var method = frame . GetMethod ( ) ;
41
44
42
- for ( var i = 0 ; i < stackFrames . Length ; i ++ )
45
+ // Always show last stackFrame
46
+ if ( ! ShowInStackTrace ( method ) && i < stackFrames . Length - 1 )
43
47
{
44
- var frame = stackFrames [ i ] ;
45
- var method = frame . GetMethod ( ) ;
46
-
47
- // Always show last stackFrame
48
- if ( ! ShowInStackTrace ( method ) && i < stackFrames . Length - 1 )
49
- {
50
- continue ;
51
- }
52
-
53
- var stackFrame = new StackFrameInfo
54
- {
55
- StackFrame = frame ,
56
- FilePath = frame . GetFileName ( ) ,
57
- LineNumber = frame . GetFileLineNumber ( ) ,
58
- MethodDisplayInfo = GetMethodDisplayString ( frame . GetMethod ( ) ) ,
59
- } ;
60
-
61
- if ( string . IsNullOrEmpty ( stackFrame . FilePath ) )
62
- {
63
- try
64
- {
65
- // .NET Framework and older versions of mono don't support portable PDBs
66
- // so we read it manually to get file name and line information
67
- portablePdbReader . PopulateStackFrame ( stackFrame , method , frame . GetILOffset ( ) ) ;
68
- }
69
- catch ( Exception ex )
70
- {
71
- if ( exceptions is null )
72
- {
73
- exceptions = new List < Exception > ( ) ;
74
- }
75
-
76
- exceptions . Add ( ex ) ;
77
- }
78
- }
79
-
80
- frames . Add ( stackFrame ) ;
48
+ continue ;
81
49
}
82
50
83
- if ( exceptions != null )
51
+ var stackFrame = new StackFrameInfo
84
52
{
85
- error = new AggregateException ( exceptions ) ;
86
- return frames ;
87
- }
53
+ StackFrame = frame ,
54
+ FilePath = frame . GetFileName ( ) ,
55
+ LineNumber = frame . GetFileLineNumber ( ) ,
56
+ MethodDisplayInfo = GetMethodDisplayString ( frame . GetMethod ( ) ) ,
57
+ } ;
88
58
89
- error = default ;
59
+ frames . Add ( stackFrame ) ;
60
+ }
61
+
62
+ if ( exceptions != null )
63
+ {
64
+ error = new AggregateException ( exceptions ) ;
90
65
return frames ;
91
66
}
67
+
68
+ error = default ;
69
+ return frames ;
92
70
}
93
71
94
72
internal static MethodDisplayInfo GetMethodDisplayString ( MethodBase method )
0 commit comments