[Mono-list] Implementing attribute-based code generation

George Birbilis George Birbilis" <birbilis@kagi.com
Thu, 13 Jan 2005 17:48:27 +0200


> [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;
> }

a problem may be that the text in the precondition etc. would need special 
IDE support for IntelliSense etc.
if it was in the code block instead of being a string it would be better 
maybe

-----
George Birbilis (birbilis@kagi.com)
http://www.kagi.com/birbilis
--------------