Generating Code Dynamically

  • Simon Robinson


In this chapter I’ll cover a significant, though often underused, feature that’s offered by the.NET Framework classes—the ability to generate either source code or IL code dynamically. In other words, you can have your code actually write or manipulate code instead of data. Normally, you’d conceptually imagine that the process of producing a software application involves you writing the source code, compiling it, and shipping it—and that’s it. The code and resources your organization wrote constitutes the totality of the shipped product. With dynamic code generation, however, your shipped code can itself actually generate new code to perform additional tasks—this can be useful for performance reasons, among other factors. Alternatively, your code may modify the code in other assemblies (which maybe done, for example, to insert calls to create debugging or profiling information). And obviously, if your product is a developer tool that’s intended to assist developers in writing code, then it may be called on to generate some source code itself.


Source Code Unify Modeling Language Regular Expression Type Reference Developer Tool 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Simon Robinson 2004

Authors and Affiliations

  • Simon Robinson

There are no affiliations available

Personalised recommendations