<?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 Team Blog : Custom Rules</title><link>http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx</link><description>Tags: Custom Rules</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Fun with Code Analysis Rule Sets</title><link>http://blogs.msdn.com/fxcop/archive/2008/11/12/fun-with-code-analysis-rulesets.aspx</link><pubDate>Wed, 12 Nov 2008 22:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9064155</guid><dc:creator>cristend</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/9064155.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=9064155</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=9064155</wfw:comment><description>&lt;P&gt;Two weeks ago, I introduced you to Visual Studio 2010 September '08 CTP (Community Technology Preview). This CTP is available as a Virtual PC (VPC) image which can be downloaded at &lt;A href="http://go.microsoft.com/fwlink/?LinkId=129231" mce_href="http://go.microsoft.com/fwlink/?LinkId=129231"&gt;&lt;FONT color=#0000ff&gt;http://go.microsoft.com/fwlink/?LinkId=129231&lt;/FONT&gt;&lt;/A&gt;. The goal of the Community Technology Preview is to obtain feedback from our customers on the new scenarios we have enabled.&amp;nbsp; If you haven't already downloaded the CTP, do it now and take it out for a spin.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;There&amp;nbsp;are many new cool features with the CTP such as an Historical Debugger and&amp;nbsp;Impact Analysis of&amp;nbsp;code changes, but today we are going to focus on &lt;STRONG&gt;Rule Sets&lt;/STRONG&gt; for code analysis. (For an overview of all the neat stuff happening in code analysis, check out this PDC video&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin"&gt;&lt;A href="http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV-HQ/TL60.wmv"&gt;http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV-HQ/TL60.wmv&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;)&amp;nbsp;&amp;nbsp;Configuring code analysis in Visual Studio 2008 and earlier versions required evaluating each individual rule to determine whether it was important enough to turn on and fix for your project. This might be a very time-consuming process that made it difficult to make sure that the most important problems were identified and fixed. With rule sets, code analysis can now be configured much more quickly and easily with sets of rules that are targeted at specific scenarios or areas of emphasis. Let's take a look at&amp;nbsp;how this works.&lt;/P&gt;
&lt;P&gt;The following scenario comes from our CTP walkthrough.&amp;nbsp; You can find the walkthrough and more details when you download the CTP as described above.&amp;nbsp; Let's assume that you have the &lt;EM&gt;&lt;STRONG&gt;DinnerNow – Kiosk&lt;/STRONG&gt;&lt;/EM&gt; solution open and is the active project.&amp;nbsp; On the &lt;STRONG&gt;Analyze&lt;/STRONG&gt; menu, click &lt;STRONG&gt;Configure Code Analysis&lt;/STRONG&gt; &lt;STRONG&gt;for DinnerNow.Restaurants.Kiosk&lt;/STRONG&gt;.&amp;nbsp; The property page for Code Analysis is displayed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG title="Code Analysis Properties" style="WIDTH: 590px; HEIGHT: 376px" height=376 alt="Code Analysis Properties" hspace=1 src="http://blogs.msdn.com/photos/codeanalysis/images/9064354/original.aspx" width=590 vspace=1 border=1 mce_src="http://blogs.msdn.com/photos/codeanalysis/images/9064354/original.aspx"&gt;&lt;/P&gt;
&lt;P class=TextinList1 style="MARGIN: 3pt 0in 3pt 0.25in"&gt;&lt;FONT face=Verdana&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This screen tells us that &lt;STRONG&gt;Microsoft All Rules&lt;/STRONG&gt; will be executed when we run code analysis, but what if we didn't want to run&amp;nbsp;every Microsoft rule?&amp;nbsp; What if we have a specific scenario we wish to target?&amp;nbsp; We can change which rule set to run by clicking on &lt;STRONG&gt;Open&lt;/STRONG&gt; which brings up:&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Add or Remove Rule Sets" style="WIDTH: 590px; HEIGHT: 387px" height=387 alt="Add or Remove Rule Sets" hspace=1 src="http://blogs.msdn.com/photos/codeanalysis/images/9064400/original.aspx" width=590 vspace=1 border=1 mce_src="http://blogs.msdn.com/photos/codeanalysis/images/9064400/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;We can select which rule set(s) by simply selecting or deselecting the appropriate box.&amp;nbsp; Notice that each rule set has a brief description of the types of rules within the rule set.&amp;nbsp; Further, you can open up each individual rule set and see the specific rules that make up the rules sets.&amp;nbsp; You can also turn on or off individual rules within a rule set.&amp;nbsp; Finally, you can adjust the type of action a rule will trigger.&amp;nbsp; In the past, code analysis rules&amp;nbsp;have been limited to build Warnings, but now you can elevate code analysis rules to build Errors.&lt;/P&gt;
&lt;P&gt;As you can see, rules sets provide a powerful way to focus code analysis on the scenarios and rules that matter most to you.&amp;nbsp; You can also create custom rule sets based on your specific needs.&amp;nbsp; We wont go into it today, but if you download the CTP, the Walkthrough explains how to customize a rule set.&lt;/P&gt;
&lt;P&gt;Give it a try and let us know what you think.&lt;/P&gt;
&lt;P&gt;Cris&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9064155" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Rules/default.aspx">Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/FxCop/default.aspx">FxCop</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis+Policy/default.aspx">Code Analysis Policy</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/CodeCommunit+Analysis/default.aspx">CodeCommunit Analysis</category></item><item><title>Tutorial on writing your own Code Analysis rule</title><link>http://blogs.msdn.com/fxcop/archive/2008/01/18/tutorial-on-writing-your-own-code-analysis-rule.aspx</link><pubDate>Fri, 18 Jan 2008 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7143040</guid><dc:creator>David M. Kean</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/7143040.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=7143040</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=7143040</wfw:comment><description>&lt;P&gt;Jason Kresowaty has posted &lt;A class="" href="http://www.binarycoder.net/fxcop/" mce_href="http://www.binarycoder.net/fxcop/"&gt;a great tutorial on writing Code Analysis/FxCop rules&lt;/A&gt;. He also spends time on explaining parts of the Introspection&amp;nbsp;API, including the different nodes and their relationship to each other.&lt;/P&gt;
&lt;P&gt;It's a great read, even if you've written some Code Analysis rules before. Definitely recommended.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7143040" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/FxCop/default.aspx">FxCop</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category></item><item><title>What kind of custom rules do you want to write?</title><link>http://blogs.msdn.com/fxcop/archive/2007/07/04/what-kind-of-custom-rules-do-you-want-to-write.aspx</link><pubDate>Wed, 04 Jul 2007 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3692221</guid><dc:creator>David M. Kean</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/3692221.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=3692221</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=3692221</wfw:comment><description>&lt;P&gt;Our excellent program manager, Joe Rohde, is trying to gather information on the kinds of custom rules customers want to write.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;I am a program manager for our Code Analysis system.&amp;nbsp;I want to know what kind of custom rules you would like to write.&amp;nbsp;Ignore what you may or may not know about what's in FxCop already. If you could track anything - tell me what you want!&lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;I don't care if it's things you know we can't do - except maybe 'find my bugs'.&amp;nbsp;Tell your friends, tell anyone who has ever said: I wish this thing could...&lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;The reason I want everything is both to help plan the rules we should just plain provide; and how to best provide an actual supported extensibility feature.&lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;Please send what you would like to see to: &lt;/EM&gt;&lt;A href="mailto:JRohde@Microsoft.com"&gt;&lt;EM&gt;JRohde@Microsoft.com&lt;/EM&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;Thanks!&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Joe&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Provide Joe with feedback and help us plan our future extensibility.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3692221" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/FxCop/default.aspx">FxCop</category></item><item><title>FAQ: How do I debug a custom rule?</title><link>http://blogs.msdn.com/fxcop/archive/2007/05/16/faq-how-do-i-debug-a-custom-rule.aspx</link><pubDate>Wed, 16 May 2007 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2650647</guid><dc:creator>David M. Kean</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/2650647.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=2650647</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=2650647</wfw:comment><description>&lt;P&gt;While writing your custom rule,&amp;nbsp;you will likely come across a need to debug it and work out why it's behaving in a particular manner.&lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Debugging within FxCop&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Debugging a custom rule within the FxCop UI is actually quite easy. To do so, simply:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Open the FxCop project that contains your custom rule (making sure the PDB is alongside the assembly)&lt;/LI&gt;
&lt;LI&gt;Open the solution that contains your custom rule and set a breakpoint in the rule your want to debug&lt;/LI&gt;
&lt;LI&gt;Choose &lt;STRONG&gt;Debug&lt;/STRONG&gt; -&amp;gt; &lt;STRONG&gt;Attach to Process&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Under &lt;STRONG&gt;Available Processes&lt;/STRONG&gt;, choose &lt;STRONG&gt;FxCop.exe&lt;/STRONG&gt; and click &lt;STRONG&gt;Attach&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;In FxCop, choose &lt;STRONG&gt;Project&lt;/STRONG&gt; -&amp;gt; &lt;STRONG&gt;Analyze&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The debugger should break when it hits the breakpoint.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Debugging within Visual Studio or via command-line&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;However, if you want debug a rule that you've written for Visual Studio Code Analysis, or via the command-line, the procedure is not so obvious:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Open a &lt;STRONG&gt;Visual Studio Command Prompt&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;If debugging a custom rule written for Visual Studio, run the following:&lt;BR&gt;&lt;BR&gt;&lt;/DIV&gt;
&lt;BLOCKQUOTE mce_keep="true"&gt;
&lt;P style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&amp;gt; cd &lt;/FONT&gt;&lt;FONT color=#000000&gt;%VSINSTALLDIR%\Team Tools\Static Analysis Tools\FxCop&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;DIV mce_keep="true"&gt;&lt;/FONT&gt;Otherwise, if debugging a custom rule written for FxCop, run the following:&lt;BR&gt;&lt;BR&gt;&lt;/DIV&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&amp;gt; cd %PROGRAMFILES%\Microsoft FxCop 1.35&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Run the following command, replacing &lt;EM&gt;[TargetAssembly]&lt;/EM&gt; and &lt;EM&gt;[RuleAssembly]&lt;/EM&gt; with the assembly you want to analyze and the assembly that contains your custom rule respectively.&lt;BR&gt;&lt;BR&gt;&lt;/DIV&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&amp;gt; devenv /debugexe FxCopCmd.exe /file:&lt;EM&gt;[TargetAssembly]&lt;/EM&gt; /rule:&lt;EM&gt;[RuleAssembly]&lt;/EM&gt; /console&lt;/P&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;DIV mce_keep="true"&gt;This will open Visual Studio in a state that is ready to debug your custom rule.&lt;BR&gt;&lt;BR&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;P style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;Choose &lt;STRONG&gt;File&lt;/STRONG&gt; -&amp;gt; &lt;STRONG&gt;Open&lt;/STRONG&gt; -&amp;gt; &lt;STRONG&gt;File&lt;/STRONG&gt; and browse to and open the source file that contains your custom rule&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;P style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;Set a breakpoint in the rule&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;P style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;Choose &lt;STRONG&gt;Debug&lt;/STRONG&gt; -&amp;gt; &lt;STRONG&gt;Start Debugging&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The debugger should break when it hits the breakpoint.&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;&lt;STRONG&gt;The Modules window is your friend&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;If the breakpoint is not being hit, check to make sure that you actually have symbols for your custom rule loaded:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;While debugging, choose &lt;STRONG&gt;Debug&lt;/STRONG&gt; -&amp;gt; &lt;STRONG&gt;Windows&lt;/STRONG&gt; -&amp;gt; &lt;STRONG&gt;Modules&lt;/STRONG&gt;&lt;BR&gt;&lt;BR&gt;To do this if you are debugging via &lt;STRONG&gt;/debugexe&lt;/STRONG&gt; switch, as soon as the command window opens to start running FxCop, click &lt;STRONG&gt;PAUSE&lt;/STRONG&gt; on the keyboard&lt;STRONG&gt;.&lt;BR&gt;&lt;BR&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;Look for your rule assembly and check under the &lt;STRONG&gt;Symbol Status&lt;/STRONG&gt; column.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;If this column states anything other &lt;STRONG&gt;Symbols Loaded&lt;/STRONG&gt;, then right-click on the assembly and choose&lt;STRONG&gt; Load Symbols&lt;/STRONG&gt; and browse manually to the PDB.&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2650647" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/FAQ/default.aspx">FAQ</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/FxCop/default.aspx">FxCop</category></item><item><title>Dealing with a Code Analysis backlog?</title><link>http://blogs.msdn.com/fxcop/archive/2007/05/04/dealing-with-a-code-analysis-backlog.aspx</link><pubDate>Fri, 04 May 2007 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2367384</guid><dc:creator>David M. Kean</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/2367384.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=2367384</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=2367384</wfw:comment><description>&lt;P&gt;&lt;A class="" href="http://msmvps.com/blogs/calinoiu/default.aspx" mce_href="http://msmvps.com/blogs/calinoiu/default.aspx"&gt;Nicole Calinoiu&lt;/A&gt; has started a (what I hope to be long) series on introducing Code Analysis (FxCop in particular) to your team. Her first couple of posts are absolute &lt;A class="" href="http://outbackdobbs.wordpress.com/2006/08/29/aussie-slang-lesson-5-what-a-ripper/" mce_href="http://outbackdobbs.wordpress.com/2006/08/29/aussie-slang-lesson-5-what-a-ripper/"&gt;rippers&lt;/A&gt;, check them out:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A class="" href="http://msmvps.com/blogs/calinoiu/archive/2007/04/22/fxcop-and-the-big-bad-backlog.aspx" mce_href="http://msmvps.com/blogs/calinoiu/archive/2007/04/22/fxcop-and-the-big-bad-backlog.aspx"&gt;FxCop and the big, bad backlog&lt;/A&gt;&lt;BR&gt;&lt;A class="" href="http://msmvps.com/blogs/calinoiu/archive/2007/04/29/fxcop-backlogs-some-rules-for-rule-activation.aspx" mce_href="http://msmvps.com/blogs/calinoiu/archive/2007/04/29/fxcop-backlogs-some-rules-for-rule-activation.aspx"&gt;FxCop backlogs: Some rules for rule activation&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;She's also written some custom rules content:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A class="" href="http://msmvps.com/blogs/calinoiu/archive/2007/04/21/no-rules-in-your-fxcop-rule-assembly.aspx" mce_href="http://msmvps.com/blogs/calinoiu/archive/2007/04/21/no-rules-in-your-fxcop-rule-assembly.aspx"&gt;No rules in your FxCop rule assembly?&lt;/A&gt;&lt;BR&gt;&lt;A class="" href="http://bordecal.mvps.org/Nicole/FxCop/CustomRulesSample.htm" mce_href="http://bordecal.mvps.org/Nicole/FxCop/CustomRulesSample.htm"&gt;Rule: Justify rule violation suppression&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Great stuff!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2367384" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/FxCop/default.aspx">FxCop</category></item><item><title>FAQ: How do I get the SourceContext for a local?</title><link>http://blogs.msdn.com/fxcop/archive/2007/03/27/faq-how-do-i-get-the-sourcecontext-for-a-local.aspx</link><pubDate>Tue, 27 Mar 2007 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1965879</guid><dc:creator>David M. Kean</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/1965879.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=1965879</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=1965879</wfw:comment><description>&lt;P&gt;&lt;EM&gt;I want to fire on the naming of a local, however, whenever I pass&amp;nbsp;the local&amp;nbsp;to the Problem constructor, the source information for the method is always used. How do I get FxCop/Code Analysis&amp;nbsp;to use the source information for the local instead?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Because the declaration of a local is not associated with an executable instruction, a local does not contain any source information within the pdb. However, any usages of the local (such as an assignment) does.&lt;/P&gt;
&lt;P&gt;The following example shows when source information is provided and not provided:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="courier new,courier"&gt; Bar()&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int&lt;/FONT&gt;&lt;FONT size=2&gt; value1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// Does not have source information&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="courier new,courier"&gt;value1 = 10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT face="courier new,courier"&gt;// Has source information&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; value2 = 20;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT face="courier new,courier"&gt;// Has source information&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(value1); &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// Has source information&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(value2); &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// Has source information&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier" size=2&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;As&amp;nbsp;most locals are assigned at their time of declaration (such as in the case of &lt;EM&gt;value2&lt;/EM&gt; in the above example), a simple trick is use the source context of the first usage of the local in place of its declaration. This works in most situations.&lt;/P&gt;
&lt;P&gt;The following example shows this (using the code from &lt;A class="" href="http://blogs.msdn.com/fxcop/archive/2006/04/07/faq-how-do-i-access-the-locals-of-a-method-in-a-custom-rule-michael-fanning-david-kean.aspx" mce_href="http://blogs.msdn.com/fxcop/archive/2006/04/07/faq-how-do-i-access-the-locals-of-a-method-in-a-custom-rule-michael-fanning-david-kean.aspx"&gt;FAQ: How do I access the locals of a method in a custom rules?&lt;/A&gt;):&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;override&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;ProblemCollection&lt;/FONT&gt;&lt;FONT size=2&gt; Check(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Member&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; member)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Method&lt;/FONT&gt;&lt;FONT size=2&gt; method = member &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Method&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (method == &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier" color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="courier new,courier"&gt; (method.Instructions.Length == 0)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;LocalList&lt;/FONT&gt;&lt;FONT size=2&gt; locals = method.Instructions[0].Value &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;LocalList&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="courier new,courier"&gt;;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (locals == &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="courier new,courier"&gt;)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;for &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT size=2&gt;i = 0; i &amp;lt; locals.Length; i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Local&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT size=2&gt; local = locals[i];&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT size=2&gt; (someCondition)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000&gt;//&amp;nbsp;Fire on the local&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Resolution&lt;/FONT&gt;&lt;FONT size=2&gt; resolution = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Resolution&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Fix local {0}"&lt;/FONT&gt;&lt;FONT size=2&gt;, local.Name.Name);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;SourceContext&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="courier new,courier"&gt; sourceContext = FindSourceContext(local, method.Instructions);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;Problem&lt;/FONT&gt;&lt;FONT size=2&gt; problem = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Problem&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier" size=2&gt;(resolution, sourceContext);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Problems.Add(problem);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="courier new,courier"&gt; Problems;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;static&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SourceContext&lt;/FONT&gt;&lt;FONT size=2&gt; FindSourceContext(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Local&lt;/FONT&gt;&lt;FONT size=2&gt; local, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;InstructionList&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT size=2&gt; instructions)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;foreach&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Instruction&lt;/FONT&gt;&lt;FONT size=2&gt; instruction &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;in&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT size=2&gt; instructions)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT size=2&gt; (instruction.Value == local)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;{&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000&gt;//&amp;nbsp;Found its first usage&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT size=2&gt; instruction.SourceContext;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;}&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SourceContext&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier" size=2&gt;();&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;}&lt;BR&gt;&lt;BR&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; If the local is only declared and is never assigned to, or its usage is only as the argument for an out parameter, then&amp;nbsp;the source context of the method will be used.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1965879" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/FAQ/default.aspx">FAQ</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/FxCop/default.aspx">FxCop</category></item><item><title>Framework for intergrated FxCop rule testing</title><link>http://blogs.msdn.com/fxcop/archive/2007/02/25/framework-for-intergrated-fxcop-rule-testing.aspx</link><pubDate>Sun, 25 Feb 2007 19:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1755375</guid><dc:creator>David M. Kean</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/1755375.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=1755375</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=1755375</wfw:comment><description>&lt;P&gt;Roy Osherove has put together a &lt;A class="" href="http://weblogs.asp.net/rosherove/archive/2007/02/24/introducing-fxcopunit-a-framework-for-integrated-fxcop-rule-testing.aspx" mce_href="http://weblogs.asp.net/rosherove/archive/2007/02/24/introducing-fxcopunit-a-framework-for-integrated-fxcop-rule-testing.aspx"&gt;Framework for testing FxCop rules&lt;/A&gt;. It's an interesting approach, firing up the FxCop engine for each rule that he wants to test. &lt;/P&gt;
&lt;P&gt;There are few things that I would like to see it support:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The ability to specify positive tests (code that rules should not fire when run over) on top of the negative (code that rules do fire when run over) tests that he supports&lt;/LI&gt;
&lt;LI&gt;The ability to separate the actual test from the methods you want to run your rules over. Unfortunately, this approach&amp;nbsp;will not&amp;nbsp;scale when you are testing 3 difference languages (C#, Visual Basic and C++) for 200+ rules that we ship.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Unfortunately, his approach is not going to work in the next version of FxCop/Visual Studio for&amp;nbsp;a couple of&amp;nbsp;reasons. 1) We did some&amp;nbsp;work in Orcas to reduce the visibility of API's that did not need to be public for actually writing custom rules (for example, everything in FxCopCommon.dll is now internal) and 2) We also removed the Reflection 'bridge',&amp;nbsp;that is,&amp;nbsp;the ability to create CCI objects from their Reflection&amp;nbsp;counterparts and vice versa.&lt;/P&gt;
&lt;P&gt;Apart from the things mentioned above, it's a&amp;nbsp;great start and its got us thinking, how many users actually automate the testing of custom rules? Is this something you see as important? Would you like to see how we do this internally?&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1755375" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>FAQ: When looking at the names of locals in a custom rule, why do I see strange names such as 'CS$1$0000' and 'VB$1$0000'?</title><link>http://blogs.msdn.com/fxcop/archive/2007/01/26/faq-when-looking-at-the-names-of-locals-in-a-custom-rule-why-do-i-see-strange-names-such-as-cs-1-0000-and-vb-1-0000.aspx</link><pubDate>Fri, 26 Jan 2007 19:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1450038</guid><dc:creator>David M. Kean</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/1450038.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=1450038</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=1450038</wfw:comment><description>&lt;P&gt;Previously &lt;A class="" href="http://blogs.msdn.com/fxcop/archive/2006/04/07/faq-how-do-i-access-the-locals-of-a-method-in-a-custom-rule-michael-fanning-david-kean.aspx" mce_href="http://blogs.msdn.com/fxcop/archive/2006/04/07/faq-how-do-i-access-the-locals-of-a-method-in-a-custom-rule-michael-fanning-david-kean.aspx"&gt;we showed you how&lt;/A&gt; to access the locals or variables of a method. Once you started to run your rule over an assembly, you might start to notice strange locals with names that start with 'CS$' and 'VB$'. These are compiler generated locals that are outside the control of the user.&lt;/P&gt;
&lt;P&gt;If you are writing a rule to check the names of locals, you will want to skip over these, To do this, simply&amp;nbsp;pass the local to RuleUtilities.IsCompilerGenerated method and check the result.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; This will also skip over locals when&amp;nbsp;source and line&amp;nbsp;information (PDBs)&amp;nbsp;is not alongside the&amp;nbsp;assembly under analysis.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1450038" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/FAQ/default.aspx">FAQ</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>Free sample book chapter on Managed Code Analysis</title><link>http://blogs.msdn.com/fxcop/archive/2007/01/24/free-sample-book-chapter-on-managed-code-analysis.aspx</link><pubDate>Wed, 24 Jan 2007 19:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1519068</guid><dc:creator>David M. Kean</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/1519068.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=1519068</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=1519068</wfw:comment><description>&lt;P&gt;&lt;A class="" href="http://searchvb.techtarget.com/infoCenter/tip/0,294276,sid8_gci1231246_tax303325_iid2657,00.html" mce_href="http://searchvb.techtarget.com/infoCenter/tip/0,294276,sid8_gci1231246_tax303325_iid2657,00.html"&gt;SearchVB.com&lt;/A&gt; is offering&amp;nbsp; a &lt;A class="" href="http://media.techtarget.com/digitalguide/images/Misc/professionalvsts_ch08.pdf" mce_href="http://media.techtarget.com/digitalguide/images/Misc/professionalvsts_ch08.pdf"&gt;free sample chapter&lt;/A&gt; on Managed Code Analysis from the book &lt;A class="" href="http://searchvb.techtarget.com/tip/0,289483,sid8_gci1231609,00.html" mce_href="http://searchvb.techtarget.com/tip/0,289483,sid8_gci1231609,00.html"&gt;Professional Visual Studio Team System&lt;/A&gt;&amp;nbsp;(co-written by fellow Team System colleague &lt;A class="" href="http://blogs.msdn.com/noahc/" mce_href="http://blogs.msdn.com/noahc/"&gt;Noah Coad&lt;/A&gt;).&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;Chapter 8, Managed Code Analysis, focuses on how to use Team System's Static Code Analysis tool for C# or VB.NET code. This tool checks code for adherence to Microsoft's .NET Framework Design Guidelines. Static Code Analysis is available from both the Visual Studio IDE and from the command line, and the authors cover both instances. The chapter ends with hints for creating custom rules for the code analysis tool. &lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Great stuff!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1519068" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Books/default.aspx">Books</category></item><item><title>FAQ: Can I create custom rules that target both Visual Studio and FxCop? [David Kean]</title><link>http://blogs.msdn.com/fxcop/archive/2006/05/31/faq-can-i-create-custom-rules-that-target-both-visual-studio-and-fxcop-david-kean.aspx</link><pubDate>Thu, 01 Jun 2006 08:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:612658</guid><dc:creator>David M. Kean</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/612658.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=612658</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=612658</wfw:comment><description>&lt;P&gt;&lt;EM&gt;I have users using both Visual Studio and FxCop, and I want to create custom rules that run on both. Is this possible?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Although in the future we do plan on making it easier to move custom rules between Visual Studio and FxCop, currently you must recompile each rule assembly against the version of FxCop/Visual Studio you want to target. &lt;/P&gt;
&lt;P&gt;Typically&amp;nbsp;this involves the (painful) step of manually removing, and re-adding the references to both FxCopSdk.dll and Microsoft.Cci.dll.&lt;/P&gt;
&lt;P&gt;To improve this process, we have developed an MSBuild targets files that can be imported by your custom rules projects, which makes switching between targetting FxCop 1.35 and Visual Studio as easy as changing build configurations.&lt;/P&gt;
&lt;P&gt;In the attached download, the same sample rules project that was made available &lt;A href="http://blogs.msdn.com/fxcop/archive/2006/03/11/549611.aspx"&gt;here&lt;/A&gt;, has been included, however, it has been updated to import this new targets file. This project has 4 build configurations, &lt;EM&gt;FxCopDebug&lt;/EM&gt;, &lt;EM&gt;FxCopRelease&lt;/EM&gt;, &lt;EM&gt;VisualStudioDebug &lt;/EM&gt;and &lt;EM&gt;VisualStudioRelease&lt;/EM&gt;. As you can probably guess from the names, the former two target building against FxCop, while the later two target building against Visual Studio. You can use this project as a starting base, or follow the below steps to import this targets file in your own projects:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Copy &lt;EM&gt;Microsoft.CodeAnalysis.CustomRules.targets&lt;/EM&gt; (attached below) to the same folder that contains your Visual Studio solution 
&lt;LI&gt;Open your custom rules project and remove any references to &lt;EM&gt;FxCopSdk&lt;/EM&gt; and &lt;EM&gt;Microsoft.Cci&lt;/EM&gt; 
&lt;LI&gt;Right-click on your project and choose &lt;STRONG&gt;Unload Project&lt;/STRONG&gt; 
&lt;LI&gt;Right-click on your project and choose&lt;STRONG&gt; Edit &lt;EM&gt;[ProjectName]&lt;/EM&gt;&lt;/STRONG&gt; 
&lt;LI&gt;Add the following bolded line&amp;nbsp;at the location indicated (at the bottom of the file):&lt;BR&gt;&lt;FONT size=1&gt;[...]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT size=1&gt; &lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Import&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Project&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;$(MSBuildBinPath)\Microsoft.CSharp.targets&lt;/FONT&gt;&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT size=1&gt; /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&amp;lt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#800000&gt;Import&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Project&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;..\Microsoft.CodeAnalysis.CustomRules.targets&lt;/FONT&gt;&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=1&gt; /&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;Project&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;By default, this looks for the targets file one directory above your project file (which typically contains your solution).&lt;BR&gt;
&lt;LI&gt;At the top of the project file, after the first &amp;lt;PropertyGroup&amp;gt;&amp;lt;/PropertyGroup&amp;gt; element, but before the second, add the following bolded lines at the location indicated:&lt;BR&gt;&lt;FONT size=1&gt;[...]&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;PropertyGroup&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;STRONG&gt;&amp;lt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color=#800000&gt;PropertyGroup&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Condition&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; '$(Configuration)|$(Platform)' == 'FxCopDebug|AnyCPU' &lt;/FONT&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;DebugSymbols&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;true&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;DebugSymbols&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;DebugType&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;full&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;DebugType&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Optimize&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;false&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;Optimize&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;OutputPath&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;bin\FxCopDebug\&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;OutputPath&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;DefineConstants&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;DEBUG;TRACE&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;DefineConstants&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;ErrorReport&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;prompt&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;ErrorReport&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;WarningLevel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;4&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;WarningLevel&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;RunCodeAnalysis&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;true&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;RunCodeAnalysis&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;CodeAnalysisRules&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;CodeAnalysisRules&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;CodeAnalysisBuildTarget&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;FxCop&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;CodeAnalysisBuildTarget&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;PropertyGroup&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color=#0000ff size=1&gt;&lt;STRONG&gt;&amp;gt;&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&amp;lt;&lt;FONT color=#800000&gt;PropertyGroup&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Condition&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; '$(Configuration)|$(Platform)' == 'VisualStudioDebug|AnyCPU' &lt;/FONT&gt;&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;DebugSymbols&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;true&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;DebugSymbols&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;DebugType&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;full&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;DebugType&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Optimize&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;false&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;Optimize&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;OutputPath&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;bin\VisualStudioDebug\&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;OutputPath&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;DefineConstants&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;DEBUG;TRACE&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;DefineConstants&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;ErrorReport&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;prompt&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;ErrorReport&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;WarningLevel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;4&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;WarningLevel&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;RunCodeAnalysis&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;true&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;RunCodeAnalysis&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;CodeAnalysisRules&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;CodeAnalysisRules&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;CodeAnalysisBuildTarget&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;VisualStudio&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;CodeAnalysisBuildTarget&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;PropertyGroup&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;&lt;STRONG&gt;&amp;gt;&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=1&gt;&lt;FONT color=#800000&gt;PropertyGroup&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Condition&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' &lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt; &lt;/FONT&gt;
&lt;LI&gt;Right-click on the project and choose &lt;STRONG&gt;Reload Project&lt;/STRONG&gt;, answering &lt;STRONG&gt;Yes&lt;/STRONG&gt; to both questions that are asked 
&lt;LI&gt;Right-click on the solution and choose &lt;STRONG&gt;Configuration Manager&lt;/STRONG&gt; 
&lt;LI&gt;In the &lt;STRONG&gt;Active solution configuration&lt;/STRONG&gt; dropdown, choose &lt;STRONG&gt;New&lt;/STRONG&gt; 
&lt;LI&gt;In the &lt;STRONG&gt;New Solution Configuration&lt;/STRONG&gt; dialog, enter &lt;EM&gt;FxCopDebug&lt;/EM&gt; as the name and click &lt;STRONG&gt;OK&lt;/STRONG&gt; 
&lt;LI&gt;In the &lt;STRONG&gt;Active solution configuration&lt;/STRONG&gt; dropdown, choose &lt;STRONG&gt;New&lt;/STRONG&gt; 
&lt;LI&gt;In the &lt;STRONG&gt;New Solution Configuration&lt;/STRONG&gt; dialog, enter &lt;EM&gt;VisualStudioDebug&lt;/EM&gt; as the name and click &lt;STRONG&gt;OK&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Once you have done the above, switching the active build configuration between &lt;EM&gt;FxCopDebug&lt;/EM&gt; and &lt;EM&gt;VisualStudioDebug&lt;/EM&gt; will now also change the references to FxCopSdk and Microsoft.Cci to point to the associated version.&lt;/P&gt;
&lt;P&gt;If you have any issues with the Microsoft.CodeAnalysis.CustomRules.targets file, or with the custom rules themselves, don't hesitate to visit the &lt;A href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=98&amp;amp;SiteID=1"&gt;FxCop&lt;/A&gt; forum.&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=612658" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/fxcop/attachment/612658.ashx" length="7100" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/fxcop/archive/tags/FAQ/default.aspx">FAQ</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/FxCop/default.aspx">FxCop</category></item><item><title>FAQ: How do I access the locals of a method in a custom rule? [Michael Fanning, David Kean]</title><link>http://blogs.msdn.com/fxcop/archive/2006/04/07/faq-how-do-i-access-the-locals-of-a-method-in-a-custom-rule-michael-fanning-david-kean.aspx</link><pubDate>Fri, 07 Apr 2006 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:570553</guid><dc:creator>David M. Kean</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/570553.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=570553</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=570553</wfw:comment><description>&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; The custom rules API is likely to change in the next version of FxCop/Visual Studio.&lt;/P&gt;
&lt;P&gt;Currently, the locals of a method are stored in a pseudo-instruction in the method's InstructionList. We plan to change this in a future version of the tool and the locals will directly hang off the method.&lt;/P&gt;
&lt;P&gt;To access them, do the following:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;override&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ProblemCollection&lt;/FONT&gt;&lt;FONT size=2&gt; Check(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Member&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; member)&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Method&lt;/FONT&gt;&lt;FONT size=2&gt; method = member &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Method&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt;&lt;FONT size=2&gt; (method == &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; (method.Instructions.Length == 0)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;LocalList&lt;/FONT&gt;&lt;FONT size=2&gt; locals = method.Instructions[0].Value &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;LocalList&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt;&lt;FONT size=2&gt; (locals == &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; i = 0; i &amp;lt; locals.Length; i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Local&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; local = locals[i];&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Do something&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;.Problems;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;In FxCop 1.35, the LocalList is foreachable.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=570553" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/FAQ/default.aspx">FAQ</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>FAQ: How do I integrate custom rules with Visual Studio? [David Kean]</title><link>http://blogs.msdn.com/fxcop/archive/2006/03/11/FAQ_3A00_-How-do-I-integrate-custom-rules-with-Visual-Studio_3F00_-_5B00_David-Kean_5D00_.aspx</link><pubDate>Sun, 12 Mar 2006 08:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:549611</guid><dc:creator>David M. Kean</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/549611.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=549611</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=549611</wfw:comment><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt;&amp;nbsp;To&amp;nbsp;have rules target both Visual Studio and FxCop, see the following entry: &lt;A class="" href="http://blogs.msdn.com/fxcop/archive/2006/05/31/faq-can-i-create-custom-rules-that-target-both-visual-studio-and-fxcop-david-kean.aspx" mce_href="http://blogs.msdn.com/fxcop/archive/2006/05/31/faq-can-i-create-custom-rules-that-target-both-visual-studio-and-fxcop-david-kean.aspx"&gt;FAQ: Can I create custom rules that target both Visual Studio and FxCop?&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Although not officially supported or documented, the Managed Code Analysis (FxCop) feature available with Visual Studio Team System comes with a rich API for writing custom rules. &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;There are a number of &lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=333885&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=333885&amp;amp;SiteID=1"&gt;samples and articles&lt;/A&gt; on the web that already cover using this API and its usage with the externally available &lt;A href="http://www.gotdotnet.com/team/fxcop/" mce_href="http://www.gotdotnet.com/team/fxcop/"&gt;FxCop&lt;/A&gt;, so instead of covering the same information, this entry will instead give a quick rundown on integrating existing custom rules with Visual Studio.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Before beginning, download the attached zipped project (at the bottom of the post) and extract the contents. This project contains a single custom rule called PrivateFieldsShouldHaveCorrectPrefix that performs a simple check to make sure that private class fields (both instance and static) are prefixed with an underscore. The following code shows the type of field names it fires violations against (and those it doesn’t):&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: teal; FONT-FAMILY: 'Courier New'"&gt;Class1&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;int&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; _Field;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;int&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; _field;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;int&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; Field;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 'Courier New'"&gt;// Violates PrivateFieldsShouldHaveCorrectPrefix&amp;nbsp;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;int&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; field;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 'Courier New'"&gt;// Violates PrivateFieldsShouldHaveCorrectPrefix&amp;nbsp;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;int&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt; m_field; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 'Courier New'"&gt;// Violates PrivateFieldsShouldHaveCorrectPrefix&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Courier New'"&gt;}&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;As the source has been provided, you can change PrivateFieldsShouldHaveCorrectPrefix to follow your own naming rules or add additional rules to the library to enforce your own company’s guidelines.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;To register the rule library with Visual Studio, the built assembly (in this case, Microsoft.FxCop.Rules.Samples.dll) should be placed in the Code Analysis Rules folder, which by default is located at C:\Program Files\Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\Rules. Once the library has been registered, all opened projects (new and existing), will have any rules that are contained in the assembly enabled by default. You can now simply run Code Analysis over a project to analyze it with your new rules.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Before attempting this there are a couple of things you should be aware of:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;You must have either &lt;A href="http://msdn.microsoft.com/vstudio/products/vsts/compare/" mce_href="http://msdn.microsoft.com/vstudio/products/vsts/compare/"&gt;Visual Studio Team Edition for Software Developers&lt;/A&gt; or &lt;A href="http://msdn.microsoft.com/vstudio/products/vsts/compare/" mce_href="http://msdn.microsoft.com/vstudio/products/vsts/compare/"&gt;Visual Studio Team Suite&lt;/A&gt;, as only these editions include the Code Analysis tools.&lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Rules or their base classes must extend BaseIntrospectionRule.&lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The rule description XML file (provided in the sample download) should be an embedded resource and end with ‘Rules.xml’ (case sensitive).&lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Rule libraries need to be compiled in .NET 2.0 and against the versions of Microsoft.Cci.dll and FxCopSdk.dll that ship with Visual Studio. These are located in C:\Program Files\Visual Studio 8\Static Analysis Tools\FxCop by default.&lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The SDK is currently undergoing a massive change, so any rules you write now for Visual Studio 2005,&amp;nbsp;will not&amp;nbsp;work in future versions, however, it should be relatively painless to convert them over.&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Please note that this is not supported by Microsoft so please don’t call Product Support Services if you have any troubles, however, feel free to post any issues you encounter on the &lt;A href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=98&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=98&amp;amp;SiteID=1"&gt;FxCop&lt;/A&gt; forum.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=549611" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/fxcop/attachment/549611.ashx" length="6613" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/fxcop/archive/tags/FAQ/default.aspx">FAQ</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>Simplified FxCop Rules SDK [Michael Fanning]</title><link>http://blogs.msdn.com/fxcop/archive/2004/06/25/simplified-fxcop-rules-sdk-michael-fanning.aspx</link><pubDate>Fri, 25 Jun 2004 23:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166311</guid><dc:creator>mimurray</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/166311.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=166311</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=166311</wfw:comment><description>&lt;P&gt;As mentioned previously here and elsewhere, we're planning to improve and simplify several aspects of FxCop's extensibility model. This is the first of a series of threads about those improvements, in order to solicit feedback and give custom rules developers a heads up on the coming changes. Here's the new simplified IIntrospectionRule interface: &lt;BR&gt;&lt;BR&gt;&amp;nbsp;public interface IIntrospectionRule : IManagedCodeRule &lt;BR&gt;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;Problem[] Check(string namespaceName, TypeNodeList types); &lt;BR&gt;&amp;nbsp;&amp;nbsp;Problem[] Check(Module theModule); &lt;BR&gt;&amp;nbsp;&amp;nbsp;Problem[] Check(Resource resource); &lt;BR&gt;&amp;nbsp;&amp;nbsp;Problem[] Check(TypeNode type); &lt;BR&gt;&amp;nbsp;&amp;nbsp;Problem[] Check(Member member); &lt;BR&gt;&amp;nbsp;} &lt;BR&gt;&lt;BR&gt;This rather drastic simplification has reduced surface area for custom rules and increased FxCop performance without limiting the kinds of checks rules developers can right. Do you need an Assembly rule? Implement a Module rule and check the argument to be sure it's an assembly node. Do you need a Property rule? Implement a member rule and insure the argument is a Property. &lt;BR&gt;&lt;BR&gt;Note that parameter checks have been eliminated. Instead, implement a Member rule and use a new helper method, RuleUtilities.GetParameters(members) to determine whether there's a parameter list to analyze (this helper returns parameters for both properties and methods). Problem class constructors will now accept a parameter argument if you want to associate a message with a specific parameter. &lt;BR&gt;&lt;BR&gt;All comments, questions, and feedback are welcome&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=166311" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>FxCop 1.30 and creating custom rules using Introspection Engine [Michael Murray]</title><link>http://blogs.msdn.com/fxcop/archive/2004/05/19/fxcop-1-30-and-creating-custom-rules-using-introspection-engine-michael-murray.aspx</link><pubDate>Thu, 20 May 2004 06:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:135577</guid><dc:creator>mimurray</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/135577.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=135577</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=135577</wfw:comment><description>&lt;P&gt;&lt;FONT size=1&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-language: AR-SA; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-language: AR-SA; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US"&gt;As John MacKenzie pointed out on the &lt;A href="http://gotdotnet.com/community/messageboard/Thread.aspx?id=225440"&gt;&lt;a title="" href="http://www.gotdotnet.com/team/fxcop/" target="_blank"&gt;GotDotNet&lt;/a&gt; FxCop message board&lt;/A&gt;, John Robbins has a great article in the June issue of MSDN magazine on FxCop 1.30 and custom rules using the new Introspection engine.&amp;nbsp;Check it out at &lt;A href="http://msdn.microsoft.com/msdnmag/issues/04/06/Bugslayer/default.aspx" target=_blank&gt;http://msdn.microsoft.com/msdnmag/issues/04/06/Bugslayer/default.aspx&lt;/A&gt; . &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/04/06/Bugslayer/default.aspx" target=_blank&gt;&lt;FONT color=#000000&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=135577" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>Writing Custom Rules in FxCop &amp;amp;amp; FxCop Visual Studio Integration [Jeffrey van Gogh]</title><link>http://blogs.msdn.com/fxcop/archive/2004/01/09/writing-custom-rules-in-fxcop-amp-fxcop-visual-studio-integration-jeffrey-van-gogh.aspx</link><pubDate>Sat, 10 Jan 2004 04:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:49287</guid><dc:creator>mimurray</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/fxcop/comments/49287.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fxcop/commentrss.aspx?PostID=49287</wfw:commentRss><wfw:comment>http://blogs.msdn.com/fxcop/rsscomments.aspx?PostID=49287</wfw:comment><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;Two common questions we often get are: &lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Arial size=2&gt;Can I write my own rules for FxCop and customize existing rules?&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Arial size=2&gt;Can I integrate FxCop into visual studio and can I jump to the location in my source of the item that FxCop flags as an error?&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;&amp;nbsp;That's why&amp;nbsp;I want to give some more information on both:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000000&gt;FxCop supports writing custom rules. Custom Rules can be written by writing a class in any.NET language. This class has to implement one of the interfaces FxCop provides via its SDK. After compiling the class into an assembly, FxCop can load the custom rule by pointing it to that assembly. Samples and Documentation on how to do this can be found on our webpage: &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT color=navy&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000000&gt;the SDK Documentation:&lt;/FONT&gt; &lt;A title=http://www.gotdotnet.com/team/fxcop/docs/gotdotnetstyle.aspx?url=UsingFxCopSdk.htm href="http://www.gotdotnet.com/team/fxcop/docs/gotdotnetstyle.aspx?url=UsingFxCopSdk.htm"&gt;http://www.gotdotnet.com/team/fxcop/docs/gotdotnetstyle.aspx?url=UsingFxCopSdk.htm&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT color=navy&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000000&gt;the Samples:&lt;/FONT&gt; &lt;A title=http://www.gotdotnet.com/team/fxcop/docs/SDKSamples.zip href="http://www.gotdotnet.com/team/fxcop/docs/SDKSamples.zip"&gt;http://www.gotdotnet.com/team/fxcop/docs/SDKSamples.zip&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000000&gt;FxCop doesn&amp;#8217;t really support editing the default rules right now. We are making some rules configurable for our next release, e.g. you can change settings of the spelling rules and you can change on which members the Naming rules run (by default they run only on members visible outside of the assembly).&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=navy&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000000&gt;FxCop integrates into VS.NET as an external tool using the Commandline version of FxCop. On details how to do this, see &lt;/FONT&gt;&lt;A title=http://www.gotdotnet.com/team/fxcop/docs/UsingFxCopCmd.htm#_Visual_Studio_Integration href="http://www.gotdotnet.com/team/fxcop/docs/UsingFxCopCmd.htm#_Visual_Studio_Integration"&gt;http://www.gotdotnet.com/team/fxcop/docs/UsingFxCopCmd.htm#_Visual_Studio_Integration&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT color=navy&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000000&gt;FxCop is able to find sourcecode location for an error message if both following conditions are met:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The compiler emitted a .pdb file for the assembly (/debug+ switch for C# Compiler, enabled by default in VS)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;FONT face=Arial size=2&gt; &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The error message occurs in an executable piece of code inside the assembly (assembly, namespace, type, field &amp;amp; attribute error messages are not in executable code and the compiler therefore doesn&amp;#8217;t generate source lookup information)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;FONT face=Arial size=2&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Arial color=#000000 size=2&gt;In the upcoming release of FxCop, with our new Metadata reader, we will be able to do a much better job for jumping to source code. Currently FxCop jumps to the first line of a method in which an FxCop issue is found. In the next version of FxCop we will jump to the exact line of code that has an issue.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=49287" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx">Custom Rules</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.msdn.com/fxcop/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item></channel></rss>