<?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>Habib Heydarian's Blog @ Microsoft : Team System 2010</title><link>http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx</link><description>Tags: Team System 2010</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Create your own Code Analysis rule set using Visual Studio Team System 2010</title><link>http://blogs.msdn.com/habibh/archive/2009/08/12/create-your-own-code-analysis-rule-set-using-visual-studio-team-system-2010.aspx</link><pubDate>Wed, 12 Aug 2009 10:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9865693</guid><dc:creator>habibh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9865693.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9865693</wfw:commentRss><description>&lt;p&gt;In a previous &lt;a href="http://blogs.msdn.com/habibh/archive/2009/07/31/discover-dead-code-in-your-application-using-code-analysis.aspx"&gt;post&lt;/a&gt;, I explained how to use Code Analysis in Visual Studio 2010 to detect dead code. In that post, I described the following five Code Analysis rules in detail and how these &lt;em&gt;set of rules&lt;/em&gt; form the basis for detecting dead code:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Private methods that are not called from any other code (CA1811) &lt;/li&gt;    &lt;li&gt;Unused local variables (CA1804) &lt;/li&gt;    &lt;li&gt;Unused private fields (CA1823) &lt;/li&gt;    &lt;li&gt;Unused parameters (CA1801) &lt;/li&gt;    &lt;li&gt;Internal classes that are not instantiated from any other code (CA1812) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;To take this one step further, it would make sense to be able to treat this set of rules as one entity so I can manage all the rules for dead code detection as a single entity. In Visual Studio 2010, we have introduced the notion of a &lt;em&gt;&lt;strong&gt;rule set&lt;/strong&gt;&lt;/em&gt; that allows you to do exactly that.&lt;/p&gt;  &lt;h2&gt;What is a &amp;quot;rule set&amp;quot;?&lt;/h2&gt;  &lt;p&gt;Think of a rule set as a container or collection of rules. A rule set allows you to bundle one or more Code Analysis rules into an arbitrary category for easier management of those rules. For example, in Team System 2010, we are providing a number of rule sets out of the box:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Microsoft Security Rules &lt;/li&gt;    &lt;li&gt;Microsoft Basic Correctness Rules &lt;/li&gt;    &lt;li&gt;Microsoft Globalization Rules &lt;/li&gt;    &lt;li&gt;etc. &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;How to create a rule set&lt;/h2&gt;  &lt;p&gt;For our walkthrough, we want to create a rule set called &lt;strong&gt;&lt;em&gt;Dead Code Detection Rules&lt;/em&gt;&lt;/strong&gt; that contains the five dead code detection rules mentioned above. The first step in creating a rule set is to create a new rule set file (*.ruleset). You can create a new rule set file via &lt;em&gt;File –&amp;gt; New –&amp;gt; File&lt;/em&gt;. In this example, I've given the rule set the name &lt;strong&gt;DeadCodeDetectionRules.ruleset&lt;/strong&gt;, as shown below.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="New file dialog" border="0" alt="New file dialog" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/CreateyourownCodeAnalysisrulesetusingVis_13F64/image_19.png" width="823" height="583" /&gt; &lt;/p&gt;  &lt;p&gt;After creating the rule set, set the name and description of the rule set using the Properties window, as shown in the following screen shot.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Rule set Properties window" border="0" alt="Rule set Properties window" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/CreateyourownCodeAnalysisrulesetusingVis_13F64/image_16.png" width="421" height="388" /&gt; &lt;/p&gt;  &lt;p&gt;Since the rule set doesn't contain any rules yet, the rule set editor shows none of the rules as being checked. The rule set editor (shown below) is a new window in Visual Studio Team System 2010 that allows you manage rules and rule sets.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Dead Code Rules rule set" border="0" alt="Dead Code Rules rule set" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/CreateyourownCodeAnalysisrulesetusingVis_13F64/image_5.png" width="807" height="359" /&gt; &lt;/p&gt;  &lt;p&gt;To start adding rules to the DeadCodeDetectionRules rule set, you can search for a rule using either the rule number or its name, as shown below. You can also simply expand the rule categories and select the rules that you are interested in.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/CreateyourownCodeAnalysisrulesetusingVis_13F64/image_7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Search in Rule set editor" border="0" alt="Search in Rule set editor" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/CreateyourownCodeAnalysisrulesetusingVis_13F64/image_thumb_2.png" width="807" height="350" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After adding all five dead code detection rules, the rule set editor should look something like this:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Rule set editor with added rules" border="0" alt="Rule set editor with added rules" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/CreateyourownCodeAnalysisrulesetusingVis_13F64/image_22.png" width="804" height="345" /&gt; &lt;/p&gt;  &lt;h2&gt;Applying a rule set to a project&lt;/h2&gt;  &lt;p&gt;Once the rule set has been created, the next step is to apply the rule set to a project. This can be done via the Project Properties window. On the Code Analysis tab, click the dropdown next to the [Open] button and select &amp;quot;Browse...&amp;quot; to browse to the location of the rule set file. After selecting the rule set, the name and description of the rule set are shown in the summary page.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Applying a rule set." border="0" alt="Applying a rule set." src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/CreateyourownCodeAnalysisrulesetusingVis_13F64/image_25.png" width="804" height="533" /&gt; &lt;/p&gt;  &lt;p&gt;So now, all the dead code detection rules are part of a single rule set which make it much easier to manage, modify and apply the rules at both the project level as well as TFS policy level.&lt;/p&gt;  &lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9865693" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category><category domain="http://blogs.msdn.com/habibh/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>Visualize project dependencies with the Team System 2010 Architecture Explorer</title><link>http://blogs.msdn.com/habibh/archive/2009/08/06/visualize-project-dependencies-with-the-team-system-2010-architecture-explorer.aspx</link><pubDate>Thu, 06 Aug 2009 10:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9858711</guid><dc:creator>habibh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9858711.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9858711</wfw:commentRss><description>&lt;p&gt;As early as Visual Studio 2002, Visual Studio has supported the ability to see the dependencies between projects in a solution. However, the experience is somewhat clunky in that you can only see the dependencies one project at a time.&lt;/p&gt;  &lt;p&gt;In the example below, you can see the project dependencies for the &lt;em&gt;Patient Monitoring&lt;/em&gt; project. However, as I mentioned above, the major drawback to this approach is that you can only see the dependencies one project at a time and don't get to see a &amp;quot;global view&amp;quot; of your solution. There is also another scenario that today's solution doesn't solve. The problem is that the only way to find out &lt;em&gt;why&lt;/em&gt; a dependency exists is to look at the code or use some other tool. In the screenshot below, the &lt;strong&gt;Project Dependencies&lt;/strong&gt; dialog doesn't tell you why the &lt;em&gt;Patient Monitoring&lt;/em&gt; project is dependent on the &lt;em&gt;Chart&lt;/em&gt; project.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Project dependencies" border="0" alt="Project dependencies" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/VisualizeprojectdependencieswiththeTeamS_11E50/image_16.png" width="800" height="600" /&gt; &lt;/p&gt;  &lt;p&gt;Architecture Explorer in Team System 2010 not only allows you to see the project dependencies for the entire solution but it also allows you to see the reason why each dependency exists. Each arrow in the screenshot below represents a dependency. Furthermore, the thickness of an arrow indicates the size of the dependency. Notice that there are no arrows going in or out of the ChartVisuals project. Using the Architecture Explorer, I discovered that this project is not being used anywhere!&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Architecture Explorer diagram" border="0" alt="Architecture Explorer diagram" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/VisualizeprojectdependencieswiththeTeamS_11E50/image_13.png" width="638" height="650" /&gt; &lt;/p&gt;  &lt;p&gt;To investigate a dependency further, you can expand the chevron (double arrows) on each node. This will not only display the classes within a project but it will also draw arrows from the classes that have dependencies on other projects. You can even dig one level deeper to see the &lt;em&gt;methods&lt;/em&gt; in those classes that are calling into the dependencies. This is shown via the blue arrows below.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Architecture Explorer diagram expanded" border="0" alt="Architecture Explorer diagram expanded" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/VisualizeprojectdependencieswiththeTeamS_11E50/image_19.png" width="879" height="652" /&gt; &lt;/p&gt;  &lt;p&gt;In a future blog post, I'll walk through how to use the Architecture Explorer to analyze circular references and class coupling.&lt;/p&gt;  &lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9858711" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category></item><item><title>PDC 2009: Developing Quality Software using Visual Studio Team System 2010</title><link>http://blogs.msdn.com/habibh/archive/2009/08/05/pdc-2009-developing-quality-software-using-visual-studio-team-system-2010.aspx</link><pubDate>Wed, 05 Aug 2009 10:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9857757</guid><dc:creator>habibh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9857757.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9857757</wfw:commentRss><description>&lt;p&gt;Software quality is a subject that is near and dear to my heart. At PDC 2009 this year, there is full day workshop on how to use Visual Studio Team System 2010 to &lt;a href="http://microsoftpdc.com/Sessions/Developing-Quality-Software-using-Visual-Studio-Team-System-2010"&gt;develop high quality software&lt;/a&gt;. I'm really excited about this workshop since it covers a lot of the features that my team works on including the debugger, profiler, code analysis, Historical Debugger, code coverage, etc.&lt;/p&gt;  &lt;p&gt;By the way, if you are heading down to PDC09, feel free to drop by the Visual Studio Team System booth for a chat. Who knows, I might also be giving a talk or two on the new developer features in Team System 2010.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/PDC2009DevelopingQualitySoftwareusingVis_14AF8/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="PDC09" border="0" alt="PDC09" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/PDC2009DevelopingQualitySoftwareusingVis_14AF8/image_thumb.png" width="242" height="242" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9857757" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/Announcements/default.aspx">Announcements</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category></item><item><title>Catch string formatting bugs with Visual Studio Team System 2010</title><link>http://blogs.msdn.com/habibh/archive/2009/08/03/catch-string-formatting-bugs-with-visual-studio-team-system-2010.aspx</link><pubDate>Tue, 04 Aug 2009 03:43:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9856655</guid><dc:creator>habibh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9856655.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9856655</wfw:commentRss><description>&lt;p&gt;Formatting strings is a very common task in .NET development. Examples include formatting dates and currencies, composing a HTML response, creating error messages, etc. One of the downsides of string formatting is that if done incorrectly, you can end up with subtle bugs that won't be detected until runtime at which point, the application usually crashes with an exception.&lt;/p&gt;  &lt;p&gt;Take the following code sample which comes from a real world application. It compiles fine and &lt;em&gt;most&lt;/em&gt; of the time, it also runs without any problems However, once in a while, there is a customer complaint that the application crashes. It turns out that the &lt;font face="Courier New"&gt;if&lt;/font&gt; part of the code is rarely executed and because it isn't a common scenario, it wasn't tested.&lt;/p&gt;  &lt;p&gt;So, what is the problem? If you look closely at line 6 below where the string &lt;font face="Courier New"&gt;body&lt;/font&gt; is formatted, the second format item which is supposed to be the user's name is missing. As I mentioned above, there is no compiler warning or error to tell the developer about this problem. It's usually found during testing or worse case, in production.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; btnSubmit_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (isEditingPost)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; body = txtBody.Value;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;         body += &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;p&amp;gt;-- {0}: post edited by {1}.&amp;lt;/p&amp;gt;&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;            DateTime.Now.ToString());&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// edit an existing post&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;         Post.UpdatePost(postID, txtTitle.Text, body);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;         panInput.Visible = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         panFeedback.Visible = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// Rest of code not shown&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In Team System 2010, we have added a new rule to Code Analysis that detects this exact problem. When I run Code Analysis over the code above, it clearly warns me that I'm missing a format item:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;warning: CA2241 : Microsoft.Usage : Method 'AddEditPost.btnSubmit_Click(object, EventArgs)' calls 'string.Format(string, object)' and does not provide an argument for format item &amp;quot;{1}&amp;quot;. The provided format string is: '&amp;quot;&amp;lt;p&amp;gt;-- {0}: post edited by {1}.&amp;lt;/p&amp;gt;&amp;quot;'&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This feature is available in &lt;a href="http://msdn.microsoft.com/en-us/teamsystem/dd819231.aspx"&gt;Visual Studio Team System 2010 Beta 1&lt;/a&gt;. Feel free to download the beta and if you have any feedback on this feature, please leave me a comment.&lt;/p&gt;

&lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9856655" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category><category domain="http://blogs.msdn.com/habibh/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>Use UML Sequence Diagrams in Team System 2010 to reverse engineer your code</title><link>http://blogs.msdn.com/habibh/archive/2009/07/29/use-uml-sequence-diagrams-in-team-system-2010-to-reverse-engineer-your-code.aspx</link><pubDate>Wed, 29 Jul 2009 10:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9851711</guid><dc:creator>habibh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9851711.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9851711</wfw:commentRss><description>&lt;p&gt;One of the new features that we have added in Visual Studio Team System 2010 is the ability to create a new UML Sequence Diagram as well as generate one from existing code. I'm not going to go into too much detail on what a UML sequence diagram is since there is a plethora of information about the subject on &lt;a href="http://en.wikipedia.org/wiki/Sequence_diagram"&gt;Wikipedia&lt;/a&gt;. Instead, I'm going to walk you through an example on how to generate a sequence diagram for an existing application using Team System 2010.&lt;/p&gt;  &lt;p&gt;For this example, I'm going to use the BeerHouse sample application. BeerHouse contains a method (AddShoppingCartItem) which adds a product to the user's shopping code. The AddShoppingCartItem method is shown below.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ActionResult AddShoppingCartItem(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; productId, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;? quantity)&lt;br /&gt;{&lt;br /&gt;    TheBeerHouseDataContext dc = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; TheBeerHouseDataContext();&lt;br /&gt;    ProfileBase profileBase = HttpContext.Profile &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ProfileBase;&lt;br /&gt;    ShoppingCart shoppingCart = (ShoppingCart)profileBase.GetPropertyValue(&lt;span style="color: #006080"&gt;&amp;quot;ShoppingCart&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (shoppingCart == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;        shoppingCart = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ShoppingCart();&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;// get the cheapest shipping method for our user&lt;/span&gt;&lt;br /&gt;        var cheapestShippingMethod = dc.ShippingMethods.GetShippingMethods().Cheapest();&lt;br /&gt;        shoppingCart.ShippingMethod = cheapestShippingMethod;&lt;br /&gt;&lt;br /&gt;        profileBase.SetPropertyValue(&lt;span style="color: #006080"&gt;&amp;quot;ShoppingCart&amp;quot;&lt;/span&gt;, shoppingCart);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    Product product = dc.Products.GetProduct(productId);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// throw a 404 Not Found if the requested forum is not in the database&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (product == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; HttpException(404, &lt;span style="color: #006080"&gt;&amp;quot;The product could not be found.&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    ShoppingCartItem item = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ShoppingCartItem(product) {&lt;br /&gt;        Quantity = quantity ?? 1&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    shoppingCart.Add(item);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; RedirectToAction(&lt;span style="color: #006080"&gt;&amp;quot;ViewShoppingCart&amp;quot;&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You can certainly read through the code above to try and understand what it does. Alternatively, using a UML sequence diagram, you can visually see the sequence of calls within this method. To generate a sequence diagram, right-click anywhere inside the method (in this case AddShoppingCartItem) and select the &amp;quot;Generate Sequence Diagram&amp;quot; method, as shown below.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Generate Sequence Diagram" border="0" alt="Generate Sequence Diagram" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/SequenceDiagramsinTeamSystem2010_65A5/image_3.png" width="807" height="311" /&gt; &lt;/p&gt;

