---
title: "My Tech-Ed Talk: Deep Reflection - What's new & Hot in Reflection 2.0"
url: "https://osherove.com/blog/2006/4/22/my-tech-ed-talk-deep-reflection-whats-new-amp-hot-in-reflect.md"
canonical: "https://osherove.com/blog/2006/4/22/my-tech-ed-talk-deep-reflection-whats-new-amp-hot-in-reflect.html"
published: "2006-04-22T23:27:00"
updated: "2006-04-22T23:27:00"
tags: []
author: "Roy Osherove"
description: "My upcoming Tech-Ed Talk in Israel will be all about what’s new and Cool in .NET 2.0 Reflection. Over the coming weeks until TechEd, I’ll supply links and information detailing the stuff I’ll be talking about. For the…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# My Tech-Ed Talk: Deep Reflection - What's new & Hot in Reflection 2.0

By Roy Osherove April 22, 2006

**Historical article** · Originally published April 22, 2006; technical details may be outdated.

My upcoming [Tech-Ed Talk in Israel](http://www.microsoft.com/israel/teched) will be all about what’s new and Cool in .NET 2.0 Reflection. Over the coming weeks until TechEd, I’ll supply links and information detailing the stuff I’ll be talking about.

For the past three weeks or so I’ve been totally immersed in Reflection-Land.

There are seriously cool things going on behind the scenes, and, frankly,  I was surprised at the amount of new stuff that is now possible.

One of my favorite features is the new ability to reflection over a Method’s Body. That is, get the actually IL for the method in the form of a Byte Array. You can then parse the IL and do what ever you want with it (including building your own version of reflector, for example).

This is possible due to a new API added on the MethodBase class, called: “GetMethodBody()”. You can then use the resulting “MethodBody” object and invoke it’s “GetILAsByteArray()” method.

It’s really quite simple.

Parsing the Byte Array is a different matter, though. I’ll talk about that in a future post. For now, suffice to say that you can do wonderful things once you have the IL.

You can basically get the IL from any MethodInfo object at runtime and parse it (for security reasons, you might wanna make sure that there are no method calls to a specific method from any plugin you are about to load)

I was also able to create a MethodInfo Debugger Visualizer, based [on the code released here by a guy from the Reflection team](http://blogs.msdn.com/haibo_luo/archive/2005/10/25/484861.aspx). His visualizer shows the IL for a DynamicMethod object at debug time (that’s also a new class I’ll talk about in a future post). It took me a day or so to figure out how to extend it to show the IL for any method info object during debugging, and it works quite well!

In fact, you can now write a method that writes its own code in IL J

All that and more, in the near future, I promise J

Meanwhile, [here’s a nice post form Joel Pobar](http://blogs.msdn.com/joelpob/archive/2004/06/22/163206.aspx), highlighting some of the new features in Reflection 2.0. I’ll be elaborating on these more, but you can follow the links on his post as well to discover a whole new world of possibilities.

Cross Posted from [Blogs.Microsoft.Co.Il/Blogs/Royo](http://blogs.microsoft.co.il/blogs/Royo)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
