views:

41

answers:

2

Without working on the source, just on the basis of a binary, is there a way (there sure must be using CodeDom, but it'll be nice if it is possible without CodeDom) to tell if a method's body has an if construct, using reflection?

A: 

If it's .Net, grab reflector.

update
After seeing your comment, I think there's a lot of information missing from your question. In particular, what language is the binary written in? Are you asking how to decompile a given .Net binary or are you asking how to use .net to decompile a binary written in some other language not based on the .Net framework?

If the latter, then no, reflection won't allow you to determine what code exists.

If the former, then I'm puzzled. The purpose of reflector is to decompile .net binaries... at which point you could just visually inspect whether an if statement did in fact exist in the method in question.

Chris Lively
I have been using reflector for many years now. How would it help me here?
Water Cooler v2
A: 
  1. Decompile (as advised by Chris)
  2. Run the decompiled code through a code parser (See for example CS Parser for C# 2.0 : http://csparser.codeplex.com/
  3. Use parser output to obtain info required, such as presence of token Y within body of method Z.
Jas