Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Simplify StackFrame class (dotnet/coreclr#23483)
Browse files Browse the repository at this point in the history
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
marek-safar authored and jkotas committed Mar 29, 2019
1 parent 4f87f4f commit 8a2ce7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 62 deletions.
66 changes: 6 additions & 60 deletions src/System.Private.CoreLib/shared/System/Diagnostics/StackFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// See the LICENSE file in the project root for more information.

using System.Text;
using System;
using System.IO;
using System.Reflection;

namespace System.Diagnostics
Expand Down Expand Up @@ -53,13 +51,8 @@ public partial class StackFrame

private void InitMembers()
{
_method = null;
_nativeOffset = OFFSET_UNKNOWN;
_ilOffset = OFFSET_UNKNOWN;
_fileName = null;
_lineNumber = 0;
_columnNumber = 0;
_isLastFrameFromForeignExceptionStackTrace = false;
}

/// <summary>
Expand All @@ -68,7 +61,7 @@ private void InitMembers()
public StackFrame()
{
InitMembers();
BuildStackFrame(0 + StackTrace.METHODS_TO_SKIP, false);
BuildStackFrame(StackTrace.METHODS_TO_SKIP, false);
}

/// <summary>
Expand All @@ -77,7 +70,7 @@ public StackFrame()
public StackFrame(bool needFileInfo)
{
InitMembers();
BuildStackFrame(0 + StackTrace.METHODS_TO_SKIP, needFileInfo);
BuildStackFrame(StackTrace.METHODS_TO_SKIP, needFileInfo);
}

/// <summary>
Expand Down Expand Up @@ -106,10 +99,10 @@ public StackFrame(int skipFrames, bool needFileInfo)
public StackFrame(string fileName, int lineNumber)
{
InitMembers();

BuildStackFrame(StackTrace.METHODS_TO_SKIP, false);
_fileName = fileName;
_lineNumber = lineNumber;
_columnNumber = 0;
}

/// <summary>
Expand All @@ -118,11 +111,8 @@ public StackFrame(string fileName, int lineNumber)
/// use the debugger's line mapping logic.
/// </summary>
public StackFrame(string fileName, int lineNumber, int colNumber)
: this (fileName, lineNumber)
{
InitMembers();
BuildStackFrame(StackTrace.METHODS_TO_SKIP, false);
_fileName = fileName;
_lineNumber = lineNumber;
_columnNumber = colNumber;
}

Expand All @@ -131,45 +121,7 @@ public StackFrame(string fileName, int lineNumber, int colNumber)
/// </summary>
public const int OFFSET_UNKNOWN = -1;

internal virtual void SetMethodBase(MethodBase mb)
{
_method = mb;
}

internal virtual void SetOffset(int iOffset)
{
_nativeOffset = iOffset;
}

internal virtual void SetILOffset(int iOffset)
{
_ilOffset = iOffset;
}

internal virtual void SetFileName(string strFName)
{
_fileName = strFName;
}

internal virtual void SetLineNumber(int iLine)
{
_lineNumber = iLine;
}

internal virtual void SetColumnNumber(int iCol)
{
_columnNumber = iCol;
}

internal virtual void SetIsLastFrameFromForeignExceptionStackTrace(bool fIsLastFrame)
{
_isLastFrameFromForeignExceptionStackTrace = fIsLastFrame;
}

internal virtual bool GetIsLastFrameFromForeignExceptionStackTrace()
{
return _isLastFrameFromForeignExceptionStackTrace;
}
internal bool IsLastFrameFromForeignExceptionStackTrace => _isLastFrameFromForeignExceptionStackTrace;

/// <summary>
/// Returns the method the frame is executing
Expand Down Expand Up @@ -278,13 +230,7 @@ public override string ToString()
sb.Append(_nativeOffset);

sb.Append(" in file:line:column ");

bool useFileName = (_fileName != null);

if (!useFileName)
sb.Append("<filename unknown>");
else
sb.Append(_fileName);
sb.Append(_fileName ?? "<filename unknown>");
sb.Append(':');
sb.Append(_lineNumber);
sb.Append(':');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ internal string ToString(TraceFormat traceFormat)
}
}

if (sf.GetIsLastFrameFromForeignExceptionStackTrace() &&
!isAsync) // Skip EDI boundary for async
// Skip EDI boundary for async
if (sf.IsLastFrameFromForeignExceptionStackTrace && !isAsync)
{
sb.Append(Environment.NewLine);
sb.Append(SR.Exception_EndStackTraceFromPreviousThrow);
Expand Down

0 comments on commit 8a2ce7c

Please sign in to comment.