7
Reasoning about Expressions
So far, we’ve looked at the powerful metadata that is captured and how we can access it using reflection. We’ve also looked at how we can leverage this same metadata and generate code on the fly at runtime.
Using reflection and generating code as techniques in metaprogramming are extremely powerful, but they’re not applicable to all scenarios. It can also be very involved and produce hard-to-read and maybe even hard-to-maintain code going deep with reflection and proxy generation.
C# expressions can, for a lot of scenarios, represent a better approach or an additional approach for specific scenarios for doing runtime discovery and extraction of metadata.
We will cover the following topics in this chapter:
- What ...
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.