[Mono-list] If you are writing a gnome/gtk application, should you avoid

Jonathan Pryor jonpryor@vt.edu
Sun, 02 May 2004 17:15:44 -0400


On Sat, 2004-05-01 at 09:48, Thomas R. Corbin wrote:
> using Debug.Assert?   In MS .NET, I believe that Debug.Assert pops up a window 
> using WinForms, but wouldn't that be a problem if you are writing a gtk 
> application?   Is there a way to plug in your own AssertHandler?

Debug.Assert and Trace.Assert have been implemented.  Their current
implementation *does not* pop up a WinForms dialog; instead, Assert just
calls Fail if the condition is false, which writes the failure message
to the console.

Thus, at present, using Debug.Assert shouldn't cause any problems,
though calling Debug.Assert won't stop program execution either (so
you'll likely get exceptions later in the code due to the failed
assertions).

In the future, this may change.  TraceImpl.Assert  (the underlying
implementation of Debug.Assert and Trace.Assert) is marked with the
MonoTODO attribute, mentioning that MSDN states that a dialog box should
be displayed.  I'm not aware of any efforts to implement this
functionality, though.

Additionally, we could provide both Gtk# and SWF implementations, and
call one depending on which assemblies have been loaded (defaulting to
the terminal if neither set of assemblies have been loaded).  This
should be a straightforward implementation, except for all the
reflection this approach would require (so that System.dll doesn't have
any explicit dependencies on System.Windows.Forms.dll or gtk-sharp.dll).

Thus, in principal, you shouldn't avoid using Debug.Assert in Gtk#
applications.  If this becomes a problem due to future development, it
should be fixed; we shouldn't have to avoid using part of the framework
just because we're writing a Gtk# app.

 - Jon