[Mono-list] Debug.Assert(): usable in current form?

Chris Seaton chris at chrisseaton.com
Fri Dec 29 15:37:23 EST 2006


I asked the same questions a while ago and was told how to turn on  
console output and so on. Why can't Mono be set up to handle asserts  
by default in exactly the same way as MS .Net? It's obviously  
confusing people.

Chris

On 29 Dec 2006, at 12:03, Paul Melis wrote:

> Hi there,
>
> After two hours of bug hunting in my ray-tracer code with mono 1.2.2 I
> found that System.Diagnostics.Debug.Assert() isn't called without
> compiling sources with #define DEBUG (or corresponding (g)mcs flag).
>
> Fine.
>
> After setting the flag and still not getting any output in a case I  
> was
> sure there should be some -- Debug.Assert(false) -- I managed to  
> find in
> a bug report that mentioned there is no output at all by default!
>
> This is not mentioned in the FAQ, on the wiki or in the documentation.
>
> After adding a ConsoleTraceListener to fix this I finally get  
> output for
> the failed assertions but there are no line number in the output...
>
> SIGH
>
> Is there a way to get failing asserts to print their line numbers  
> to the
> console?? And yes, I am compiling and running with -debug/--debug
>
> Here's a small example program
>
> // t.cs
> #define DEBUG
> #define TRACE
>
> using System;
> using System.Diagnostics;
>
> class Test
> {
>      public static void Main()
>      {
>          Debug.Listeners.Add(new ConsoleTraceListener());
>
>          Debug.Assert(false);
>      }
> };
>
> When compiled with
>
> gmcs -out:t.exe -debug t.cs
>
> and run with
>
> mono --debug t.exe
>
> I get
>
> ---- DEBUG ASSERTION FAILED ----
> ---- Assert Short Message ----
>
>     at System.Diagnostics.TraceImpl.Assert ()
>     at System.Diagnostics.Debug.Assert ()
>     at Test.Main ()
> ---- Assert Long Message ----
>
> I.e. no line numbers. Without those my assert statements are  
> useless as
> there are several within the same method.
>
> Paul
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list



More information about the Mono-list mailing list