I have been curious about dynamically create class at runtime in C# and stumbled across this article. http://olondono.blogspot.com/2008/02/creating-code-at-runtime.html I am curious to hear some pros and cons regarding construction of a class at runtime.
Any opinions?
Meta-programming has all the advantages of build-time code-gneneration, but without the additional code step. This is very common in library code, such as ORMs, serializers, some types of AOP, DI/IoC containers, etc.
DynamicMethodcan be associated with a type; fully generated (dll) code would require[InternalsVisibleTo]or similar, which may be impossibleI’m currently re-writing an existing library to use runtime IL generation; it is very rewarding and I’m happy with it; but it is unlike anything I’ve written before.