[Mono-list] Design by Contract

Stephen Touset stephen@touset.org
Wed, 29 Dec 2004 13:04:21 -0500

Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Tue, 2004-12-28 at 20:31 -0500, Joshua Tauberer wrote:
> I've thought about this a few times and even tried hacking some
> rudimentary DBC support into Mono using attributes.  The difficulty in
> this depends on what you want out of DBC.  I was going for something that
> would see contract violations at compile time (which turned out to be way
> over my head, so I didn't get far).  Just adding assertions automatically
> would be much easier, or even easy.

I was just looking for runtime checking of contract violations, not

> Adding pre/post-condition assertions would just mean going into the parts
> of mcs for methods and properties, looping through the attributes on the
> method/parameters, and adding some object creations (to instantiate the
> attributes) and method invocations (to have the attribute perform the
> check) in the generated IL.  Not much, really.

Well...this was actually my next step: adding support in mcs. However, I
don't really have the desire to maintain a fork of mcs, and I was hoping
to test the water to see if this is something that the mono folks would
be opposed to, since it's not strictly C#.

=46rom rom what I can tell, there appears to be no way to add the ability to
do DBC-like checking to C# programs without modifying the compiler
itself. A perl script could theoretically just convert attributes into
code, but contract inheritance quickly becomes a thorny issue.

So, is support for DBC something that anyone would be willing to see in
mcs? Is it even something the mcs folks would allow as a patch, or would
I need to maintain a separate fork of mcs (something I'm not really
willing to do)?

Stephen Touset <stephen@touset.org>

Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

Version: GnuPG v1.2.5 (GNU/Linux)