[Mono-dev] Inconsistent value in System.Diagnostics.DefaultTraceListener.AssertUiEnabled

MarLOne InfoSeeker002 at gmail.com
Fri Mar 14 12:42:30 UTC 2014


I am running "Mono JIT compiler version (Debian"
in Mint-15 Cinnamon (64-bits) and also in Ubuntu 12.04 LTS (32-bits). My
development is using MonoDevelop 4.2.2 and obtained from PPA

The problem is frequently reported in the Mono-forum complaining
Debug.Assert( false ) never stop and and warn user when the assertion fails.

The function System.Diagnostics.Debug.Assert(bool, string) is not at fault
as I have disassembled the Mono code. The fault lies in the property value
of *System.Diagnostics.DefaultTraceListener.AssertUiEnabled* which is
default to *false* in *Mono* while in *CLR's runtime code* it is default to

Here is the way to check cross-platform consistency:
1) Create a console application Windows/CLR containing the following code
if( (System.Diagnostics.Debug.Listeners["Default"] as
DefaultTraceListener).AssertUiEnabled == false )
  throw new Exception( "Wrong Default Value" );

Do not use NUnit to perform this test as NUnit automatically setting this
value to false so that user's Debug.Assert() does not interfere with the
NUnit.Framework.Assert class' operations. By default, it is written to
console in NUnit.

Attached is the MonoDevelop project called VerifyAssertUiEnabled.zip

2) Run the console application in Windows and you should see *NO* exception.

3) Take the console application to Linux with Mono runtime installed and run
it, you will see the Exception telling the property value is different.

You can restore the consistency between CLR and Mono so that
Debug.Assert(false) will not be silenced  in Mono in the following way:
1) In Code
DefaultTraceListener defListener = Debug.Listeners["Default"] as
if( defListener != null )
   // available
   defListener.AssertUiEnabled = true;

2) Using a configuration file with the following contents (this is harmless
in CLR)
<?xml version="1.0" encoding="utf-8"?>
       <assert assertuienabled="true" />

Clearly the default value in DefaultTraceListener.AssertUiEnabled is
producing inconsistent run time behaviour between CLR and Mono. Perhaps it
is due to the fact the developer has forgotten to initialise the
DefaultTraceListener.AssertUiEnabled value.


View this message in context: http://mono.1490590.n4.nabble.com/Inconsistent-value-in-System-Diagnostics-DefaultTraceListener-AssertUiEnabled-tp4662230.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list