[Mono-list] Implementing attribute-based code generation
Stephen Touset
stephen@touset.org
Wed, 12 Jan 2005 22:36:08 -0500
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 != null")]
[Postcondition("size > 0")]
void AddObject(Object o) {
// ... do stuff ...
return;
}
Which would then at compile time insert
void AddObject(Object o) {
Check.Require(o != null);
// ... do stuf ...
Check.Ensure(size > 0);
return;
}
While also obeying design by contract inheritance rules.