// Copyright (c) Ben A Adams. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Reflection;
namespace System.Diagnostics
{
public class EnhancedStackFrame : StackFrame
{
private string _fileName;
private int _lineNumber;
private int _colNumber;
public StackFrame StackFrame { get; }
public ResolvedMethod MethodInfo { get; }
internal EnhancedStackFrame(StackFrame stackFrame, ResolvedMethod methodInfo, string fileName, int lineNumber, int colNumber)
: base(fileName, lineNumber, colNumber)
{
StackFrame = stackFrame;
MethodInfo = methodInfo;
_fileName = fileName;
_lineNumber = lineNumber;
_colNumber = colNumber;
}
///
/// Gets the column number in the file that contains the code that is executing.
/// This information is typically extracted from the debugging symbols for the executable.
///
/// The file column number, or 0 (zero) if the file column number cannot be determined.
public override int GetFileColumnNumber() => _colNumber;
///
/// Gets the line number in the file that contains the code that is executing.
/// This information is typically extracted from the debugging symbols for the executable.
///
/// The file line number, or 0 (zero) if the file line number cannot be determined.
public override int GetFileLineNumber() => _lineNumber;
///
/// Gets the file name that contains the code that is executing.
/// This information is typically extracted from the debugging symbols for the executable.
///
/// The file name, or null if the file name cannot be determined.
public override string GetFileName() => _fileName;
///
/// Gets the offset from the start of the Microsoft intermediate language (MSIL)
/// code for the method that is executing. This offset might be an approximation
/// depending on whether or not the just-in-time (JIT) compiler is generating debugging
/// code. The generation of this debugging information is controlled by the System.Diagnostics.DebuggableAttribute.
///
/// The offset from the start of the MSIL code for the method that is executing.
public override int GetILOffset() => StackFrame.GetILOffset();
///
/// Gets the method in which the frame is executing.
///
/// The method in which the frame is executing.
public override MethodBase GetMethod() => StackFrame.GetMethod();
///
/// Gets the offset from the start of the native just-in-time (JIT)-compiled code
/// for the method that is being executed. The generation of this debugging information
/// is controlled by the System.Diagnostics.DebuggableAttribute class.
///
/// The offset from the start of the JIT-compiled code for the method that is being executed.
public override int GetNativeOffset() => StackFrame.GetNativeOffset();
///
/// Builds a readable representation of the stack trace.
///
/// A readable representation of the stack trace.
public override string ToString() => MethodInfo.ToString();
}
}