What this book covers
Chapter 1, How Can Metaprogramming Benefit You?, dives into what metaprogramming is and how it can improve developers’ day-to-day work. It gives some concrete basic examples to explain its capabilities.
Chapter 2, Metaprogramming Concepts, provides explanations of the differences between implicit and explicit metadata through concrete examples. In addition, it gives an insight into how the .NET runtime works.
Chapter 3, Demystifying through Existing Real-World Examples, shows how Microsoft, as an example, leverages metaprogramming and how you probably already use it.
Chapter 4, Reasoning about Types Using Reflection, provides an overview of how powerful the .NET runtime reflection is and how its implicit metadata can be leveraged.
Chapter 5, Leveraging Attributes, introduces leveraging C# attributes as an explicit metaprogramming technique and how it can be used, giving real-world applicable examples.
Chapter 6, Dynamic Proxy Generation, introduces code that generates code, at runtime. A powerful concept that can really boost your developers’ productivity if used wisely.
Chapter 7, Reasoning about Expressions, provides an introduction to C# and .NET expression trees, how they represent a different aspect of metadata, and how they can be reasoned about and unpacked in your code.
Chapter 8, Building and Executing Expressions, provides an introduction to how you can build your own expressions at runtime and how these can be executed – an alternative technique to generating code.
Chapter 9, Taking Advantage of the Dynamic Language Runtime, covers what the Dynamic Language Runtime is and how it can be used to dynamically generate code – yet another alternative for your code is to create code.
Chapter 10, Convention over Configuration, unravels the superpower of conventions – code that repeats the patterns you probably already have, enabling your developers to become more productive and your code base to become more consistent.
Chapter 11, Applying the Open-Closed Principle, provides a dive into how you can create code bases that are open to extension but closed for modification – a powerful principle for maintainable software, using metaprogramming as an angle into it.
Chapter 12, Go Beyond Inheritance, provides another level on top of regular conventions, giving developers an opportunity to not just be limited by what the programming language offers, aiming for readability and maintainability.
Chapter 13, Applying Cross-Cutting Concerns, unlocks the concept of applying code consistently across an entire code base without having to revert to manual recipes.
Chapter 14, Aspect-Oriented Programming, provides details on the formalization of aspect-oriented programming and how this can help you provide cross-cutting concerns as a more formal technique.
Chapter 15, Roslyn Compiler Extensions, details the basics of what the .NET compiler SDK offers and how to get started with it, serving as the basis for the following chapters.
Chapter 16, Generating Code, provides an introduction to how you can generate code using code at the compiler level before you enter runtime – yet another great way to improve your developers’ productivity and provide consistency in your code base.
Chapter 17, Static Code Analysis, provides an introduction to how you can build your own rules that perform analysis on any code being added to your project, helping you create consistent, uniform, and more maintainable code.
Chapter 18, Caveats and Final Words, looks into what the book has covered, what benefits there are, and what caveats there are. As with anything, you have to strike the right balance and know what to use when.