2007-11-30 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mcs / class / corlib / System.Diagnostics / StackTrace.cs
index bebf216d981dec2b3415fd8fb35f0d6ad4f2cc01..404056c2c4e3bb4ef699abd03be3e76e5760b2f3 100644 (file)
@@ -41,7 +41,10 @@ using System.Threading;
 namespace System.Diagnostics {
 
        [Serializable]
-       [MonoTODO ("Fix serialization compatibility with MS.NET")]
+#if NET_2_0
+       [ComVisible (true)]
+#endif
+       [MonoTODO ("Serialized objects are not compatible with .NET")]
        public class StackTrace {
 
                public const int METHODS_TO_SKIP = 0;
@@ -152,7 +155,7 @@ namespace System.Diagnostics {
 #if ONLY_1_1
                [ReflectionPermission (SecurityAction.Demand, TypeInformation = true)]
 #endif
-               [MonoTODO]
+               [MonoTODO ("Not possible to create StackTraces from other threads")]
                public StackTrace (Thread targetThread, bool needFileInfo)
                {
                        throw new NotImplementedException ();
@@ -193,11 +196,34 @@ namespace System.Diagnostics {
                        StringBuilder sb = new StringBuilder ();
                        for (int i = 0; i < FrameCount; i++) {
                                StackFrame frame = GetFrame (i);
-                               sb.Append (newline);
+                               if (i > 0)
+                                       sb.Append (newline);
+                               else
+                                       sb.AppendFormat ("   {0} ", Locale.GetText ("at"));
                                MethodBase method = frame.GetMethod ();
                                if (method != null) {
                                        // Method information available
-                                       sb.AppendFormat ("{0}.{1} ()", method.DeclaringType.FullName, method.Name);
+                                       sb.AppendFormat ("{0}.{1}", method.DeclaringType.FullName, method.Name);
+                                       /* Append parameter information */
+                                       sb.Append ("(");
+                                       ParameterInfo[] p = method.GetParameters ();
+                                       for (int j = 0; j < p.Length; ++j) {
+                                               if (j > 0)
+                                                       sb.Append (", ");
+                                               Type pt = p[j].ParameterType;
+                                               bool byref = pt.IsByRef;
+                                               if (byref)
+                                                       pt = pt.GetElementType ();
+                                               if (pt.IsClass && pt.Namespace != String.Empty) {
+                                                       sb.Append (pt.Namespace);
+                                                       sb.Append (".");
+                                               }
+                                               sb.Append (pt.Name);
+                                               if (byref)
+                                                       sb.Append (" ByRef");
+                                               sb.AppendFormat (" {0}", p [j].Name);
+                                       }
+                                       sb.Append (")");
                                }
                                else {
                                        // Method information not available