© Nick Harrison 2017

Nick Harrison, Code Generation with Roslyn, 10.1007/978-1-4842-2211-9_7

7. Reflecting on Generated Code

Nick Harrison

(1)Lexington, South Carolina, USA

Generated code will always be code that was not known at compile time. The whole point of generating code is to make it easier to change the business rules after deployment. This is where reflection comes in. Reflection allows you to access metadata about your code at runtime. With it, you can load an assembly, discover the types in the assembly, create an instance of these types, and systematically execute any method discovered in these types. This is exactly what you need to evaluate new business logic.

Reflection may seem like magic, but it really is a matter of carefully ...

Get Code Generation with Roslyn now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.