System.Diagnostics.Debug.Listeners.Clear();This code does not show a dialog box with the assert information because the default listener has been removed. It is completely possibly to add custom listeners that perform whatever behaviour is required.
System.Diagnostics.Debug.Assert(false);
However, the weirdness is that when using the Contract.Assert() method in System.Diagnostics.Contracts namespace, the assert behaviour cannot be modified using the Listeners collection. Although it appears to be a normal assert, it cannot be - it does not use the Debug.Listeners collection to define its behaviour, and there doesn't appear to be any other Listeners collection that could effect the behaviour.
Therefore the following code:
System.Diagnostics.Debug.Listeners.Clear();shows an assert dialog box.
System.Diagnostics.Contracts.Contract.Assert(false);
This means it is not possible to run a test on the Microsoft implementation which uses a custom listener to check that the asserts generated are correct. So my strategy of running a set of tests against the Microsoft implementation and my implementation to ensure they produce the same behaviour is not going to work.
Alas.
statically check code contracts working from mono develop would be very cool. It would also provide a competitive advantage to monodevelop. Statically checked code contracts are only available in the very expensive MSDN licences.
ReplyDelete