&lt;p&gt;After selecting the &lt;em&gt;Generate Sequence Diagram&lt;/em&gt; command, the &amp;quot;Generate a Sequence Diagram&amp;quot; dialog appears, as shown below. The purpose of this dialog is to allow you to control the amount of information that is displayed on the diagram. There are essentially three knobs to control the amount of information that is generated on the diagram: call depth, scope, namespace.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Generate a Sequence Diagram" border="0" alt="Generate a Sequence Diagram" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/SequenceDiagramsinTeamSystem2010_65A5/image_20.png" width="325" height="294" /&gt; &lt;/p&gt;

&lt;p&gt;After clicking the [OK] button, the sequence diagram below is generated. It should be immediately clear how much easier it is to understand the sequence of method calls using the diagram instead of reading through the code.&lt;/p&gt;

&lt;p&gt;In the diagram below, you can see that there are five objects involved and how the objects interact with each other. Also, there is a section marked &lt;strong&gt;Opt &lt;/strong&gt;which stands for &amp;quot;optional&amp;quot; meaning that the sequence of calls within the &lt;strong&gt;Opt&lt;/strong&gt; section are dependent on some condition being true (in this case when &lt;font face="Courier New"&gt;shoppingCart == null&lt;/font&gt;).&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="UML Sequence Diagram" border="0" alt="UML Sequence Diagram" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/SequenceDiagramsinTeamSystem2010_65A5/image_21.png" width="795" height="904" /&gt; &lt;/p&gt;

&lt;h2&gt;Tips&lt;/h2&gt;

&lt;p&gt;Here are a few tips for using sequence diagrams.&lt;/p&gt;

&lt;h3&gt;Changing the default name of a sequence diagram&lt;/h3&gt;

&lt;p&gt;By default, the name of the sequence diagram that is generated is cryptic and not very friendly. You cannot change the name on the diagram itself. Instead, you have to use the Properties window to change the &lt;em&gt;Name&lt;/em&gt; property, as shown below.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Sequence Diagram Properties" border="0" alt="Sequence Diagram Properties" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/SequenceDiagramsinTeamSystem2010_65A5/image_22.png" width="403" height="238" /&gt; &lt;/p&gt;

&lt;h3&gt;Adding a comment to a sequence diagram&lt;/h3&gt;

&lt;p&gt;It's often helpful to annotate sequence diagrams by adding comments. To add a comment, right-click on the sequence diagram and select Add –&amp;gt; Comment.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Add a comment to a sequence diagram" border="0" alt="Add a comment to a sequence diagram" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/SequenceDiagramsinTeamSystem2010_65A5/image_23.png" width="485" height="233" /&gt; &lt;/p&gt;

&lt;p&gt;As a last note, the ability to generate a UML sequence diagram is only supported for C# and VB.NET.&lt;/p&gt;

&lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9851711" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category></item><item><title>Walkthrough: Measure the performance of your JScript code with Team System 2010</title><link>http://blogs.msdn.com/habibh/archive/2009/07/24/walkthrough-measure-the-performance-of-your-jscript-code-with-team-system-2010.aspx</link><pubDate>Fri, 24 Jul 2009 22:41:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9847811</guid><dc:creator>habibh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9847811.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9847811</wfw:commentRss><description>&lt;p&gt;In Visual Studio Team System 2010, one of the new features that we have added to the Profiler is the ability to measure the performance of JScript code that runs in the browser. This means that if you have a web application that contains ASP.NET AJAX or plain old JScript, you can now measure how long it takes to execute the JScript portion of the application. The main restriction with this feature is that it is only supported for Internet Explorer 8.&lt;/p&gt;  &lt;p&gt;In this walkthrough, I'm using the BeerHouse sample application. Specifically, I want to measure the performance of the &lt;strong&gt;UpdateProgress()&lt;/strong&gt; JScript function by figuring out how many times it is called. This function visually displays the current progress when a newsletter is sent to the list of subscribers. The body of UpdateProgress() is shown below.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;function&lt;/span&gt; UpdateProgress(result, context) &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;    &lt;span style="color: #008000"&gt;// result is a semicolon-separated list of values, so split it&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; &lt;span style="color: #0000ff"&gt;params&lt;/span&gt; = result.split(&lt;span style="color: #006080"&gt;&amp;quot;;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; percentage = &lt;span style="color: #0000ff"&gt;params&lt;/span&gt;[0];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; sentMails = &lt;span style="color: #0000ff"&gt;params&lt;/span&gt;[1];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; totalMails = &lt;span style="color: #0000ff"&gt;params&lt;/span&gt;[2];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (totalMails &amp;lt; 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;       totalMails = &lt;span style="color: #006080"&gt;'???'&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;    &lt;span style="color: #008000"&gt;// update progressbar's width and description text&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; progBar = window.document.getElementById(&lt;span style="color: #006080"&gt;'progressbar'&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;    progBar.style.width = percentage + &lt;span style="color: #006080"&gt;'%'&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; descr = window.document.getElementById(&lt;span style="color: #006080"&gt;'progressdescription'&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;    descr.innerHTML = &lt;span style="color: #006080"&gt;'&amp;lt;b&amp;gt;'&lt;/span&gt; + percentage + &lt;span style="color: #006080"&gt;'% completed&amp;lt;/b&amp;gt; - '&lt;/span&gt; +&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;       sentMails + &lt;span style="color: #006080"&gt;' out of '&lt;/span&gt; + totalMails + &lt;span style="color: #006080"&gt;' e-mails have been sent.'&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;    &lt;span style="color: #008000"&gt;// if the current percentage is less than 100%, &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;    &lt;span style="color: #008000"&gt;// recall the server callback method in 2 seconds&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (percentage == &lt;span style="color: #006080"&gt;'100'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;       window.document.getElementById(&lt;span style="color: #006080"&gt;'panelcomplete'&lt;/span&gt;).style.display = &lt;span style="color: #006080"&gt;''&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;       setTimeout(&lt;span style="color: #006080"&gt;'CallUpdateProgress()'&lt;/span&gt;, 2000);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;And here is what the progress bar feature looks like.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Update Progress feature" border="0" alt="Update Progress feature" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughMeasuretheperformanceofyourAJ_E2A2/image_5.png" width="804" height="576" /&gt; &lt;/p&gt;

&lt;p&gt;To start collecting performance information about your application, select the &amp;quot;Launch Performance Wizard...&amp;quot; command from the &lt;strong&gt;Analyze&lt;/strong&gt; menu, as shown here.&lt;/p&gt;

&lt;p&gt;&lt;img title="Analyze menu" border="0" alt="Analyze menu" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_6.png" width="783" height="561" /&gt;&lt;/p&gt;

&lt;p&gt;Once the Performance Wizard comes up, select the &lt;strong&gt;Instrumentation&lt;/strong&gt; option and click [Next].&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Page 1 of the Performance Wizard" border="0" alt="Page 1 of the Performance Wizard" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughMeasuretheperformanceofyourAJ_E2A2/image_11.png" width="641" height="485" /&gt; &lt;/p&gt;

&lt;p&gt;On the second page of the Performance Wizard, you can select which application you want to profile. Since I am profiling the BeerHouse application and it's already open in Visual Studio, the Profiler will automatically select the project for me, as shown below.&lt;/p&gt;

&lt;p&gt;&lt;img title="Select application to profile" border="0" alt="Select application to profile" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_12.png" width="641" height="535" /&gt;&lt;/p&gt;

&lt;p&gt;This next step is important! On the last page of the wizard, the checkbox to &amp;quot;Launch profiling after the wizard finishes&amp;quot; is checked. Uncheck it and click the [Finish] button.&lt;/p&gt;

&lt;p&gt;&lt;img title="Performance Wizard last page" border="0" alt="Performance Wizard last page" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_18.png" width="641" height="535" /&gt;&lt;/p&gt;

&lt;p&gt;After clicking the [Finish] button, Visual Studio will open the &amp;quot;Performance Explorer&amp;quot; window. In this window, under the &amp;quot;Targets&amp;quot; node, you can see the target application to be profiled . Right-click the target (in this case TBH_Web) and select Properties, as shown below.&lt;/p&gt;

&lt;p&gt;&lt;img title="Target properties context menu" border="0" alt="Target properties context menu" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_21.png" width="725" height="521" /&gt;&lt;/p&gt;

&lt;p&gt;In the Properties dialog, select the &amp;quot;Instrumentation&amp;quot; tab and check the &amp;quot;Profile JavaScript&amp;quot; option. Press [OK] to dismiss the dialog.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Enable Profile JavaScript" border="0" alt="Enable Profile JavaScript" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughMeasuretheperformanceofyourAJ_E2A2/image_10.png" width="678" height="430" /&gt; &lt;/p&gt;

&lt;p&gt;Next, in the Performance Explorer window, click the &amp;quot;Launch with Profiling&amp;quot; toolbar button to start collecting performance data about your application. See below for a screenshot.&lt;/p&gt;

&lt;p&gt;&lt;img title="Start profiling" border="0" alt="Start profiling" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_thumb_8.png" width="209" height="270" /&gt;&lt;/p&gt;

&lt;p&gt;This will launch the BeerHouse application and start collecting performance data. In order to capture information about the UpdateProgress() function, I need to exercise the feature by creating a newsletter and sending it to the subscribers of the BeerHouse web site. After completing the scenario, exit the application which will cause the profiler to stop collecting additional information about the application.&lt;/p&gt;

&lt;p&gt;In the screenshot below, I've selected the &amp;quot;Call Tree&amp;quot; view to highlight information about the UpdateProgress() JScript function. As you can see from the screenshot, this function was called 12 times from the SendNewsletter.aspx page. The profiler not only shows how many times this function was called but also how long it took. Using this information, I can now make a decision as to whether to investigate this feature further or determine the performance is fine.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughMeasuretheperformanceofyourAJ_E2A2/image_14.png" width="805" height="602" /&gt; &lt;/p&gt;

