[Mono-list] Implementing attribute-based code generation

Kamil Skalski nazgul@nemerle.org
Thu, 13 Jan 2005 10:08:51 +0100


Dnia czwartek, 13 stycznia 2005 04:36, Stephen Touset napisa=C5=82:
> Rodrigo B. de Oliveira wrote:
> >It sounds like you are talking about what we call syntactic attributes.
>
> I couldn't tell from the website. Essentially, I am trying to add design
> by contract support to the mono C# compiler (as an extension, rather
> than a core patch to mcs). The best way to do this would seem to be to
> have attributes that can modify methods. In other words:
>
> [Precondition("o !=3D null")]
> [Postcondition("size > 0")]
> void AddObject(Object o) {
>     // ... do stuff ...
>     return;
> }

If you do not need to stick with C#, then look what we do about this in=20
Nemerle:
http://nemerle.org/macrouse.html#designbycontract

>
> Which would then at compile time insert
>
> void AddObject(Object o) {
>     Check.Require(o !=3D null);
>     // ... do stuf ...
>     Check.Ensure(size > 0);
>     return;
> }
>
> While also obeying design by contract inheritance rules.

This is still not implemented, but there are no real stopers from doing thi=
s.