Bug 3754 - Debug.Assert doesn't do anything
Summary: Debug.Assert doesn't do anything
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-05 10:36 UTC by Matt Jones
Modified: 2012-03-29 18:48 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Matt Jones 2012-03-05 10:36:49 UTC
As far as I can tell, Debug.Assert doesn't give any popup or console trace - it doesn't appear to do anything.

Is this a bug, by design or a config issue in MonoDevelop? If it's by design, I think that is a mistake as the .NET environments that developers will be coming from handle it quite differently (a popup.)

I don't think a popup would be helpful but the option to throw an exception so we can catch it *at the time* would be very useful.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-03-28 21:23:58 UTC
You can easily do this yourself by implementing a subclass of System.Diagnostics.TraceListener and add it to Debug.Listeners.

If you want an exception to be thrown, just make your ExceptionalTraceListener throw an exception in the Fail implementation.
Comment 2 Matt Jones 2012-03-29 04:16:11 UTC
That sounds like good advice but I can't find TraceListener in System.Diagnostics.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-03-29 18:48:42 UTC
This has been fixed now (mobile-master: 185961ba, master: 976279, 2.10: 9d103ff).

The fix will be included in MonoTouch 5.3.3.

By default Debug.Assert will print the assertion to Console.Out, but you can use TraceListeners do basically do whatever you want.