Skip to content

Commit ec10429

Browse files
RozzaysRedRowse
andauthored
Remove PortablePdbReader except trace cleanup (#19957)
* Remove PortablePdbReader except trace cleanup Co-authored-by: Rowse <[email protected]>
1 parent 56d50e6 commit ec10429

File tree

2 files changed

+31
-188
lines changed

2 files changed

+31
-188
lines changed

src/Shared/StackTrace/StackFrame/PortablePdbReader.cs

Lines changed: 0 additions & 135 deletions
This file was deleted.

src/Shared/StackTrace/StackFrame/StackTraceHelper.cs

Lines changed: 31 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -25,70 +25,48 @@ public static IList<StackFrameInfo> GetFrames(Exception exception, out Aggregate
2525
return frames;
2626
}
2727

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)
2933
{
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+
}
3337

34-
if (stackFrames == null)
35-
{
36-
error = default;
37-
return frames;
38-
}
38+
List<Exception> exceptions = null;
3939

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();
4144

42-
for (var i = 0; i < stackFrames.Length; i++)
45+
// Always show last stackFrame
46+
if (!ShowInStackTrace(method) && i < stackFrames.Length - 1)
4347
{
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;
8149
}
8250

83-
if (exceptions != null)
51+
var stackFrame = new StackFrameInfo
8452
{
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+
};
8858

89-
error = default;
59+
frames.Add(stackFrame);
60+
}
61+
62+
if (exceptions != null)
63+
{
64+
error = new AggregateException(exceptions);
9065
return frames;
9166
}
67+
68+
error = default;
69+
return frames;
9270
}
9371

9472
internal static MethodDisplayInfo GetMethodDisplayString(MethodBase method)

0 commit comments

Comments
 (0)