&lt;p&gt;The steps shown in this walkthrough are applicable any time that you want to measure the performance of JScript code running in Internet Explorer 8. The JScript profiler feature is available as part of Visual Studio Team System 2010 Beta 1 which you can download from &lt;a href="http://msdn.microsoft.com/en-us/teamsystem/dd819231.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9847811" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category><category domain="http://blogs.msdn.com/habibh/archive/tags/Performance+Tuning/default.aspx">Performance Tuning</category></item><item><title>Use Code Analysis to measure the quality of sample code</title><link>http://blogs.msdn.com/habibh/archive/2009/07/21/use-code-analysis-to-measure-the-quality-of-sample-code.aspx</link><pubDate>Tue, 21 Jul 2009 15:08:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9843277</guid><dc:creator>habibh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9843277.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9843277</wfw:commentRss><description>&lt;p&gt;Sample code is great because it allows you to quickly get up to speed with a new technology or learn how an API works and sometimes, you might even use some of the code in your own application. The major downside of reusing sample code is that most often, the code wasn't written with production quality in mind, so things like error handling, performance, security, etc. are omitted from the code.&lt;/p&gt;  &lt;p&gt;Here is an example. The &lt;a href="http://www.asp.net/downloads/starter-kits/the-beer-house/"&gt;BeerHouse&lt;/a&gt; E-commerce sample application that is available from &lt;a href="http://www.asp.net"&gt;http://www.asp.net&lt;/a&gt; contains the &lt;strong&gt;UpdateOrder&lt;/strong&gt; method which unsurprisingly updates a customer order. By looking at the code, you might decide that it looks ok and therefore decide to reuse it in your own application.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// Updates an existing order&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; UpdateOrder(OrderDetails order)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (SqlConnection cn = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlConnection(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.ConnectionString))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; shippedDate = order.ShippedDate;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (order.ShippedDate == DateTime.MinValue)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;          shippedDate = DBNull.Value;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;       SqlCommand cmd = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlCommand(&lt;span style="color: #006080"&gt;&amp;quot;tbh_Store_UpdateOrder&amp;quot;&lt;/span&gt;, cn);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;       cmd.CommandType = CommandType.StoredProcedure;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;       cmd.Parameters.Add(&lt;span style="color: #006080"&gt;&amp;quot;@OrderID&amp;quot;&lt;/span&gt;, SqlDbType.Int).Value = order.ID;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;       cmd.Parameters.Add(&lt;span style="color: #006080"&gt;&amp;quot;@StatusID&amp;quot;&lt;/span&gt;, SqlDbType.Int).Value = order.StatusID;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;       cmd.Parameters.Add(&lt;span style="color: #006080"&gt;&amp;quot;@ShippedDate&amp;quot;&lt;/span&gt;, SqlDbType.DateTime).Value = shippedDate;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;       cmd.Parameters.Add(&lt;span style="color: #006080"&gt;&amp;quot;@TransactionID&amp;quot;&lt;/span&gt;, SqlDbType.NVarChar).Value = order.TransactionID;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;       cmd.Parameters.Add(&lt;span style="color: #006080"&gt;&amp;quot;@TrackingID&amp;quot;&lt;/span&gt;, SqlDbType.NVarChar).Value = order.TrackingID;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;       cn.Open();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; ret = ExecuteNonQuery(cmd);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (ret == 1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;However, if you look closer at the parameter &lt;strong&gt;&lt;em&gt;order&lt;/em&gt;&lt;/strong&gt; and follow its usage throughout the method, you will notice that it's not validated before being used. That, combined with the fact that the method is declared &lt;em&gt;public&lt;/em&gt; means that the &lt;strong&gt;UpdateOrder&lt;/strong&gt; method is a ticking time bomb that could blow up at any time. All it takes is to call the method and pass in &lt;em&gt;null&lt;/em&gt; for the parameter &lt;em&gt;order&lt;/em&gt;. The following screenshot shows the extent of the problem where the usage of the parameter &lt;strong&gt;&lt;em&gt;order&lt;/em&gt;&lt;/strong&gt; is highlighted.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Sample code" border="0" alt="Sample code" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/67b34901df55_7723/image3.png" width="971" height="569" /&gt; &lt;/p&gt;

&lt;p&gt;In Visual Studio Team System 2010, Code Analysis provides the ability to detect this exact problem. Code Analysis can detect if a parameter of a public method is validated and if not, it will warn you about it. When I ran Code Analysis on this application, Code Analysis displayed the following warning in the &lt;em&gt;Error List&lt;/em&gt; (among other errors):&lt;/p&gt;

&lt;p&gt;c:\Users\Administrator\Desktop\TheBeerHouse\TBH_Web\App_Code\DAL\SqlClient\SqlStoreProvider.cs(610) : &lt;font color="#ff0000"&gt;warning: CA1062 : Microsoft.Design : In externally visible method 'SqlStoreProvider.UpdateOrder(OrderDetails)', validate parameter 'order' before using it.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;The fix for this bug is as simple as adding an assert and checking for the null condition.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// Updates an existing order&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; UpdateOrder(OrderDetails order)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     Debug.Assert(order != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (order == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;    &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (SqlConnection cn = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlConnection(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.ConnectionString))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The first time that I ran Code Analysis on a sample application I was amazed at the number of bugs in the code, including performance and severe security bugs. Nowadays, I've gotten into the habit of running Code Analysis first to see the overall health of the sample code before using it.&lt;/p&gt;

&lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9843277" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category><category domain="http://blogs.msdn.com/habibh/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>Visual Studio Team System 2010 Profiler and Virtual Machines: Error VSP1454 is no more!</title><link>http://blogs.msdn.com/habibh/archive/2009/07/08/visual-studio-team-system-2010-profiler-and-virtual-machines-error-vsp1454-is-no-more.aspx</link><pubDate>Thu, 09 Jul 2009 07:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9829118</guid><dc:creator>habibh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9829118.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9829118</wfw:commentRss><description>&lt;p&gt;Prior to Team System 2010, if you try to profile an application on a virtual machine (e.g. Virtual PC, Hyper-V, VMWare) using sampling mode, this is the error that you will see:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Error VSP1454 dialog" border="0" alt="Error VSP1454 dialog" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/VisualStudioTeamSystem2010ProfilerandVir_D688/image_5.png" width="444" height="163" /&gt; &lt;/p&gt;  &lt;p&gt;Unfortunately, if you want to use sampling mode, you're pretty much stuck! The only &amp;quot;workaround&amp;quot; is to profile your application using instrumentation mode instead of sampling mode.&lt;/p&gt;  &lt;p&gt;I'm glad to report that in Team System 2010, we now support profiling applications in sampling mode! Our support extends to Virtual PC 2007, Hyper-V and VMWare. The reason why this is important is because increasingly, we are noticing that developers are using virtual machines as their main development environment. &lt;/p&gt;  &lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9829118" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category></item><item><title>Troubleshooting Team Foundation Server 2010 Beta 1 error TF255275</title><link>http://blogs.msdn.com/habibh/archive/2009/07/06/troubleshooting-team-foundation-server-2010-beta-1-error-tf255275.aspx</link><pubDate>Mon, 06 Jul 2009 15:10:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9819607</guid><dc:creator>habibh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9819607.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9819607</wfw:commentRss><description>&lt;p&gt;When installing Team Foundation Server 2010 Beta 1, you might run across the following error during the readiness check:&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&lt;font color="#ff0000"&gt;Error&amp;#160;&amp;#160;&amp;#160; [ Reporting ] TF255275: The following Web service for SQL Server Reporting Services could not be accessed: http://&amp;lt;machine_name&amp;gt;/ReportServer/ReportService2005.asmx.&lt;/font&gt;       &lt;br /&gt;Warning&amp;#160;&amp;#160;&amp;#160; [ Project Collection ] TF255331: The existence of the following folder on the report server could not be verified: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing.. A network problem might have prevented communication, the report server might be offline, or your account might not have permissions on the report server. The team project collection could not be created. To complete this wizard, you must specify the option not to create a collection. As an alternative, you can close this wizard, correct the problem, and then restart the wizard.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;What's interesting is that if you copy the URL above into a browser, the browser *can* find the the web service (ReportService2005.asmx) just fine. So, what's the issue? Typically, this problem happens if the machine name was changed since SQL Server Reporting Services was installed on that machine. When you try to install TFS 2010, it tries to contact the SQL Server Reporting Services via the old name of the machine which no longer exists. The workaround is to delete the databases for the Reporting Services and recreate them using the Reporting Services Configuration Manager.&lt;/p&gt;  &lt;p&gt;First, open the SQL Server Management Studio and under the Database node, delete both the ReportServer and ReportServerTempDB databases, as shown below.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Delete RS dabases using SSMS" border="0" alt="Delete RS dabases using SSMS" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/TroubleshootingTeamFoundationServer2010B_E6DC/image_9.png" width="708" height="500" /&gt; &lt;/p&gt;  &lt;p&gt;Next, start the Reporting Services Configuration Manager from the Start menu, shown here.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Start Menu showing RSCM" border="0" alt="Start Menu showing RSCM" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/TroubleshootingTeamFoundationServer2010B_E6DC/image_12.png" width="403" height="534" /&gt; &lt;/p&gt;  &lt;p&gt;In the Reporting Services Configuration Manager, select the &lt;em&gt;Database&lt;/em&gt; tab. On the Database tab, click the [Change Database] button, only here were are going to create the databases, instead of changing them.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Reporting Services Configuration Manager dialog" border="0" alt="Reporting Services Configuration Manager dialog" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/TroubleshootingTeamFoundationServer2010B_E6DC/image_11.png" width="816" height="616" /&gt; &lt;/p&gt;  &lt;p&gt;On the Change Database page, make sure the &amp;quot;Create a new report server database&amp;quot; option is selected. Click the [Next] button.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Create a new report server database" border="0" alt="Create a new report server database" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/TroubleshootingTeamFoundationServer2010B_E6DC/image_6.png" width="684" height="493" /&gt; &lt;/p&gt;  &lt;p&gt;After clicking the [Next] button, enter the name of the computer where SQL Server is running, as shown below.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/TroubleshootingTeamFoundationServer2010B_E6DC/image_3.png" width="684" height="493" /&gt; &lt;/p&gt;  &lt;p&gt;On the subsequent steps in the wizard, keep the default options and continue clicking the [Next] button. When finished, click the [Exit] button on the Reporting Services Configuration Manager dialog. Re-run the Team Foundation Administration Console and the error should no longer appear.&lt;/p&gt;  &lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9819607" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Administering/default.aspx">VSTS Administering</category></item><item><title>Preventing SQL Injection Attacks with Visual Studio Team System 2010</title><link>http://blogs.msdn.com/habibh/archive/2009/07/02/preventing-sql-injection-attacks-with-visual-studio-team-system-2010.aspx</link><pubDate>Thu, 02 Jul 2009 16:46:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9814114</guid><dc:creator>habibh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9814114.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9814114</wfw:commentRss><description>&lt;p&gt;There are numerous articles on the web that describe the perils of SQL Injection attacks and warn developers about the fact that &amp;quot;All Input is Evil!&amp;quot;. If you are interested in reading more about what a SQL Injection attack is, Wikipedia has a pretty good introduction to the &lt;a href="http://en.wikipedia.org/wiki/SQL_injection"&gt;subject&lt;/a&gt;. There are a number of recommendations on how to prevent SQL Injection attacks including sanitizing all user input, securing the database, etc. However, the onus is still on the developer to find out if his application is susceptible to SQL Injection attacks.&lt;/p&gt;  &lt;p&gt;With Visual Studio Team System 2010, we've introduced a new Code Analysis feature that detects and warns developers about SQL Injection attacks, thus relieving the developer from some of the burden. But more importantly, this feature helps developers write more secure code to begin with.&lt;/p&gt;  &lt;h3&gt;A SQL Injection example&lt;/h3&gt;  &lt;p&gt;For this example, I’m going to use the good old N&lt;em&gt;orthwind&lt;/em&gt; sample database and some ASP.NET code to walk through the scenario. In the method below, the SQL string &lt;em&gt;strSQL&lt;/em&gt; is dynamically constructed to retrieve products from the Northwind database. Furthermore, the user can filter out products by typing in some text that is used as a filter (txtFilter). The reason why this method is susceptible to a SQL Injection attack is because &lt;em&gt;strSQL&lt;/em&gt; is created by using values directly entered by the user which are not sanitized in any way.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; DataView CreateDataView()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; connString = ConfigurationManager.ConnectionStrings[0].ConnectionString;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; strSQL = &lt;span style="color: #006080"&gt;&amp;quot;SELECT ProductId, ProductName, QuantityPerUnit, UnitPrice FROM Products&amp;quot;&lt;/span&gt;;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (txtFilter.Text.Length &amp;gt; 0) &lt;br /&gt;    {&lt;br /&gt;        strSQL += &lt;span style="color: #006080"&gt;&amp;quot; WHERE ProductName LIKE '&amp;quot;&lt;/span&gt; + txtFilter.Text + &lt;span style="color: #006080"&gt;&amp;quot;'&amp;quot;&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    SqlConnection connection  = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlConnection(connString);&lt;br /&gt;    SqlDataAdapter adapter = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlDataAdapter(strSQL, connection);&lt;br /&gt;    DataTable dtProducts = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataTable();&lt;br /&gt;&lt;br /&gt;    adapter.Fill(dtProducts);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; dtProducts.DefaultView;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Because SQL Server allows you to concatenate several SQL statements using a semicolon or space, I can append my own SQL statement to the query above by simply entering my statement in the &lt;em&gt;txtFilter&lt;/em&gt; textbox, as shown below:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;'; &lt;span style="color: #0000ff"&gt;UPDATE&lt;/span&gt; Products &lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; UnitPrice = 0.01 &lt;span style="color: #0000ff"&gt;WHERE&lt;/span&gt; ProductId = 1--&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Using the attack above, I can set the UnitPrice for the product with ProductID = 1 to $0.01, purchase a few units of the product without anyone finding out (not for a while anyway). There are many other vectors of attack here but this example is a simple demonstration of how devastating a SQL Injection attack can be.&lt;/p&gt;

