ToString() public method

public ToString ( ) : string
return string
 /// <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();
 }
Beispiel #2
0
		internal static void TraceStackFrame(int steps)
		{
			string name = null;
			GetCurrentMethodName(2, ref name);
			string trace = "";
			for(int i=1;i<steps;i++)
			{
				System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(i, true);
				trace += sf.ToString();
			}
			System.Diagnostics.Trace.WriteLine(trace, name);
			System.Diagnostics.Trace.WriteLine("");
		}
Beispiel #3
0
        public static string GetStackTrace()
        {
            System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(1);
            StringBuilder msg = new StringBuilder();

            for (int i = 0; i < st.FrameCount; i++)
            {
                System.Diagnostics.StackFrame sf = st.GetFrame(i);

                msg.AppendLine(sf.ToString());
            }

            return(msg.ToString());
        }
Beispiel #4
0
        internal static void TraceStackFrame(int steps)
        {
            string name = null;

            GetCurrentMethodName(2, out name);
            string trace = "";

            for (int i = 1; i < steps; i++)
            {
                System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(i, true);
                trace += sf.ToString();
            }
            System.Diagnostics.Trace.WriteLine(trace, name);
            System.Diagnostics.Trace.WriteLine("");
        }
Beispiel #5
0
        /// <summary>
        /// 指定された内容をログに出力します。
        /// </summary>
        /// <param name="msg">ログに出力する内容</param>
        public void Print(String msg)
        {
            try
            {
                FileOpen();
                FileWrite(msg);

                if (TraceTriggerText.Length > 0)
                {
                    if (msg.IndexOf(TraceTriggerText) >= 0)
                    {
                        // 情報
                        FileWrite("Track trace ==>");
                        System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
                        for (int i = 0; i < st.FrameCount; i++)
                        {
                            System.Diagnostics.StackFrame sf = st.GetFrame(i);
                            FileWrite("   - " + sf.ToString().Replace("\r\n", ""));
                        }
                    }
                }
            }
            catch (Exception es)
            {
                try
                {
                    FileWrite(EXCEPTION_MESSAGE + es.Message);
                }
                catch
                {
                }
            }
            finally
            {
                FileClose();
            }
        }
Beispiel #6
0
 private void WriteDebugComment()
 {
     if (Debugger.IsAttached)
     {
         var zed = new StackFrame(2, true);
         _builder.WriteLine("// {0}", zed.ToString());
     }
 }
Beispiel #7
0
		public void StackFrame_Path_Leak ()
		{
			StackFrame sf = new StackFrame ("/path/to/the/source/file.cs", 1);
			Assert.IsFalse (sf.ToString ().Contains ("path/to/the/source"), "no path leaked");
			Assert.IsTrue (sf.ToString ().Contains ("file.cs"), "filename");
		}
Beispiel #8
0
		public void StackFrame_FileName_Leak ()
		{
			StackFrame sf = new StackFrame ("/path/to/the/source/file.cs", 1);
			Assert.IsTrue (sf.ToString ().Contains ("<filename unknown>"), "no file name leaked");
		}
Beispiel #9
0
 public static string GetCurrentLocation(int skip_frames)
 {
     StackFrame sf = new StackFrame(skip_frames + 1, true);
     return sf.ToString();
 }