6

Dynamic Proxy Generation

In the previous chapters, we looked at how powerful it is to have the type of metadata that the .NET runtime provides us with, combining that with the power of creating your own metadata, the capability to analyze it, and turn it into useful information or take actions based on it. We’re now going to explore even further and let code make new code based on metadata.

In this chapter, we will look into how we can take advantage of the fact that your code runs in a managed runtime environment and how that can be used to create new code at runtime after your code has been compiled.

We will cover the following topics:

  • An introduction to IL and Reflection.Emit
  • Creating a dynamic assembly and module
  • Virtual members and overrides ...

Get Metaprogramming in C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.