contents

foreword
preface
acknowledgments
about this book
about the cover illustration

Part 1 Demystifying metaprogramming

Chapter 1 Metaprogramming concepts
Definitions of metaprogramming
Examples of metaprogramming
Summary
Chapter 2 Exploring code and metadata with reflection
The need for reflection
Reading metadata and executing code
Impractical uses of reflection
Practical uses of reflection
Summary

Part 2 Techniques for generating code

Chapter 3 The Text Template Transformation Toolkit (T4)
Thinking of generics as templates
Introducing T4
More useful T4 examples
T4 fundamentals
Using T4 inside Visual Studio
Summary
Chapter 4 Generating code with the CodeDOM
Understanding the CodeDOM
The code provider classes
Adding objects to a code graph
Metaprogramming with the CodeDOM
Summary
Chapter 5 Generating code with Reflection.Emit
Why Emitter classes?
An overview of assembly internals
A lightning tour of opcodes
Creating dynamic assemblies
Lightweight code generation with dynamic methods
Summary
Chapter 6 Generating code with expressions
Expression-oriented programming
Making dynamic methods with LINQ Expressions
Using expressions effectively
Evolving expression trees
Summary
Chapter 7 Generating code with IL rewriting
The case for code injection
Creating an injection framework
Debugging injected code
Summary

Part 3 Languages and tools

Chapter 8 The Dynamic Language Runtime
The simplest dynamic classes
The DLR hosting model
Summary
Chapter 9 Languages and tools
A survey of languages
A survey of tools
Summary
Chapter 10 Managing the .NET Compiler
Opening up the compiler
Understanding the basics of Roslyn
Interacting with code in Visual Studio
Summary

appendix A Metaprogramming in Windows 8
appendix B Usage guide
                   index