O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lightweight Code Generation

In the first generation of .NET, no facilities were provided to generate code at runtime, despite the fact that some portions of the runtime could take advantage of such a thing. For example, the object serialization stack has historically relied on the invocation of the C# compiler at runtime to generate some helper assemblies based on the object types that occur in the input. Although this works fine, the additional step of generating C# code and feeding it through a compiler just to obtain an assembly seems largely redundant if we have some common code representation based on IL already.

Starting with .NET 2.0, services to emit code at runtime (and save or execute it) have been added to the framework. Known as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required