[Mono-list] Implementing attribute-based code generation

Shawn Vose mono@programmerforrent.com
Wed, 12 Jan 2005 20:19:41 -0500


Stephen Touset wrote:

>I'm looking into the potential of writing code to allow mono to have
>extensions. As a first foray into the idea, I'm going to try writing a
>module that would look for specific attributes on methods and classes,
>and use those to generate code that would go into the marked methods and
>all methods of the marked classes, respectively.
>
>However, looking at the mono source code, it seems to be very complex.
>I'm looking for hints as to the best place to put the hooks for the
>extension, because of this. My first idea would be to put this after the
>parsing of the source tree, so that I can manipulate the methods as
>they're in memory. However, I can't seem to find simple ways to navigate
>through the memory representation of the source tree. Can anyone give me
>a brief pointer to where I should be looking?
>
>  
>
Use System.Reflection to read available methods, attributes and 
properties for a dll. You can use it to do so at runtime. I know there 
has been a few questions and answers on Relection in the archives