当前位置: 首页>>代码示例>>C#>>正文


C# StackFrame.GetFileColumnNumber方法代码示例

本文整理汇总了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();
        }
开发者ID:getsentry,项目名称:raven-csharp,代码行数:39,代码来源:ExceptionFrame.cs

示例2: ConeStackFrame

 public ConeStackFrame(StackFrame frame)
 {
     Method = frame.GetMethod();
     File = frame.GetFileName();
     Line = frame.GetFileLineNumber();
     Column = frame.GetFileColumnNumber();
 }
开发者ID:drunkcod,项目名称:Cone,代码行数:7,代码来源:ConeStackFrame.cs

示例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");
		}
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:StackFrameTest.cs

示例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");
		}
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:StackFrameTest.cs

示例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();
 }
开发者ID:ZaneKaminski,项目名称:wcf-raw-json,代码行数:18,代码来源:FaultStackFrame.cs

示例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);
     }
 }
开发者ID:substans,项目名称:GameTypes,代码行数:12,代码来源:D.cs

示例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);
     }
 }
开发者ID:substans,项目名称:GameTypes,代码行数:12,代码来源:D.cs

示例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 ();
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:18,代码来源:StackFrameCas.cs

示例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();
 }
开发者ID:Microshaoft,项目名称:Microshaoft.Common.Utilities.Net.4x,代码行数:47,代码来源:StackTraceHelper.cs

示例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";
 }
开发者ID:wind0ws,项目名称:DotNetLog,代码行数:20,代码来源:StackTraceHelper.cs

示例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();
        }
开发者ID:ehvattum,项目名称:raven-csharp,代码行数:25,代码来源:ExceptionFrame.cs

示例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()
            };
        }
开发者ID:jalaziz,项目名称:raven-csharp,代码行数:21,代码来源:SentryStacktrace.cs

示例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();
        }
开发者ID:maz0r,项目名称:jmmserver,代码行数:62,代码来源:UnhandledExceptionManager.cs

示例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;
        }
开发者ID:modulexcite,项目名称:FieldLog,代码行数:55,代码来源:Exceptions.cs

示例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);
 }
开发者ID:caocf,项目名称:workspace-kepler,代码行数:14,代码来源:LogManager.cs


注:本文中的System.Diagnostics.StackFrame.GetFileColumnNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。