<?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>Code Analysis of Microsoft Assemblies [Michael Fanning]</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx</link><description>For the (real) inaugural post, Michael Fanning explains why some shipped Microsoft managed assemblies have fxcop violations, a very good question. It's also a good insight into how we use FxCop internally at MS. 
 -----Original Message----- 
 From:</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Code Analysis of Microsoft Assemblies [Michael Fanning]</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#163374</link><pubDate>Wed, 23 Jun 2004 08:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:163374</guid><dc:creator>Vinod</dc:creator><description>Thanks a lot Jeffry. Interospection solved the issue. When will be the release for the Interospection help documentation.?&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;&lt;br&gt;Vinod&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=163374" width="1" height="1"&gt;</description></item><item><title>re: Code Analysis of Microsoft Assemblies [Michael Fanning]</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#163065</link><pubDate>Wed, 23 Jun 2004 00:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:163065</guid><dc:creator>Jeffrey van Gogh</dc:creator><description>sure, provided you get the basic rules running from the article, here's some sample code:&lt;br&gt;&lt;br&gt;public Problem[] Check(Method method)&lt;br&gt;{&lt;br&gt;  for(int i=0; i &amp;lt; method.Instructions.Length; i++)&lt;br&gt;  {&lt;br&gt;    Instruction instruction = method.Instructions[i];&lt;br&gt;    switch(instruction.OpCode)&lt;br&gt;    {&lt;br&gt;      case OpCode.Newobj:&lt;br&gt;        InstanceInitializer cons = instruction.Value as InstanceInitializer;&lt;br&gt;        if (cons.DeclaringType == MyTypeThatIsNotAllowed)&lt;br&gt;        {&lt;br&gt;          Problems.Add(GetResolution(cons.FullName), instruction);&lt;br&gt;        }&lt;br&gt;    }&lt;br&gt;  }&lt;br&gt;  return Problems.AsArray();&lt;br&gt;}&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=163065" width="1" height="1"&gt;</description></item><item><title>re: Code Analysis of Microsoft Assemblies [Michael Fanning]</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#162774</link><pubDate>Tue, 22 Jun 2004 19:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:162774</guid><dc:creator>Vinod</dc:creator><description>Hi Jeffrey,&lt;br&gt;&lt;br&gt;Is it possible for you to post a sample code on the same. &lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;&lt;br&gt;Vinod&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=162774" width="1" height="1"&gt;</description></item><item><title>re: Code Analysis of Microsoft Assemblies [Michael Fanning]</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#162746</link><pubDate>Tue, 22 Jun 2004 19:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:162746</guid><dc:creator>Jeffrey van Gogh</dc:creator><description>Hi Vinod,&lt;br&gt;&lt;br&gt;first I'd recommend to take a look at this article from MSDN Magazine: &lt;a target="_new" href="http://msdn.microsoft.com/msdnmag/issues/04/06/Bugslayer/default.aspx"&gt;http://msdn.microsoft.com/msdnmag/issues/04/06/Bugslayer/default.aspx&lt;/a&gt; It talks about how to write custom fxcop rules.&lt;br&gt;&lt;br&gt;Then about your specific question. I'd walk the Method.Instructions and see if you find a instruction with OpCode.Newobj that has a value that is a InstanceInitailizer of the DataAccessHelper type.&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;&lt;br&gt;&lt;br&gt;Jeffrey&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=162746" width="1" height="1"&gt;</description></item><item><title>Design Guidelines</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#162557</link><pubDate>Tue, 22 Jun 2004 16:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:162557</guid><dc:creator>Vinod</dc:creator><description>I have a specific design rule to check in my Presentation Layer. I have to check whether any one of the development team has mistakenly created an Instance of DataAccessHelper in the Web Layer. I should be able to check even within a method whether an Instance of the DAL is created. How is it possible to write a Custom rule for such situations using FxCop?&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;&lt;br&gt;Vinod&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=162557" width="1" height="1"&gt;</description></item><item><title>Why does FxCop generate violations against itself?</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#71136</link><pubDate>Wed, 11 Feb 2004 09:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:71136</guid><dc:creator>overflow</dc:creator><description>&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=71136" width="1" height="1"&gt;</description></item><item><title>FAQ: Why does FxCop generate violations against itself? [Michael Fanning]</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#70937</link><pubDate>Wed, 11 Feb 2004 02:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70937</guid><dc:creator>FxCop</dc:creator><description>&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=70937" width="1" height="1"&gt;</description></item><item><title>re: Code Analysis of Microsoft Assemblies [Michael Fanning]</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#49279</link><pubDate>Sat, 10 Jan 2004 01:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:49279</guid><dc:creator>Jeffrey van Gogh</dc:creator><description>Hi Eric,&lt;br&gt;&lt;br&gt;FxCop does check both Design Guidelines, as well as Code-correctness issues, the ratio is about 50%-50%. You're right though that most of the issues in System.dll are Design Guidelines violations.&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;&lt;br&gt;&lt;br&gt;Jeffrey van Gogh&lt;br&gt;FxCop Team&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=49279" width="1" height="1"&gt;</description></item><item><title>re: Code Analysis of Microsoft Assemblies [Michael Fanning]</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#49248</link><pubDate>Fri, 09 Jan 2004 23:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:49248</guid><dc:creator>Eric Newton</dc:creator><description>people relax... fxcop is a design GUIDELINES check, not neccesarily a code-correctness check.&lt;br&gt;&lt;br&gt;If System.dll had 1600 true errors, do you think we'd be happy go-lucky .Net developers? or raging lunatics bent on hair pulling...&lt;br&gt;&lt;br&gt;again, relax&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=49248" width="1" height="1"&gt;</description></item><item><title>re: Code Analysis of Microsoft Assemblies [Michael Fanning]</title><link>http://blogs.msdn.com/b/codeanalysis/archive/2004/01/08/code-analysis-of-microsoft-assemblies-michael-fanning.aspx#49096</link><pubDate>Fri, 09 Jan 2004 17:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:49096</guid><dc:creator>Jeffrey van Gogh</dc:creator><description>That address should ofcourse be: asKfxcop At Microsoft.com&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=49096" width="1" height="1"&gt;</description></item></channel></rss>