[Mono-dev] Patch 1/2 - System.Diagnostics.Contracts in corlib

Chris Bacon chris at dunelm.org.uk
Thu Jun 17 07:32:58 EDT 2010

Hi Marek,

Some of the existing code was protected by "#if NET_2_1 || NET_4_0" 
(e.g. PureAttribute)
And other parts of the code were always compiled, but made internal if 
not NET_2_1 or NET_4_0 (e.g. Contract.cs)
So I left these as they are, and did the same in new files that I 
introduced, which meant the call to Environment.FailFast() had to have 
the additional "#if NET_4_0".
However, if it would be better to change all files to be completely 
surrounded by "#if NET_4_0" then please let me know.

The private exception class ContractException is specified in the MS 
See sections 7.6, 7.3, 7.4
And I have verified what I have implemented is the same as MS.

The private exception class ContractShouldAssertException is because, in 
some circumstances, the code should Assert, but there appears to be no 
simple way to do this from within corlib, so I throw this exception 
instead. However, this will never occur because it is guarded by "if 
(Environment.UserInteractive)" which currently always returns false. I 
have put a FIXME comment at both places in the code where this is done. 
If there is a better way to implement this, please let me know.

Kind regards

Marek Safar wrote:
> Hello,
> Few comments from me
> - All code is #if NET_4_0 there is no need for further nested #if
> - Why did you have to introduce private exception classes ?
> Marek
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-
>>>> bounces at lists.ximian.com] Im Auftrag von Chris Bacon
>>>> Gesendet: Mittwoch, 16. Juni 2010 12:03
>>>> An: Marek Safar
>>>> Cc: mono-devel-list at lists.ximian.com
>>>> Betreff: Re: [Mono-dev] Patch 1/2 - System.Diagnostics.Contracts in
>>>> corlib
>>>> Hi,
>>>> Attached is a new, improved, patch that keeps existing formatting.
>>>> Sorry for the mistake.
>>>> Kind regards
>>>> Chris
>>>> Marek Safar wrote:
>>>>> Hi Chris,
>>>>>> Attached is a patch to corlib containing updates the
>>>>>> System.Diagnostics.Contracts as part of the GSoC work I am doing.
>>>>>> I'm sure there will be parts of this I haven't done quite right, so
>>>>>> please let me know what they are, and I'll sort them out.
>>>>> Can you keep existing formatting, most of the changes are about
>>>>> changing tabs to spaces. Please send a new set of patches without any
>>>>> noise (lines you have not changed)
>>>>> Thanks
>>>>> Marek

More information about the Mono-devel-list mailing list