&lt;p&gt;Luckily, with Team System 2010, you can prevent such attacks by using the Code Analysis security rules. In order to take advantage of this fetaure, the first step is to configure Code Analysis to check for SQL Injection vulnerabilities in your application. To do that, select the &amp;quot;Configure Code Analysis for &amp;lt;project&amp;gt;&amp;quot; command from the &lt;strong&gt;Analyze&lt;/strong&gt; menu, as shown here.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Configure Code Analysis" border="0" alt="Configure Code Analysis" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/PreventingSQLInjectionAttackswithVisualS_D4EA/image_9.png" width="894" height="657" /&gt;&lt;/p&gt;

&lt;p&gt;Once you've selected the Configure command, the Project Properties window opens with the &amp;quot;Code Analysis&amp;quot; tab selected. Using the Rule Set drop down, select the &lt;strong&gt;Microsoft Security Rules&lt;/strong&gt;. This will tell Visual Studio to run Code Analysis on your application, checking for security vulnerabilities. To see which vulnerabilities Code Analysis is checking for, click the [Open] button.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Microsoft Security Rules" border="0" alt="Microsoft Security Rules" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/PreventingSQLInjectionAttackswithVisualS_D4EA/image_6.png" width="896" height="656" /&gt;&lt;/p&gt;

&lt;p&gt;After clicking the [Open] button, the Rule Set editor is opened. Other than security vulnerabilities, you can configure Code Analysis to detect many other issues in your application such as performance, correctness, reliability, etc. In the Rule Set editor window, expand the &lt;em&gt;Microsoft.Security&lt;/em&gt; section and look for the rule where the ID is &lt;em&gt;CA2100&lt;/em&gt;. This is the rule that Code Analysis uses to detect potential SQL Injection attacks in your code. What's also nice is that when you select the rule, the lower pane of the window shows you additional help on the rule, including sample code and some guidance.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Code Analysis Rule Set editor" border="0" alt="Code Analysis Rule Set editor" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/PreventingSQLInjectionAttackswithVisualS_D4EA/image_3.png" width="800" height="631" /&gt; &lt;/p&gt;

&lt;p&gt;The next step, after configuring Code Analysis, is to run it. From the Analyze menu, select the &amp;quot;Run Code Analysis on &amp;lt;project&amp;gt;&amp;quot; command. This command will run all the rules that have been enabled for your application and report any issues in the Error List.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Run Code Analysis" border="0" alt="Run Code Analysis" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/PreventingSQLInjectionAttackswithVisualS_D4EA/image_12.png" width="895" height="660" /&gt; &lt;/p&gt;

&lt;p&gt;In the Error List, you can see that Code Analysis has detected the SQL Injection vulnerability in our code. Furthermore, you can double click the error to navigate to the section of your code which contains this vulnerability.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Error List showing SQL Injection attack" border="0" alt="Error List showing SQL Injection attack" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/PreventingSQLInjectionAttackswithVisualS_D4EA/image_15.png" width="844" height="196" /&gt; &lt;/p&gt;

&lt;p&gt;If you have any feedback on this feature, I would love to hear about it. In a future post, I will delve into how Code Analysis detects these types of vulnerabilities.&lt;/p&gt;

&lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9814114" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category></item><item><title>Walkthrough: Using the Tier Interaction Profiler in Visual Studio Team System 2010</title><link>http://blogs.msdn.com/habibh/archive/2009/06/30/walkthrough-using-the-tier-interaction-profiler-in-visual-studio-team-system-2010.aspx</link><pubDate>Wed, 01 Jul 2009 05:24:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9810251</guid><dc:creator>habibh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/habibh/comments/9810251.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=9810251</wfw:commentRss><description>&lt;p&gt;In Visual Studio Team System 2010, we've made a huge number of improvements to the Profiler. In case you didn't know that Visual Studio Team System has a Profiler, see the &lt;a href="http://msdn.microsoft.com/en-us/library/z9z62c29(VS.80).aspx"&gt;documentation&lt;/a&gt; on MSDN. One of the major improvements that we have made to the Profiler is the ability to measure how long the interaction between the application layer and the database layer takes.&lt;/p&gt;  &lt;p&gt;Let's say that you have a typical multi-tier application, made up of a presentation layer, an application server and a database at the backend. Let's further assume that you are seeing several reports form customers that some transactions are timing out or are taking too long to complete. How do you go about finding out the root cause of the problem?&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Distributed multi-tier application" border="0" alt="Distributed multi-tier application" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_3.png" width="641" height="169" /&gt; &lt;/p&gt;  &lt;p&gt;Before Visual Studio Team System 2010, you could use the Profiler to diagnose if the failure occurred in either the presentation or middle tier. However, if the performance bottleneck is between the middle tier and the database layer, you are out of luck. In this walkthrough, I'm going to demonstrate how to use the new &amp;quot;Tier Interaction&amp;quot; feature of the Profiler to diagnose failures between the application and data tier.&lt;/p&gt;  &lt;p&gt;For this demo, I'm going to use the BeerHouse sample application. To start, select the &amp;quot;Launch Performance Wizard...&amp;quot; from the Analyze menu as shown below.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Analyze menu" border="0" alt="Analyze menu" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_6.png" width="783" height="561" /&gt; &lt;/p&gt;  &lt;p&gt;Next, you should see the &amp;quot;Performance Wizard&amp;quot;. On this dialog, select the &amp;quot;CPU Sampling&amp;quot; option and click Next.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Perfomance Wizard." border="0" alt="Perfomance Wizard." src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_9.png" width="641" height="535" /&gt; &lt;/p&gt;  &lt;p&gt;You should now land on the second page of the Performance Wizard. If the solution that you are planning to profile is already open, the wizard will automatically select it for you. Click the Next button to continue.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Select application to profile" border="0" alt="Select application to profile" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_12.png" width="641" height="535" /&gt; &lt;/p&gt;  &lt;p&gt;The next step is important! On the last page of the wizard, the checkbox to &amp;quot;Launch profiling after the wizard finishes&amp;quot; is checked. Uncheck it and click the Finish button.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Performance Wizard last page" border="0" alt="Performance Wizard last page" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_18.png" width="641" height="535" /&gt; &lt;/p&gt;  &lt;p&gt;After clicking the Finish button, Visual Studio will open the &amp;quot;Performance Explorer&amp;quot; window and displays the target application to be profiled under the &amp;quot;Targets&amp;quot; node. Right-click the target (in this case TBH_Web) and select Properties, as shown below.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Target properties context menu" border="0" alt="Target properties context menu" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_21.png" width="725" height="521" /&gt; &lt;/p&gt;  &lt;p&gt;In the Properties dialog, select the &amp;quot;Tier Interactions&amp;quot; tab and check the &amp;quot;Enable tier interaction profiling&amp;quot; checkbox. Press the OK button to dismiss the dialog.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Target Property Pages" border="0" alt="Target Property Pages" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_37.png" width="678" height="430" /&gt; &lt;/p&gt;  &lt;p&gt;Next, click the &amp;quot;Launch with Profiling&amp;quot; toolbar button in the Performance Explorer window shown below to start the Profiler.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_26.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Start profiling" border="0" alt="Start profiling" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_thumb_8.png" width="209" height="270" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The application will now start. At this point, to reproduce the customer problem, walk through the scenario that the customer or tester reported. While you are going through your scenario, the Profiler is collecting performance data about the application. Once done, close the application. At this point, Visual Studio will display a summary of the performance data that was collected as you were using the application.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Profiler Summary page" border="0" alt="Profiler Summary page" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_29.png" width="900" height="655" /&gt; &lt;/p&gt;  &lt;p&gt;In order to see the interaction between the application and the database, select the &amp;quot;Interactions&amp;quot; view from the &amp;quot;Current View&amp;quot; drop down.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_32.png" width="899" height="655" /&gt; &lt;/p&gt;  &lt;p&gt;And finally, here is the Tier Interactions view. There is a ton of very useful information on this page, including:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Which ASP.NET pages were requested, how many times and how long did it take to execute each page&lt;/li&gt;    &lt;li&gt;For each ASP.NET request, which SQL Server stored procedures were called, how many times and how long did the calls take&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_34.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Profiler Interactions view" border="0" alt="Profiler Interactions view" src="http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WalkthroughUsingtheTierInteractionProfil_10254/image_thumb_11.png" width="900" height="655" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The Tier Interaction Profiler is available in Visual Studio Team System Beta 1 right now. Feel free to download it and give it a try. If you have any feedback, send it my way.&lt;/p&gt;  &lt;p&gt;Habib Heydarian.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9810251" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category><category domain="http://blogs.msdn.com/habibh/archive/tags/VSTS+Developing/default.aspx">VSTS Developing</category></item><item><title>What’s new in Visual Studio Team System 2010: Episode 2</title><link>http://blogs.msdn.com/habibh/archive/2008/10/01/what-s-new-in-visual-studio-team-system-2010-issue-2.aspx</link><pubDate>Wed, 01 Oct 2008 20:03:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8971904</guid><dc:creator>habibh</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/habibh/comments/8971904.aspx</comments><wfw:commentRss>http://blogs.msdn.com/habibh/commentrss.aspx?PostID=8971904</wfw:commentRss><description>&lt;h5&gt;Feature: Historical Debugger&lt;/h5&gt;  &lt;p&gt;In my previous post, I mentioned that one of the key scenarios that my team is working on is eliminating the &amp;quot;No Repro&amp;quot; scenario. Let’s take a look at what this actually means. Let’s say that you’re a developer and you are trying to reproduce a bug in your code. This is often a time consuming task and if you’re unlucky, you won’t even be able to reproduce the issue. At Microsoft, when a bug or issue is not reproducible, we mark it as &amp;quot;Not Repro&amp;quot;. Alas, a “No Repro” bug is both unproductive and frustrating.&lt;/p&gt;  &lt;p&gt;In Visual Studio Team System 2010, we’ve introduced a feature that for now we are calling the &lt;strong&gt;Historical Debugger&lt;/strong&gt; (this name will most likely change by the time we release the RTM version of VSTS 2010). The goal of this new feature is to significantly cut down the time it takes to debug an issue by recording what the application does and be able to replay the recording (or log) in Visual Studio. By recording what the application does as it is running, our goal is cut down the number of &amp;quot;No Repro&amp;quot; bugs.&lt;/p&gt;  &lt;p&gt;Here is a short demo of the Historical Debugger. The usual caveat applies: This is only an early glimpse of the functionality and we still have a lot of work left before the release.&lt;/p&gt;  &lt;p&gt;Habib Heydarian.&lt;/p&gt;  &lt;div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:3d3b8383-e38a-4e25-8f0f-beeba2a6ebab" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;div id="1c05b54b-832a-4343-a750-d89dfeb77603" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://video.msn.com/video.aspx?vid=343e7c82-c0fb-4b8c-bec7-1065c7d9d3b5&amp;amp;from=writer" target="_new"&gt;&lt;img src="https://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/WhatsnewinVisualStudioTeamSystem2010Issu_8D7C/videoe03225dae01a.jpg" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('1c05b54b-832a-4343-a750-d89dfeb77603'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;embed src=\&amp;quot;http://images.video.msn.com/flash/soapbox1_1.swf\&amp;quot; quality=\&amp;quot;high\&amp;quot; width=\&amp;quot;432\&amp;quot; height=\&amp;quot;364\&amp;quot; wmode=\&amp;quot;transparent\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; pluginspage=\&amp;quot;http://macromedia.com/go/getflashplayer\&amp;quot; flashvars=\&amp;quot;c=v&amp;amp;v=343e7c82-c0fb-4b8c-bec7-1065c7d9d3b5&amp;amp;from=writer&amp;amp;mkt=en-US\&amp;quot; &amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8971904" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/habibh/archive/tags/Team+System+2010/default.aspx">Team System 2010</category></item></channel></rss>