本文整理汇总了C#中System.Diagnostics.StackFrame.GetFileColumnNumber方法的典型用法代码示例。如果您正苦于以下问题:C# StackFrame.GetFileColumnNumber方法的具体用法?C# StackFrame.GetFileColumnNumber怎么用?C# StackFrame.GetFileColumnNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.StackFrame
的用法示例。
在下文中一共展示了StackFrame.GetFileColumnNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExceptionFrame
/// <summary>
/// Initializes a new instance of the <see cref="ExceptionFrame"/> class.
/// </summary>
/// <param name="frame">The <see cref="StackFrame"/>.</param>
public ExceptionFrame(StackFrame frame)
{
if (frame == null)
return;
int lineNo = frame.GetFileLineNumber();
if (lineNo == 0)
{
//The pdb files aren't currently available
lineNo = frame.GetILOffset();
}
var method = frame.GetMethod();
if (method != null)
{
Module = (method.DeclaringType != null) ? method.DeclaringType.FullName : null;
Function = method.Name;
Source = method.ToString();
}
else
{
// on some platforms (e.g. on mono), StackFrame.GetMethod() may return null
// e.g. for this stack frame:
// at (wrapper dynamic-method) System.Object:lambda_method (System.Runtime.CompilerServices.Closure,object,object))
Module = "(unknown)";
Function = "(unknown)";
Source = "(unknown)";
}
Filename = frame.GetFileName();
LineNumber = lineNo;
ColumnNumber = frame.GetFileColumnNumber();
}
示例2: ConeStackFrame
public ConeStackFrame(StackFrame frame)
{
Method = frame.GetMethod();
File = frame.GetFileName();
Line = frame.GetFileLineNumber();
Column = frame.GetFileColumnNumber();
}
示例3: FileName_LineNumber_ColumnNumber
public void FileName_LineNumber_ColumnNumber ()
{
StackFrame sf = new StackFrame (String.Empty, Int32.MinValue, Int32.MaxValue);
Assert.AreEqual (Int32.MinValue, sf.GetFileLineNumber (), "GetFileLineNumber");
Assert.AreEqual (Int32.MaxValue, sf.GetFileColumnNumber (), "GetFileColumnNumber");
Assert.IsTrue (sf.GetILOffset () >= 0, "GetILOffset");
Assert.IsTrue (sf.GetNativeOffset () > 0, "GetNativeOffset");
Assert.AreEqual ("FileName_LineNumber_ColumnNumber", sf.GetMethod ().Name, "GetMethod");
}
示例4: Default
public void Default ()
{
StackFrame sf = new StackFrame ();
Assert.AreEqual (0, sf.GetFileLineNumber (), "GetFileLineNumber");
Assert.AreEqual (0, sf.GetFileColumnNumber (), "GetFileColumnNumber");
Assert.IsTrue (sf.GetILOffset () >= 0, "GetILOffset");
Assert.IsTrue (sf.GetNativeOffset () >= 0, "GetNativeOffset");
Assert.AreEqual ("Default", sf.GetMethod ().Name, "GetMethod");
}
示例5: FaultStackFrame
/// <summary>
/// Creates a new instance of the <see cref="WcfRawJson.ErrorHandling.FaultStackFrame"/>
/// class from an existing <see cref="System.Diagnostics.StackFrame"/>.
/// </summary>
/// <param name="frame">
/// The <see cref="System.Diagnostics.StackFrame"/> object from which to derive this
/// <see cref="WcfRawJson.ErrorHandling.StackFrame"/>
/// </param>
public FaultStackFrame(StackFrame frame)
{
this.FileColumnNumber = frame.GetFileColumnNumber();
this.FileLineNumber = frame.GetFileLineNumber();
this.FileName = frame.GetFileName();
this.ILOffset = frame.GetILOffset();
this.Method = frame.GetMethod().ToString();
this.NativeOffset = frame.GetNativeOffset();
this.Description = frame.ToString();
}
示例6: assert
public static void assert(bool pCondition)
{
if (!pCondition)
{
StackFrame frame = new StackFrame(1, true);
var message = string.Format("Line: {0}\r\nColumn: {1}\r\nWhere:{2}",
frame.GetFileLineNumber(),
frame.GetFileColumnNumber(),
frame.GetMethod().Name);
throw new Exception(message);
}
}
示例7: isNull
public static void isNull(object pObject)
{
if (pObject == null)
{
StackFrame frame = new StackFrame(1, true);
var message = string.Format("Line: {0}\r\nColumn: {1}\r\nWhere:{2}",
frame.GetFileLineNumber(),
frame.GetFileColumnNumber(),
frame.GetMethod().Name);
throw new NullReferenceException(message);
}
}
示例8: Check
// avoid replication of tests on all constructors (this is no
// problem because the stack is already set correctly). The
// goal is to call every property and methods to see if they
// have any* security requirements (*except for LinkDemand and
// InheritanceDemand).
private void Check (StackFrame sf, bool checkFile)
{
int cn = sf.GetFileColumnNumber ();
int ln = sf.GetFileLineNumber ();
int il = sf.GetILOffset ();
int no = sf.GetNativeOffset ();
Assert.IsNotNull (sf.GetMethod (), "GetMethod");
if (checkFile) {
string fn = sf.GetFileName ();
}
}
示例9: StackFrameToString
public static string StackFrameToString(StackFrame stackFrame)
{
StringBuilder sb = new StringBuilder();
int intParam; MemberInfo mi = stackFrame.GetMethod();
sb.Append(" ");
sb.Append(mi.DeclaringType.Namespace);
sb.Append(".");
sb.Append(mi.DeclaringType.Name);
sb.Append(".");
sb.Append(mi.Name);
// -- build method params
sb.Append("(");
intParam = 0;
foreach (ParameterInfo param in stackFrame.GetMethod().GetParameters())
{
intParam += 1;
sb.Append(param.Name);
sb.Append(" As ");
sb.Append(param.ParameterType.Name);
}
sb.Append(")");
sb.Append(Environment.NewLine);
// -- if source code is available, append location info
sb.Append(" ");
if (string.IsNullOrEmpty(stackFrame.GetFileName()))
{
sb.Append("(unknown file)");
//-- native code offset is always available
sb.Append(": N ");
sb.Append(string.Format("{0:#00000}", stackFrame.GetNativeOffset()));
}
else
{
sb.Append(Path.GetFileName(stackFrame.GetFileName()));
sb.Append(": line ");
sb.Append(string.Format("{0:#0000}", stackFrame.GetFileLineNumber()));
sb.Append(", col ");
sb.Append(string.Format("{0:#00}", stackFrame.GetFileColumnNumber()));
if (stackFrame.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
{
sb.Append(", IL ");
sb.Append(string.Format("{0:#0000}", stackFrame.GetILOffset()));
}
}
sb.Append(Environment.NewLine);
return sb.ToString();
}
示例10: GetStackFrameInfo
public static string GetStackFrameInfo(StackFrame frame, TraceInfo traceInfo)
{
if (frame != null)
{
switch (traceInfo)
{
case TraceInfo.LineNumber:
return frame.GetFileLineNumber().ToString();
case TraceInfo.FileName:
return frame.GetFileName();
case TraceInfo.Method:
return frame.GetMethod().Name;
case TraceInfo.ColumnNumber:
return frame.GetFileColumnNumber().ToString();
case TraceInfo.Full:
return new StackTrace(frame).ToString();
}
}
return "Error: StackFrame==null";
}
示例11: ExceptionFrame
/// <summary>
/// Initializes a new instance of the <see cref="ExceptionFrame"/> class.
/// </summary>
/// <param name="frame">The <see cref="StackFrame"/>.</param>
public ExceptionFrame(StackFrame frame)
{
if (frame == null)
return;
int lineNo = frame.GetFileLineNumber();
if (lineNo == 0)
{
//The pdb files aren't currently available
lineNo = frame.GetILOffset();
}
var method = frame.GetMethod();
Filename = frame.GetFileName();
Module = (method.DeclaringType != null) ? method.DeclaringType.FullName : null;
Function = method.Name;
Source = method.ToString();
LineNumber = lineNo;
ColumnNumber = frame.GetFileColumnNumber();
}
示例12: BuildExceptionFrame
private static ExceptionFrame BuildExceptionFrame(StackFrame frame)
{
int lineNo = frame.GetFileLineNumber();
if (lineNo == 0)
{
//The pdb files aren't currently available
lineNo = frame.GetILOffset();
}
var method = frame.GetMethod();
return new ExceptionFrame()
{
Filename = frame.GetFileName(),
Module = (method.DeclaringType != null) ? method.DeclaringType.FullName : null,
Function = method.Name,
Source = method.ToString(),
LineNumber = lineNo,
ColumnNumber = frame.GetFileColumnNumber()
};
}
示例13: StackFrameToString
//--
//-- turns a single stack frame object into an informative string
//--
private static string StackFrameToString(StackFrame sf)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int intParam = 0;
MemberInfo mi = sf.GetMethod();
var _with1 = sb;
//-- build method name
_with1.Append(" ");
_with1.Append(mi.DeclaringType.Namespace);
_with1.Append(".");
_with1.Append(mi.DeclaringType.Name);
_with1.Append(".");
_with1.Append(mi.Name);
//-- build method params
ParameterInfo[] objParameters = sf.GetMethod().GetParameters();
ParameterInfo objParameter = null;
_with1.Append("(");
intParam = 0;
foreach (ParameterInfo objParameter_loopVariable in objParameters)
{
objParameter = objParameter_loopVariable;
intParam += 1;
if (intParam > 1)
_with1.Append(", ");
_with1.Append(objParameter.Name);
_with1.Append(" As ");
_with1.Append(objParameter.ParameterType.Name);
}
_with1.Append(")");
_with1.Append(Environment.NewLine);
//-- if source code is available, append location info
_with1.Append(" ");
if (sf.GetFileName() == null || sf.GetFileName().Length == 0)
{
_with1.Append(System.IO.Path.GetFileName(ParentAssembly().CodeBase));
//-- native code offset is always available
_with1.Append(": N ");
_with1.Append(string.Format("{0:#00000}", sf.GetNativeOffset()));
}
else
{
_with1.Append(System.IO.Path.GetFileName(sf.GetFileName()));
_with1.Append(": line ");
_with1.Append(string.Format("{0:#0000}", sf.GetFileLineNumber()));
_with1.Append(", col ");
_with1.Append(string.Format("{0:#00}", sf.GetFileColumnNumber()));
//-- if IL is available, append IL location info
if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
{
_with1.Append(", IL ");
_with1.Append(string.Format("{0:#0000}", sf.GetILOffset()));
}
}
_with1.Append(Environment.NewLine);
return sb.ToString();
}
示例14: FieldLogStackFrame
/// <summary>
/// Initialises a new instance of the FieldLogStackFrame class.
/// </summary>
/// <param name="stackFrame">The StackFrame instance.</param>
public FieldLogStackFrame(StackFrame stackFrame)
{
MethodBase method = stackFrame.GetMethod();
if (method.DeclaringType != null)
{
Module = method.DeclaringType.Module.FullyQualifiedName;
Token = method.MetadataToken;
ILOffset = stackFrame.GetILOffset();
TypeName = FormatTypeName(method.DeclaringType);
}
MethodName = method.Name;
// TODO: Include 'extern' indicator from the following tests (needs new file format)
//bool isPInvoke = (method.Attributes & MethodAttributes.PinvokeImpl) != 0;
//bool isInternalCall = (method.GetMethodImplementationFlags() & MethodImplAttributes.InternalCall) != 0;
MethodInfo methodInfo = method as MethodInfo;
StringBuilder sigSb = new StringBuilder();
if (methodInfo != null)
{
sigSb.Append(FormatTypeName(methodInfo.ReturnType));
}
else
{
sigSb.Append("void"); // Dummy return value for constructors
}
ParameterInfo[] parameters = method.GetParameters();
sigSb.Append("(");
for (int i = 0; i < parameters.Length; i++)
{
if (i > 0)
{
sigSb.Append(", ");
}
sigSb.Append(FormatTypeName(parameters[i].ParameterType));
}
sigSb.Append(")");
MethodSignature = sigSb.ToString();
FileName = stackFrame.GetFileName();
Line = stackFrame.GetFileLineNumber();
Column = stackFrame.GetFileColumnNumber();
Size = (Module != null ? Module.Length * 2 : 0) +
(TypeName != null ? TypeName.Length * 2 : 0) +
(MethodName != null ? MethodName.Length * 2 : 0) +
(MethodSignature != null ? MethodSignature.Length * 2 : 0) +
(FileName != null ? FileName.Length * 2 : 0) +
4 + 4;
}
示例15: GetColumnNumber
/// <summary>
/// 获取追踪信息所在列
/// </summary>
/// <param name="frame"></param>
/// <returns></returns>
public static String GetColumnNumber(StackFrame frame)
{
const String unknow = "NULL";
if (frame == null) return unknow;
var columnNumber = frame.GetFileColumnNumber();
return String.IsNullOrEmpty(columnNumber.ToString(CultureInfo.InvariantCulture))
? unknow
: columnNumber.ToString(CultureInfo.InvariantCulture);
}