<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Things in Metadata that are missing in Reflection</title><link>http://blogs.msdn.com/jmstall/archive/2008/03/15/things-in-metadata-that-are-missing-in-reflection.aspx</link><description>System.Reflection is a high-level way of describing Types in .NET targetted at managed code consumers. The API is easy to use, but does not expose all the information that's actually present and affecting decisions. For example, Reflection does not expose</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Things in Metadata that are missing in Reflection</title><link>http://blogs.msdn.com/jmstall/archive/2008/03/15/things-in-metadata-that-are-missing-in-reflection.aspx#8225300</link><pubDate>Sat, 15 Mar 2008 13:17:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8225300</guid><dc:creator>Patrick Smacchia</dc:creator><description>&lt;p&gt;After 3 years coping with Reflection in the code of the static analyzer NDepend I came to the conclusion that System.Reflection must not be used to do any kind of code analysis.&lt;/p&gt;
&lt;p&gt;I think it was originaly made for implementing things like Plug-In pattern and it should not be used for something else.&lt;/p&gt;
&lt;p&gt;The main coarse problem is that it cannot consider code as raw data. For reflection code will be still considered as something more. And as a result:&lt;/p&gt;
&lt;p&gt;-You will get CAS exception, unexpected exception on static cctor... (no matter you are using the ReadOnly API)&lt;/p&gt;
&lt;p&gt;-It doesn't cop well with complex C++/CLI assemblies (that often don't respect the CLI).&lt;/p&gt;
&lt;p&gt;-It doesn't cop well with 64bits assemblies on 32 bits machine and vice versa.&lt;/p&gt;
&lt;p&gt;-It has poor performance, certainly because of underlying CAS security check. &lt;/p&gt;
&lt;p&gt;-You cannot unload an assembly once it is loaded into an appdomain.&lt;/p&gt;
&lt;p&gt;But also:&lt;/p&gt;
&lt;p&gt;-It doesn't parse IL.&lt;/p&gt;
&lt;p&gt;-And as you mention it doesn't know about typeSpec&lt;/p&gt;
&lt;p&gt;I don't say that Reflection is crap, it is a great tool for Plug-In scenario.&lt;/p&gt;
&lt;p&gt;But if you plan to use it to do any kind of analysis (as building your own ILDasm) use Mono.Cecil instead. This is what NDepend uses now and it is truly perfect for analysis (and open-source btw).&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.mono-project.com/Cecil"&gt;http://www.mono-project.com/Cecil&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>