Fix from Matt Kunze to add the other Process.Start overloads
[mono.git] / mcs / class / System / System.Diagnostics / Debug.cs
index 5c48908dba3518043664f455278c5d98243610c8..73ead2ee832b6c50b103066fa2a48822ce7cd9d8 100644 (file)
-//\r
-// System.Diagnostics.Debug.cs\r
-//\r
-// Author: John R. Hicks <angryjohn69@nc.rr.com>\r
-//\r
-// (C) 2002\r
-//\r
-using System;\r
-\r
-namespace System.Diagnostics\r
-{\r
-       \r
-       /// <summary>\r
-       /// Provides a set of methods to help debug code\r
-       /// </summary>\r
-       public sealed class Debug\r
-       {\r
-               private static bool autoFlush;\r
-               private static int indentLevel;\r
-               private static int indentSize;\r
-               private static TraceListenerCollection listeners;\r
-               \r
-               static Debug()\r
-               {\r
-                       autoFlush = false;\r
-                       indentLevel = 0;\r
-                       indentSize = 4;\r
-                       listeners = new TraceListenerCollection();\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Gets or sets value indicating whether Flush should\r
-               /// be called on the listeners.\r
-               /// </summary>\r
-               public static bool AutoFlush\r
-               {\r
-                       get\r
-                       {\r
-                               return autoFlush;\r
-                       }\r
-                       set\r
-                       {\r
-                               autoFlush = value;\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Gets or sets indent level\r
-               /// </summary>\r
-               public static int IndentLevel\r
-               {\r
-                       get\r
-                       {\r
-                               return indentLevel;\r
-                       }\r
-                       set\r
-                       {\r
-                               indentLevel = value;\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// The number of spaces in an indent.\r
-               /// </summary>\r
-               public static int IndentSize\r
-               {\r
-                       get\r
-                       {\r
-                               return indentSize;\r
-                       }\r
-                       set\r
-                       {\r
-                               indentSize = value;\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Returns the listeners collection\r
-               /// </summary>\r
-               public static TraceListenerCollection Listeners\r
-               {\r
-                       get\r
-                       {\r
-                               return listeners;\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Checks for a condition, and prints a stack trace\r
-               /// if the condition is false.\r
-               /// </summary>\r
-               public static void Assert(bool condition)\r
-               {\r
-                       if(!condition) {\r
-                               WriteLine(new StackTrace().ToString());         \r
-                       }\r
-                       \r
-               }\r
-               \r
-               /// <summary>\r
-               /// Checks for a condition, and displays a message if the condition\r
-               /// is false.\r
-               /// </summary>\r
-               public static void Assert(bool condition, string message)\r
-               {\r
-                       if(!condition) {\r
-                               WriteLine(message);             \r
-                               \r
-                       }\r
-                       \r
-               }\r
-               \r
-               /// <summary>\r
-               /// Checks for a condtion, and displays a message and a detailed message\r
-               /// string if the condition is false.\r
-               /// </summary>\r
-               public static void Assert(bool condition, string message, string detailMessage)\r
-               {\r
-                       if(!condition) {\r
-                               WriteLine(message);\r
-                               Indent();\r
-                               WriteLine(detailMessage);\r
-                               Unindent();\r
-                               \r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Closes the Debug buffer\r
-               /// </summary>\r
-               public static void Close()\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.Close();\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Emits the specified error message.\r
-               /// </summary>\r
-               public static void Fail(string message)\r
-               {\r
-                       WriteLine(message);\r
-                       \r
-               }\r
-               \r
-               /// <summary>\r
-               /// Emits the specified error message and detailed error message.\r
-               /// </summary>\r
-               public static void Fail(string message, string detailMessage)\r
-               {\r
-                       WriteLine(message);\r
-                       Indent();\r
-                       WriteLine(detailMessage);\r
-                       Unindent();\r
-                       \r
-               }\r
-               \r
-               /// <summary>\r
-               /// Flushes the listeners\r
-               /// </summary>\r
-               public static void Flush()\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.Flush();\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Increments the indent level\r
-               /// </summary>\r
-               public static void Indent()\r
-               {\r
-                       indentLevel++;  \r
-               }\r
-               \r
-               /// <summary>\r
-               /// Decrements the indent level\r
-               /// </summary>\r
-               public static void Unindent()\r
-               {\r
-                       if(indentLevel == 0)\r
-                               return;\r
-                       else\r
-                               indentLevel--;\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the value of the specified object's ToString method\r
-               /// to the listeners.\r
-               /// </summary>\r
-               public static void Write(object value)\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.Write(value.ToString());\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the specified message to each listener in the Listeners collection.\r
-               /// </summary>\r
-               public static void Write(string message)\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.Write(message);\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the category name and value of the specified object's\r
-               /// ToString method to each listener in the Listeners collection.\r
-               /// </summary>\r
-               public static void Write(object value, string category)\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.Write("[" + category + "] " + value.ToString());\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the category name and the specified message\r
-               /// to each listener in the Listeners collection.\r
-               /// </summary>\r
-               public static void Write(string message, string category)\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.Write("[" + category + "] " + message);\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the value of the specified object's ToString method\r
-               /// to each of the listeners if the condition is true.\r
-               /// </summary>\r
-               public static void WriteIf(bool condition, object value)\r
-               {\r
-                       if(condition)\r
-                       {\r
-                               foreach(TraceListener l in listeners)\r
-                               {\r
-                                       l.Write(value.ToString());\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the specified message to each of the listeners\r
-               /// if the specified condition is true.\r
-               /// </summary>\r
-               public static void WriteIf(bool condition, string message)\r
-               {\r
-                       if(condition)\r
-                       {\r
-                               foreach(TraceListener l in listeners)\r
-                               {\r
-                                       l.Write(message);\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the value of the specified object's ToString message\r
-               /// and category to each of the listeners if the condition is true.\r
-               /// </summary>\r
-               public static void WriteIf(bool condition, object value, string category)\r
-               {\r
-                       if(condition)\r
-                       {\r
-                               foreach(TraceListener l in listeners)\r
-                               {\r
-                                       l.Write("[" + category + "] " + value.ToString());\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the category and specified message to each listener\r
-               /// if the specified condition is true.\r
-               /// </summary>\r
-               public static void WriteIf(bool condition, string message, string category)\r
-               {\r
-                       if(condition)\r
-                       {\r
-                               foreach(TraceListener l in listeners)\r
-                               {\r
-                                       l.Write("[" + category + "] " + message);\r
-                               }\r
-                       }\r
-                       \r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the value of the object's ToString method,\r
-               /// followed by a line terminator, to each listener.\r
-               /// </summary>\r
-               public static void WriteLine(object value)\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.WriteLine(value.ToString());\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the specified message, followed by a line terminator,\r
-               /// to each listener.\r
-               /// </summary>\r
-               public static void WriteLine(string message)\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.WriteLine(message);\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the value of the specified object's ToString method,\r
-               /// along with a category, followed by a line terminator, to each listener.\r
-               /// </summary>\r
-               public static void WriteLine(object value, string category)\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.WriteLine("[" + category + "] " + value.ToString());\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the specified category and message, followed by a line terminator,\r
-               /// to each listener.\r
-               /// </summary>\r
-               public static void WriteLine(string message, string category)\r
-               {\r
-                       foreach(TraceListener l in listeners)\r
-                       {\r
-                               l.WriteLine("[" + category + "] " + message);\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the value of the object's ToString method\r
-               /// to each listener if the specified condition is true.\r
-               /// </summary>\r
-               public static void WriteLineIf(bool condition, object value)\r
-               {\r
-                       if(condition)\r
-                       {\r
-                               foreach(TraceListener l in listeners)\r
-                               {\r
-                                       l.WriteLine(value.ToString());\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the specified message to each listener\r
-               /// if the specified condition is true.\r
-               /// </summary>\r
-               public static void WriteLineIf(bool condition, string message)\r
-               {\r
-                       if(condition)\r
-                       {\r
-                               foreach(TraceListener l in listeners)\r
-                               {\r
-                                       l.WriteLine(message);\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the value of the object's ToString method, and a category\r
-               /// to each listener if the specified condition is true.\r
-               /// </summary>\r
-               public static void WriteLineIf(bool condition, object value, string category)\r
-               {\r
-                       if(condition)\r
-                       {\r
-                               foreach(TraceListener l in listeners)\r
-                               {\r
-                                       l.WriteLine("[" + category + "] " + value.ToString());\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// Writes the specified category and message to each listener, followed by a line\r
-               /// terminator, if the specified condition is true.\r
-               /// </summary>\r
-               public static void WriteLineIf(bool condition, string message, string category)\r
-               {\r
-                       if(condition)\r
-                       {\r
-                               foreach(TraceListener l in listeners)\r
-                               {\r
-                                       l.WriteLine("[" + category + "] " + message);\r
-                               }\r
-                       }\r
-                       \r
-               }\r
-       }\r
-}\r
+//
+// System.Diagnostics.Debug.cs
+//
+// Authors:
+//   Jonathan Pryor (jonpryor@vt.edu)
+//
+// Comments from John R. Hicks <angryjohn69@nc.rr.com> original implementation 
+// can be found at: /mcs/docs/apidocs/xml/en/System.Diagnostics
+//
+// (C) 2002
+//
+
+using System;
+using System.Diagnostics;
+
+namespace System.Diagnostics {
+
+       public sealed class Debug {
+
+               private Debug () {}
+
+               public static bool AutoFlush {
+                       get {return TraceImpl.AutoFlush;}
+                       set {TraceImpl.AutoFlush = value;}
+               }
+
+               public static int IndentLevel {
+                       get {return TraceImpl.IndentLevel;}
+                       set {TraceImpl.IndentLevel = value;}
+               }
+
+               public static int IndentSize {
+                       get {return TraceImpl.IndentSize;}
+                       set {TraceImpl.IndentSize = value;}
+               }
+
+               public static TraceListenerCollection Listeners {
+                       get {return TraceImpl.Listeners;}
+               }
+
+               [Conditional("DEBUG")]
+               public static void Assert (bool condition)
+               {
+                       TraceImpl.Assert (condition);
+               }
+
+               [Conditional("DEBUG")]
+               public static void Assert (bool condition, string message)
+               {
+                       TraceImpl.Assert (condition, message);
+               }
+
+               [Conditional("DEBUG")]
+               public static void Assert (bool condition, string message, 
+                       string detailMessage)
+               {
+                       TraceImpl.Assert (condition, message, detailMessage);
+               }
+
+               [Conditional("DEBUG")]
+               public static void Close ()
+               {
+                       TraceImpl.Close ();
+               }
+
+               [Conditional("DEBUG")]
+               public static void Fail (string message)
+               {
+                       TraceImpl.Fail (message);
+               }
+
+               [Conditional("DEBUG")]
+               public static void Fail (string message, string detailMessage)
+               {
+                       TraceImpl.Fail (message, detailMessage);
+               }
+
+               [Conditional("DEBUG")]
+               public static void Flush ()
+               {
+                       TraceImpl.Flush ();
+               }
+
+               [Conditional("DEBUG")]
+               public static void Indent ()
+               {
+                       TraceImpl.Indent ();
+               }
+
+               [Conditional("DEBUG")]
+               public static void Unindent ()
+               {
+                       TraceImpl.Unindent ();
+               }
+
+               [Conditional("DEBUG")]
+               public static void Write (object value)
+               {
+                       TraceImpl.Write (value);
+               }
+
+               [Conditional("DEBUG")]
+               public static void Write (string message)
+               {
+                       TraceImpl.Write (message);
+               }
+
+               [Conditional("DEBUG")]
+               public static void Write (object value, string category)
+               {
+                       TraceImpl.Write (value, category);
+               }
+
+               [Conditional("DEBUG")]
+               public static void Write (string message, string category)
+               {
+                       TraceImpl.Write (message, category);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteIf (bool condition, object value)
+               {
+                       TraceImpl.WriteIf (condition, value);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteIf (bool condition, string message)
+               {
+                       TraceImpl.WriteIf (condition, message);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteIf (bool condition, object value, 
+                       string category)
+               {
+                       TraceImpl.WriteIf (condition, value, category);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteIf (bool condition, string message, 
+                       string category)
+               {
+                       TraceImpl.WriteIf (condition, message, category);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLine (object value)
+               {
+                       TraceImpl.WriteLine (value);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLine (string message)
+               {
+                       TraceImpl.WriteLine (message);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLine (object value, string category)
+               {
+                       TraceImpl.WriteLine (value, category);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLine (string message, string category)
+               {
+                       TraceImpl.WriteLine (message, category);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLineIf (bool condition, object value)
+               {
+                       TraceImpl.WriteLineIf (condition, value);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLineIf (bool condition, string message)
+               {
+                       TraceImpl.WriteLineIf (condition, message);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLineIf (bool condition, object value, 
+                       string category)
+               {
+                       TraceImpl.WriteLineIf (condition, value, category);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLineIf (bool condition, string message, 
+                       string category)
+               {
+                       TraceImpl.WriteLineIf (condition, message, category);
+               }
+       }
+}
+