[Mono-bugs] [Bug 71947][Nor] Changed - Debug.Assert not working out of the box

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 31 Jan 2005 07:53:04 -0500 (EST)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jonpryor@vt.edu.


--- shadow/71947	2005-01-29 12:38:52.000000000 -0500
+++ shadow/71947.tmp.29141	2005-01-31 07:53:04.000000000 -0500
@@ -1,14 +1,14 @@
 Bug#: 71947
 Product: Mono: Class Libraries
 Version: 1.0
+OS: unknown
 OS Details: 
-Status: NEW   
+Status: RESOLVED   
+Severity: Unknown
 Priority: Normal
 Component: System
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: matze@braunis.de               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
@@ -23,6 +23,68 @@
 1. The program isn't aborted after the listeners have been called.
 2. There's no listener registered by default. There should be a listener
 which displays something on stderr.
 So in effect your application will just continue silently which isn't
 really what assert should do.
+------- Additional Comments From jonpryor@vt.edu  2005-01-31 07:53 -------
+Debug.Assert isn't fully implemented yet, but not for the reasons you
+specify. :-)
+To answer your issues:
+1.  Isn't necessarily supposed to happen; more below.
+2.  The DefaultTraceListener is registered by default, it's just
+producing no output.  Set the MONO_TRACE environment value to view its
+output on the console, e.g. export MONO_TRACE=Console.Error:+++.
+See the DefaultTraceListener documentation for more information:
+Not killing the program when an assertion fails is mostly in keeping
+with what .NET does.
+If you try the following program under .NET:
+	// test Debug.Assert behavior
+	using System;
+	using System.Diagnostics;
+	class Test {
+		public static void Main ()
+		{
+			Console.WriteLine ("Begin");
+			Debug.Assert (false);
+			Console.WriteLine ("End");
+		}
+	}
+Compile with "csc /d:DEBUG da.cs", run as "da.exe", .NET will display
+a dialog box:
+	Title: Assertion Failed: Abort=Quit, Retry=Debug, 
+		Ignore=Continue
+	at Test.Main
+	[Abort] [Retry] [Ignore]
+[Ignore] is the default button.  If [Ignore] is selected, you see both
+"Begin" and "End" printed to the console.  [Retry] starts a debugger,
+and [Abort] quits the program.
+Furthermore, no assertion message is displayed to the console; .NET
+uses OutputDebugString instead, so a utility such as sysinternal's
+DbgView or a debugger must be used to view it.
+The current mono default is [Ignore], which is why the program isn't
+Consequently, the *real* missing behavior is the display of the dialog
+box asking the user what to do, and will likely remain missing until
+someone gets bored enough to tackle the issue of which toolkit to use
+(should it be a System.Windows.Forms dialog?  Or Gtk#?  Or Qt#?  Or
+wx.NET?  And how to select which one?).
+If you really need the program to be terminated when an assertion
+fails, create a new TraceListener and override both TraceListener.Fail
+methods to call Environment.Exit.  You can then use the application
+.config file to add this listener to the Debug.Listeners collection.