[Mono-list] Debug.Assert - a cross-platform issue
inorton at gmail.com
Sun Mar 9 13:34:06 UTC 2014
Anyway.. The reason why it is false by default is that there is no
trace listener enabled by default.
You can enable it in several ways.
1. export MONO_TRACE_LISTENER=Console.Error
2. Adding one.
var tl = new System.Diagnostics.ConsoleTraceListener();
System.Diagnostics.Debug.Listeners.Add ( tl );
3. using the xml config mentioned earlier.
On 9 March 2014 10:58, "Andrés G. Aragoneses" <knocte at gmail.com> wrote:
> On 09/03/14 06:28, MarLOne wrote:
>> Hi all,
>> I have found out the run time discrepancy of Debug.Assert() in CLR and in
>> Mono. The answer literally is in front of our eyes.
>> The difference is in this property:
>> In *CLR* the default value is *true* but in *Mono* the default value is set
>> to *false*. If you disassembly the system assembly, you will see that in
> By disassembling Microsoft's code, you've rendered yourself unable to
> contribute to Mono (at least around the area of the API you're talking
> about). Next time, read this first:
>> Mono, the DefaultTraceListener.Fail() already contains GUI code to report
>> the failure if the above mentioned property is true. Since the default value
>> is set to false, it does not report any failure condition.
>> Hence there are two ways of fixing it:
>> 1) In code just do this (surround it with conditional compilation control) :
>> (Debug.Listeners["Default"] as DefaultTraceListener).AssertUiEnabled = true;
>> 2) In a config file like this:
>> <?xml version="1.0" encoding="utf-8"?>
>> <assert assertuienabled="true" />
>> This setting is superfluous in CLR but is harmless hence the same config
>> file can be used in both platform.
>> If you are performing cross platform checking, make sure you include the
>> configuration setting to avoid the disappointment. This highlights the
>> importance to maintain default values consistence.
>> Hope this will help and may be someone maintaining this part of the code to
>> consider restoring that consistence.
>> View this message in context: http://mono.1490590.n4.nabble.com/Debug-Assert-a-cross-platform-issue-tp4662174p4662183.html
>> Sent from the Mono - General mailing list archive at Nabble.com.
>> Mono-list maillist - Mono-list at lists.ximian.com
> Mono-list maillist - Mono-list at lists.ximian.com
More information about the Mono-list