<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Visual Studio Tips</title>
        <link>http://geekswithblogs.net/dchestnutt/category/4049.aspx</link>
        <description>Visual Studio Tips</description>
        <language>en-US</language>
        <copyright>Dave Chestnutt</copyright>
        <managingEditor>hlzsfc102@sneakemail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>CodeGaffe: Copy &amp; Paste (and ReSharper to the rescue)</title>
            <link>http://geekswithblogs.net/dchestnutt/archive/2006/12/11/100867.aspx</link>
            <description>&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;I use a coding tool called ReSharper - and I was pleasantly surprised the other day when it pointed out a copy &amp;amp; paste bug that was waiting to explode.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You see, copy and paste programming is so very easy to do - that we all do it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Even the best of us accidentally leave in duplicate code snippets from time to time.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;Why Cut &amp;amp; Paste is so bad&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;There are two big reasons why this is an anti-pattern:&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.5in; DIRECTION: ltr; unicode-bidi: embed" type=1&gt;
&lt;LI style="MARGIN-TOP: 0px; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle; FONT-FAMILY: Verdana; mso-outline-level: 1" value=1&gt;If the code you cut and pasted has a bug in it (and it invariably will), what do you think are the chances that you'll find and fix all occurrences of it? 
&lt;LI style="MARGIN-TOP: 0px; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle; FONT-FAMILY: Verdana; mso-outline-level: 1" value=2&gt;If you're rubber-stamping code (copy and paste, paste, paste…) so that you can make minor edits to the pasted version, it's too easy to make a mistake - and the code will compile fine.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It won't fall over until a customer runs it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Rubber-stamping typically happens in a switch statement or a batch or if/else-if statements (where the cases are nearly identical).&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;It's this second case that ReSharper showed me a bug that wouldn't have been found until run-time.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It surprised me because ReSharper doesn't look for duplicate code snippets.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But one of its rules can get triggered if you copy &amp;amp; paste code incorrectly.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;ReSharper is...&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;This is an add-in to Visual Studio.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It does many things, but one thing it does well is point out flaws in your C# code via highlighting - so you can quickly see suspicious or questionable practices.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;There are other tools that do the same for C#, and there are similar tools for Java. &lt;SPAN style="FONT-STYLE: italic"&gt;[Disclaimer: I do not work for JetBrains. I paid for my own copy out of my own pocket. I'm just a happy user.]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;This is not a tutorial on using ReSharper - I'm just showing one tiny example of how it can help you.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Here is some legacy code opened in Visual Studio with ReSharper:&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in; mso-outline-level: 1"&gt;&lt;IMG title="ReSharper Example on Legacy Code" src="http://static.flickr.com/136/319646018_564ffc8d19.jpg?v=0" border=0&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;Notice the highlights on the right of the source window.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Those give an indication of where there might be problems in the source.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You can click those lines and it will jump to the place in the code with the problem.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It highlights the error and offers fixes, too.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The orange lines are approximately lined up with where the scroll bar would be when you view the code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Orange means warning, and red means error.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Opening up legacy code often shows many many orange lines because ReSharper warns about suspicious or bad practices.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;These are things that the compiler is happy with, but you'll be unhappy about in the long run.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;Here's what ReSharper found&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;So, back to how I was pleasantly surprised.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Look at this code example.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It's pretty obvious at first glance that this code was rubber-stamped to handle many cases - with slight edits in each version.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;This code will compile, but it won't work right.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Here's what it looks like in normal Visual Studio:&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in; mso-outline-level: 1"&gt;&lt;IMG title=blah src="http://static.flickr.com/140/319646020_5f56459b17.jpg?v=0&gt;&lt;/P&gt;&lt;P style=" FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1?&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; mso-outline-level: 1"&gt;&lt;SPAN style="FONT-FAMILY: Verdana"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; mso-outline-level: 1"&gt;&lt;SPAN style="FONT-FAMILY: Verdana"&gt;Do you see the problem?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It's in line 41.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When copying and pasting, the person forgot to modify the &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Lucida Console'"&gt;if &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Verdana"&gt;statement to use htmlButtonMatch instead of htmlTextboxMatch.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It's clearly wrong, but it might not show up as a bug until months after someone wrote this.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;Look at what ReSharper shows (it does additional highlighting of things like method names, etc.):&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in; mso-outline-level: 1"&gt;&lt;IMG title=blah src="http://static.flickr.com/129/319646021_8dedd5c3ee.jpg?v=0&gt;&lt;/P&gt;&lt;P style=" FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1?&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;With this cool tool, I'm immediately alerted to the problem.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;The tool tip for the grayed out variable warns me that it wasn't used.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;From that, I can easily spot the error in line 41.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The important thing is that ReSharper alerted me that there was a problem.&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P style="MARGIN: 0in; mso-outline-level: 1"&gt;&lt;IMG title=blah src="http://static.flickr.com/131/319646022_9546887e59.jpg?v=0&gt;&lt;/P&gt;&lt;P style=" FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1?&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;This was some actual legacy code that I opened up one day - when I noticed the problem.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I was&amp;nbsp;fix it and find out why unit tests didn't cover this case.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;You know, if I didn't tell people I used ReSharper, they'd think I was really smart.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;But I am smart enough to use good tools.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;See also: &lt;A href="http://en.wikipedia.org/wiki/Copy_and_paste_programming"&gt;http://en.wikipedia.org/wiki/Copy_and_paste_programming&lt;/A&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;EM&gt;&lt;FONT size=1&gt;Technorati tags: &lt;A href="http://technorati.com/tag/Visual%20Studio" rel=tag&gt;Visual Studio&lt;/A&gt;, &lt;A href="http://technorati.com/tag/CodeGaffes" rel=tag&gt;CodeGaffes&lt;/A&gt;, &lt;A href="http://technorati.com/tag/Geekswithblogs" rel=tag&gt;Geekswithblogs&lt;/FONT&gt;&lt;/EM&gt;&lt;/A&gt;&lt;/DIV&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=100867"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=100867" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dchestnutt/aggbug/100867.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dave Chestnutt</dc:creator>
            <guid>http://geekswithblogs.net/dchestnutt/archive/2006/12/11/100867.aspx</guid>
            <pubDate>Mon, 11 Dec 2006 18:22:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dchestnutt/comments/100867.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dchestnutt/archive/2006/12/11/100867.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dchestnutt/comments/commentRss/100867.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dchestnutt/services/trackbacks/100867.aspx</trackback:ping>
        </item>
        <item>
            <title>Gotcha! Visual Studio Pre/Post-Build Events</title>
            <link>http://geekswithblogs.net/dchestnutt/archive/2006/05/30/80113.aspx</link>
            <description>&lt;P&gt;Visual Studio has a nifty feature called Pre-Build and Post-Build events. These are used to include extra DOS commands before or after the build.&lt;/P&gt;
&lt;P&gt;But there's a gotcha! And it will bite you when you least expect it. In Visual Studio, there is NO ERROR CHECKING except at the end of an event. Any errors that happen prior to the final step are lost. Keep reading to see a workaround. 
&lt;H2&gt;Setting Build Events&lt;/H2&gt;
&lt;P&gt;Build Events are accessed by right-clicking on a Project in the solution explorer and choosing "Build Events": 
&lt;BLOCKQUOTE&gt;&lt;IMG title="Property Window for a project" src="http://static.flickr.com/73/156561127_8e7f825b97.jpg?v=0?v=0" border=0&gt; &lt;/BLOCKQUOTE&gt;
&lt;P&gt;It looks like these were originally intended as one-line DOS commands to do tweaks in your build. But they obviously grew - and you can put any number of DOS commands in there to copy files, clean up directories, even run unit tests! 
&lt;P&gt;Before describing the gotcha, there are a few things you need to know if you've never used these before. One is that you can put any DOS commands in here. It's really nothing more than a place to save a batch file that's run before (or after) the project build. It also offers "macros". The build process actually creates a batch file from your commands by replacing the macro text. &lt;/P&gt;&lt;!--EndFragment--&gt;
&lt;P&gt;In this example, MYDEPLOY is just a regular DOS environment variable. The advantage to macros is they take into account the various differences between developers (and their file directory structure) as well as handling Debug vs. Release builds.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;IMG title="This is where you type your pre or post build event, using macros" src="http://static.flickr.com/75/156561128_7760a09ea8.jpg?v=0?v=0" border=0&gt; &lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;For example, this command: &lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5pt; FONT-SIZE: 10pt; BACKGROUND: #f0f0f0; PADDING-BOTTOM: 5pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 5pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;Copy $(OutDir)*.* %MYDEPLOY%&lt;/DIV&gt;&lt;!--EndFragment--&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Gets converted to this, and placed in a batch file: &lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5pt; FONT-SIZE: 10pt; BACKGROUND: #f0f0f0; PADDING-BOTTOM: 5pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 5pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;Copy bin\Debug\*.* %MYDEPLOY%&lt;/DIV&gt;
&lt;P&gt;
&lt;H2&gt;The Gotcha&lt;/H2&gt;
&lt;P&gt;So, what's the problem? 
&lt;P&gt;Well, VS puts these commands in a batch file and runs it. VS checks for build failures so it can tell you about them. However - it only checks for a failure of the batch file that it created - not for any failures within the batch file. 
&lt;P&gt;What does this mean? If you only place one command in the build event, VS will correctly report any errors that happen. But if you place multiple commands in here, the net effect is that VS will only detect an error in the last statement. 
&lt;P&gt;So, for example, if you put &lt;EM&gt;three&lt;/EM&gt; copy commands in here, VS will only report an error if the &lt;EM&gt;final&lt;/EM&gt; command fails. 
&lt;P&gt;Ouch. 
&lt;H2&gt;The Workaround&lt;/H2&gt;
&lt;P&gt;So how can we fix this? Since VS is just creating a batch file, we use normal batch file commands to detect errors and report them. Here's what I do: 
&lt;UL&gt;
&lt;LI&gt;I add a check for error after every meaningful step: &lt;/LI&gt;&lt;/UL&gt;
&lt;BLOCKQUOTE style="MARGIN-RIGHT: 0px"&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5pt; FONT-SIZE: 10pt; BACKGROUND: #f0f0f0; PADDING-BOTTOM: 5pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 5pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;if errorlevel 1 goto BuildEventFailed&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;!--EndFragment--&gt;
&lt;UL&gt;
&lt;LI&gt;I add code at the end to handle the error so VS will report it:&lt;/LI&gt;&lt;/UL&gt;
&lt;BLOCKQUOTE style="MARGIN-RIGHT: 0px"&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5pt; FONT-SIZE: 10pt; BACKGROUND: #f0f0f0; PADDING-BOTTOM: 5pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 5pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;REM Exit properly because the build will not fail&lt;PRE style="MARGIN: 0px"&gt;REM unless the final step exits with an error code&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;goto BuildEventOK&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;:BuildEventFailed&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;echo POSTBUILDSTEP for $(ProjectName) FAILED&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;exit 1&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;:BuildEventOK&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;echo POSTBUILDSTEP for $(ProjectName) COMPLETED OK&lt;/PRE&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;!--EndFragment--&gt;
&lt;P&gt;
&lt;P&gt;&lt;BR&gt;Here's an example of one of my actual post build events: &lt;BR&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5pt; FONT-SIZE: 10pt; BACKGROUND: #f0f0f0; PADDING-BOTTOM: 5pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 5pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;echo POSTBUILDSTEP for $(ProjectName)&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt; &lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;xcopy "$(TargetPath)" "$(SolutionDir)$(OutDir)" /i /d /y&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;if errorlevel 1 goto BuildEventFailed&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;xcopy "$(TargetDir)$(TargetName).pdb" "$(SolutionDir)$(OutDir)" /i /d /y&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;if errorlevel 1 goto BuildEventFailed&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt; &lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;echo GAC of: "$(SolutionDir)$(OutDir)$(TargetFileName)"&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;gacutil.exe /nologo /i "$(SolutionDir)$(OutDir)$(TargetFileName)" /f&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;if errorlevel 1 goto BuildEventFailed&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt; &lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;REM Exit properly because the build will not fail &lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;REM unless the final step exits with an error code&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;goto BuildEventOK&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;:BuildEventFailed&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;echo POSTBUILDSTEP for $(ProjectName) FAILED&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;exit 1&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;:BuildEventOK&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;echo POSTBUILDSTEP for $(ProjectName) COMPLETED OK&lt;/PRE&gt;&lt;/DIV&gt;&lt;!--EndFragment--&gt;
&lt;P&gt;You don't have to be as fancy, with the extra "echo" statements, but do the error checking you need so errors don't slip through the cracks. 
&lt;P&gt;One final note: don’t put too much in these events. They’re pretty hard to debug when things go wrong. If you have something complex to do, put the commands in a batch file and reference the batch file yourself in the event. 
&lt;P&gt;But now at least, you can get notified if (make that &lt;U&gt;when&lt;/U&gt;) something fails. &lt;/P&gt;
&lt;P&gt; Technorati tags: 
&lt;a href="http://technorati.com/tag/Visual%20Studio" rel="tag"&gt;Visual Studio&lt;/a&gt;,
&lt;a href="http://technorati.com/tag/CodeGaffes" rel="tag"&gt;CodeGaffes&lt;/a&gt;, 
&lt;a href="http://technorati.com/tag/Geekswithblogs" rel="tag"&gt;Geekswithblogs&lt;/a&gt;
&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=80113"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=80113" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dchestnutt/aggbug/80113.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dave Chestnutt</dc:creator>
            <guid>http://geekswithblogs.net/dchestnutt/archive/2006/05/30/80113.aspx</guid>
            <pubDate>Tue, 30 May 2006 16:23:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dchestnutt/comments/80113.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dchestnutt/archive/2006/05/30/80113.aspx#feedback</comments>
            <slash:comments>37</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dchestnutt/comments/commentRss/80113.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dchestnutt/services/trackbacks/80113.aspx</trackback:ping>
        </item>
        <item>
            <title>CodeGaffe: Avoid .NET “partial” classes in C# and VB</title>
            <link>http://geekswithblogs.net/dchestnutt/archive/2006/04/05/74442.aspx</link>
            <description>&lt;P&gt;Microsoft added a new keyword to C# and VB for 2005 (CLR 2.0): &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Don't use it.&lt;/EM&gt;&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt; is used to physically break up a class definition into multiple files. When the compiler sees the keyword &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt; it finds all the related partial files in order to compile the class. This makes it possible to split the code for a single class across multiple files. By and large, though, this is a bad idea. Let’s look at why that is. 
&lt;P&gt;&lt;SPAN class=pullquote style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-WEIGHT: normal; FONT-SIZE: 16pt; FLOAT: right; PADDING-BOTTOM: 5px; MARGIN: 20px; WIDTH: 207px; LINE-HEIGHT: normal; PADDING-TOP: 5px; FONT-STYLE: normal; HEIGHT: 133px; TEXT-ALIGN: right"&gt;
&lt;P align=left&gt;&lt;FONT face=Papyrus&gt;If you find &lt;BR&gt;yourself typing&lt;BR&gt;"p-a-r-t-i-a-l" &lt;BR&gt;&lt;/FONT&gt;&lt;FONT face=Papyrus&gt;Stop!&lt;/FONT&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;FONT face="Arial Black"&gt;Reasons Given To Use the “partial” keyword&lt;/FONT&gt; 
&lt;P&gt;There are three main incentives I’ve heard for using &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt;, according to Microsoft and others: 
&lt;OL&gt;
&lt;LI&gt;If a class is really large, break it into multiple files so more than one person can work on it at a time. 
&lt;LI&gt;If a class implements multiple interfaces, put the methods that implement each interface into a separate file. 
&lt;LI&gt;When the IDE generates code, it puts the code into a separate file so you don't see it or accidentally modify it.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Let's examine each of these reasons in detail. 
&lt;P&gt;&lt;FONT face="Arial Black"&gt;1. Avoid using “partial” to break large files into many smaller files&lt;/FONT&gt;—so multiple people can work on them. This is a bad practice.&lt;/P&gt;
&lt;P&gt;Why? 
&lt;P&gt;No matter how you try to group code in various partial files, &lt;STRONG&gt;&lt;EM&gt;you will never see the big picture for the class anymore&lt;/EM&gt;&lt;/STRONG&gt;. It’ll become brittle, easily broken. By only viewing a portion of the class, you can too easily break some assumption or dependency in the rest of the class. For example, you won’t see all the internal fields. If a field needs updating, and it’s not referenced in the portion of the class you’re editing, you’ll never even realize that you are breaking the class. &lt;EM&gt;&lt;/EM&gt;People will make incompatible changes and no one will know until Humpty Dumpty is put back together again. Are your unit tests good enough to catch this?&lt;/P&gt;
&lt;P&gt;So what's the right solution for really large files?&lt;/P&gt;
&lt;P&gt;If you’re thinking of using &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;partial&lt;/STRONG&gt;&lt;/FONT&gt; because your class file is large, then consider it a warning sign that it's time to break the class up—not by using &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt; but by using object oriented design. Break your monster class into multiple classes, grouped by responsibility. That way, you can hide details inside classes, and it will be much harder for developers who work on the new smaller classes to make incompatible changes with each other. As a bonus, breaking it up will also make your code easier to read, test, and maintain. &lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial Black"&gt;2.&lt;FONT face="Arial Black"&gt;&lt;/FONT&gt; Avoid using “partial” to organize your class file.&lt;/FONT&gt; Some people suggest putting the implementations of each interface into their own files. This sounds reasonable at first, but it contains a pitfall—the class implements 2 or more interfaces, but it is still one class that has its own private data (and all the assumptions that go with that). If you only read code in one file and make changes, you may not realize the side effects you introduce on other methods that are in other partial files. This is a bad practice for the same reason that it was for reason #1, large class files.&lt;/P&gt;
&lt;P&gt;
&lt;P&gt;&lt;FONT face="Arial Black"&gt;3. “partial” is ok if the compiler puts it there. &lt;/FONT&gt;This is the only safe reason to use &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt;. When the compiler adds &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt; to your class, it does so to hide the code that it generates. While there are other solutions to handling generated code, this is the one that Microsoft chose, and it works fine. You can't ever modify the generated code (well, not easily) so it's just as well that it's hidden in a separate file. Note the key phrase here: the &lt;EM&gt;&lt;STRONG&gt;compiler&lt;/STRONG&gt;&lt;/EM&gt; adds partial—not you. 
&lt;BLOCKQUOTE&gt;&lt;IMG title="Visual Studio generates partial for you" src="http://static.flickr.com/43/123941420_caa05a9621.jpg?v=0" border=0&gt; &lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Arial Black"&gt;Recommendations&lt;/FONT&gt; 
&lt;UL&gt;
&lt;LI&gt;If you find yourself typing "p-a-r-t-i-a-l" — stop! Don’t do it. 
&lt;LI&gt;If the class you’re working on is marked &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt;, make sure that the other partial bits are compiler-generated. If they’re not, you should consider putting the class files back together and re-factoring the large class into smaller classes.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;One final Note&lt;/STRONG&gt;: in VB, since the &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt; keyword is optional, you can really confuse someone reading the code because they may not even realize that other code exists for this class. If you work in VB, be aware that your entire class may not be in the file you’re looking at.&lt;/P&gt;
&lt;P&gt;For another viewpoint, see these articles: 
&lt;UL&gt;
&lt;LI&gt;This is a well written article describing &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt; classes: &lt;A href="http://www.devx.com/dotnet/Article/22603"&gt;http://www.devx.com/dotnet/Article/22603&lt;/A&gt; 
&lt;LI&gt;Microsoft’s article on &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;partial&lt;/FONT&gt;&lt;/STRONG&gt; (and other things): &lt;A href="http://msdn.microsoft.com/msdnmag/issues/06/00/C20/default.aspx"&gt;http://msdn.microsoft.com/msdnmag/issues/06/00/C20/default.aspx&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;DIV&gt;Technorati tags: 
&lt;a href="http://technorati.com/tag/C%2523" rel="tag"&gt;C#&lt;/a&gt;,
&lt;a href="http://technorati.com/tag/Visual%20Basic" rel="tag"&gt;Visual Basic&lt;/a&gt;,
&lt;A href="http://technorati.com/tag/Visual%20Studio" rel=tag&gt;Visual Studio&lt;/A&gt;, &lt;A href="http://technorati.com/tag/CodeGaffes" rel=tag&gt;CodeGaffes&lt;/A&gt;, &lt;A href="http://technorati.com/tag/Geekswithblogs" rel=tag&gt;Geekswithblogs&lt;/A&gt; &lt;/DIV&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=74442"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=74442" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dchestnutt/aggbug/74442.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dave Chestnutt</dc:creator>
            <guid>http://geekswithblogs.net/dchestnutt/archive/2006/04/05/74442.aspx</guid>
            <pubDate>Wed, 05 Apr 2006 23:34:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dchestnutt/comments/74442.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dchestnutt/archive/2006/04/05/74442.aspx#feedback</comments>
            <slash:comments>13</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dchestnutt/comments/commentRss/74442.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dchestnutt/services/trackbacks/74442.aspx</trackback:ping>
        </item>
        <item>
            <title>NUnit - support both .NET 1.1 and 2.0 at the same time</title>
            <link>http://geekswithblogs.net/dchestnutt/archive/2006/03/07/71661.aspx</link>
            <description>&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-STYLE: italic; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;How to easily run NUnit tests in both .NET 1.1 and 2.0 environments.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;I want to run my NUnit tests! But I have a problem -- my code runs under both .NET 1.1 and 2.0 frameworks.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It is real easy to run tests from the IDE, which I do, but that means I'm only running the tests under one version of .NET.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;How can I &lt;SPAN style="FONT-WEIGHT: bold; FONT-STYLE: italic"&gt;easily &lt;/SPAN&gt;run tests under &lt;SPAN style="FONT-WEIGHT: bold; FONT-STYLE: italic"&gt;both &lt;/SPAN&gt;.NET frameworks?&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;I'm lazy, so it has to be easy.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So, without even resorting to the command line, here's how I do it in 3 steps:&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV dir=ltr style="MARGIN-TOP: 0px; FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;1. Running tests with the .NET 1.1 Framework&lt;/DIV&gt;
&lt;P dir=ltr style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;I use Visual Studio 2003, and the TestDriven.NET Add-in (&lt;A href="http://www.testdriven.net/"&gt;http://www.testdriven.net/&lt;/A&gt;).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I right-click on tests, projects, or the whole solution - and run my tests under .NET 1.1.&lt;/P&gt;
&lt;P dir=ltr style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV dir=ltr style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;STRONG&gt;2. Running tests with the .NET 2.0 Framework&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;P dir=ltr style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;I use the NUnit GUI app to run tests under the .NET 2.0 environment.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;To make the NUnit GUI run with .NET 2.0 framework - I modified the &lt;SPAN style="FONT-WEIGHT: bold"&gt;nunit-gui.exe.config&lt;/SPAN&gt; file so its startup section has the 2.0 runtime first:&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5pt; FONT-SIZE: 10pt; BACKGROUND: #f0f0f0; PADDING-BOTTOM: 5pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 5pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;SPAN style="COLOR: blue"&gt;startup&lt;/SPAN&gt;&amp;gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp; &lt;FONT color=#006400&gt;&lt;EM&gt;&amp;lt;!-- NUnit will run under the first version it finds --&amp;gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp; &lt;FONT color=#0000ff&gt;&amp;lt;SUPPORTEDRUNTIME &lt;FONT&gt;version&lt;/FONT&gt;="v2.0.50727"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;SUPPORTEDRUNTIME &lt;FONT&gt;version&lt;/FONT&gt;="v1.1.4322" /&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;SUPPORTEDRUNTIME  &lt;FONT&gt;version&lt;/FONT&gt;="v1.0.3705" /&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;REQUIREDRUNTIME  &lt;FONT&gt;version&lt;/FONT&gt;="v1.0.3705" /&amp;gt;&lt;BR&gt;&amp;lt;&lt;SPAN style="COLOR: blue"&gt;/startup&lt;/SPAN&gt;&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;!--EndFragment--&gt;
&lt;P style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P dir=ltr style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;I place a shortcut to the NUnit GUI on my Quick Launch toolbar, and I'm all set.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;While it's still true that I run the tests in the IDE the most, I can easily start the NUnit GUI and fire off my tests under .NET 2.0.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And since it's easy, I do it.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV style="MARGIN-TOP: 0px; FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;3. Making a test conditional based on .NET framework version&lt;/DIV&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;Some of my tests only make sense under .NET 2.0, and some under 1.1.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;[They all compile under 1.1 because we support both.]&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So how do I make a few tests conditional?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This requires two things: How to detect the version of the framework in use, and how to stop NUnit from running tests that are inappropriate for the framework in use.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;I've seen a bunch of ways to detect what framework version we're actually running under.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is my favorite because it's so simple and clear:&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5pt; FONT-SIZE: 10pt; BACKGROUND: #f0f0f0; PADDING-BOTTOM: 5pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 5pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; IsUsingDotNet11()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; (Environment.Version.Major == 1)&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp; (Environment.Version.Minor == 1);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; IsUsingDotNet20()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; (Environment.Version.Major == 2)&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp; (Environment.Version.Minor == 0);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;&lt;!--EndFragment--&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;As far as NUnit goes, we let it run all the tests, because we add checks inside the tests to stop them if they require the "other" version of the framework.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;By using NUnit's &lt;SPAN style="FONT-WEIGHT: bold"&gt;Assert.Ignore()&lt;/SPAN&gt; method, we can give a nice message, as well as gracefully stop the test in its tracks.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5pt; FONT-SIZE: 10pt; BACKGROUND: #f0f0f0; PADDING-BOTTOM: 5pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 5pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;[Test]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; TestSomethingOnDotNet11Only()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (! IsUsingDotNet11())&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;Assert.Ignore&lt;/STRONG&gt;("This test is for .NET 1.1 only");&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// &amp;#8230; Rest of test code ...&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;&lt;!--EndFragment--&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;There you have it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You can adapt this technique to suit your needs.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For example, if you run your tests from a batch file, you can modify &lt;SPAN style="FONT-WEIGHT: bold"&gt;nunit-console.exe.config&lt;/SPAN&gt; to make the console run under any version of the Framework that's installed on the machine.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;The reality is that many of us have to support more than one version of the DotNET framework.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Until such support is built into Visual Studio, we'll have to resort to methods like this to test in the real world.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Hopefully this short cut will make it easy.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;So you can be lazy like me.&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=71661"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=71661" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dchestnutt/aggbug/71661.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dave Chestnutt</dc:creator>
            <guid>http://geekswithblogs.net/dchestnutt/archive/2006/03/07/71661.aspx</guid>
            <pubDate>Tue, 07 Mar 2006 23:44:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dchestnutt/comments/71661.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dchestnutt/archive/2006/03/07/71661.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/dchestnutt/comments/commentRss/71661.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dchestnutt/services/trackbacks/71661.aspx</trackback:ping>
        </item>
        <item>
            <title>Visual Studio and Perforce: Suppress the Open Connection dialog</title>
            <link>http://geekswithblogs.net/dchestnutt/archive/2006/02/28/70977.aspx</link>
            <description>&lt;DIV&gt;We've used Perforce source control for a number of years.&amp;nbsp; It's a great tool and it integrates with Visual Studio pretty well.&amp;nbsp; But its Visual Studio integration has one really annoying feature, that fortunately,&amp;nbsp;you can work around.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;The feature is this: If your solution has 10 projects in it, you can put each of those 10 projects in a separate Perforce Depot.&amp;nbsp; Is that useful?&amp;nbsp; I'll leave that to you.&amp;nbsp; Suffice it to say that we put all our source in one Depot.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;The problem comes when you reload a solution.&amp;nbsp; Perforce, by default, wants to prompt you for login information - &lt;STRONG&gt;&lt;EM&gt;&lt;FONT color=#000080&gt;for&amp;nbsp;each project in the solution&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;.&amp;nbsp; We have some solutions with 20-30 projects, so this gets pretty annoying.&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;This is the Perforce "Open Connection" screen that pops up over and over again:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG title="The dreaded dialog" src="http://static.flickr.com/40/105982186_5dc7338961.jpg?v=0" border=0&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR&gt;Fortunately, you can suppress this dialog (assuming that you only use one Depot!)&amp;nbsp; The option is pretty well hidden, but here's how you get to it.&amp;nbsp; Open Visual Studio, and before you open your solution file, go to &lt;STRONG&gt;Tools - Options&lt;/STRONG&gt;.&amp;nbsp; Select &lt;STRONG&gt;SCC provider&lt;/STRONG&gt; on the left, and click the &lt;STRONG&gt;Advanced&lt;/STRONG&gt; button:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG title="Tools Options dialog" src="http://static.flickr.com/47/105982187_482854dd92.jpg?v=0" border=0&gt; &amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;This brings up the well-hidden Perforce dialog.&amp;nbsp; Switch to the Connection tab and click the option called: "Bind to the workspace that matches your Perforce environment settings"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG title="Well Hidden Perforce Settings" src="http://static.flickr.com/50/105982188_b911334004.jpg?v=0" border=0&gt; &amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR&gt;Presto!&amp;nbsp; Press Ok to save your settings, and the Perforce "Open Connection" screen is banished, never to annoy you again.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;This makes the Perforce integration fairly practical in Visual Studio.&amp;nbsp; It's not perfect, but it automatically checks out&amp;nbsp;files for you (as you try to change them).&amp;nbsp; And that's extremely useful.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;It just makes my day...&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=70977"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=70977" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dchestnutt/aggbug/70977.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dave Chestnutt</dc:creator>
            <guid>http://geekswithblogs.net/dchestnutt/archive/2006/02/28/70977.aspx</guid>
            <pubDate>Tue, 28 Feb 2006 20:14:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dchestnutt/comments/70977.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dchestnutt/archive/2006/02/28/70977.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dchestnutt/comments/commentRss/70977.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dchestnutt/services/trackbacks/70977.aspx</trackback:ping>
        </item>
        <item>
            <title>Visual Studio: Macro to automatically collapse the projects in the Solution Explorer </title>
            <link>http://geekswithblogs.net/dchestnutt/archive/2006/02/21/70290.aspx</link>
            <description>&lt;DIV&gt;One of the pains of working with Visual Studio is that the Solution Explorer, in a large project, is hard to use.&amp;nbsp; As you open more and more files, it gets harder to navigate in the solution explorer since it opens all the projects for you.&amp;nbsp; &lt;/DIV&gt;
&lt;DIV&gt;Edwin Evans wrote a nice short macro to collapse all the projects.&amp;nbsp;&amp;nbsp;It works with both 2003 and 2005.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;A href="http://www.codeproject.com/macro/collapseall.asp?df=100&amp;amp;forumid=7565&amp;amp;exp=0&amp;amp;select=396167"&gt;http://www.codeproject.com/macro/collapseall.asp?df=100&amp;amp;forumid=7565&amp;amp;exp=0&amp;amp;select=396167&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Assign it to a button your toolbar and give it the smiley face icon.&amp;nbsp; 'Cuz that's what you'll do when you use it.&lt;/DIV&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=70290"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=70290" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dchestnutt/aggbug/70290.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dave Chestnutt</dc:creator>
            <guid>http://geekswithblogs.net/dchestnutt/archive/2006/02/21/70290.aspx</guid>
            <pubDate>Tue, 21 Feb 2006 21:02:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dchestnutt/comments/70290.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dchestnutt/archive/2006/02/21/70290.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dchestnutt/comments/commentRss/70290.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dchestnutt/services/trackbacks/70290.aspx</trackback:ping>
        </item>
        <item>
            <title>SparklingCode: Count the cost with Line Numbers</title>
            <link>http://geekswithblogs.net/dchestnutt/archive/2006/01/30/67659.aspx</link>
            <description>&lt;DIV&gt;One of the benefits of using modern editors is that it's really easy to navigate your code base. If you're looking at a method call, for example, you can use a keystroke combination to jump to the method definition. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;But there's a drawback to this. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;If you're not careful, as you add new code you can end up with monster methods, or monster-sized classes. Let me ask you this - what do you think the maximum size of a class should be? 100 lines? 500 lines? 10,000 lines? While we won't agree on an exact number, we can all agree that a class with 10,000 lines in it is much more likely to have bugs in it than one with 100 lines. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;But no one sets out to write such a huge class. How does it get this way? Simple - over time, various people make little modifications to a class. How many times have you looked at a modification and thought to yourself, "Perfect, I'll just add these lines of code here, and it'll support the new feature." After enough people do that, your 500 line class grows and grows. And grows! &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Here's a fairly innocuous bit of code. If I had just added this, without line numbers being displayed, I might not realize how big the class already is. But, as the screen shot on the right shows, I might be more inclined to realize that I shouldn't grow this class any further since it already has nearly 20,000 lines of code in it! &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;TABLE border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH vAlign=top align=left width="50%"&gt;No Line Numbers&lt;/TH&gt;
&lt;TH vAlign=top align=left width="50%"&gt;Line Numbers show a problem!&lt;/TH&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top&gt;&amp;nbsp;&lt;IMG title="Code snippet without line numbers" src="http://static.flickr.com/33/93377523_8d711f7d70.jpg?v=0" border=0&gt;&amp;nbsp; &lt;/TD&gt;
&lt;TD vAlign=top&gt;&amp;nbsp;&lt;IMG title="Code snippet with line numbers" src="http://static.flickr.com/42/93377526_cc384d99f5.jpg?v=0" border=0&gt;&amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Thus, my advice: turn on line number display in your editor. In Visual Studio, turn on Line Numbers by going to &lt;B&gt;Tools | Options | Text Editor&lt;/B&gt; and check &lt;U&gt;&lt;B&gt;Line Numbers&lt;/B&gt;&lt;/U&gt; &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;IMG title="Turn on Line Number Display in Visual Studio" src="http://static.flickr.com/14/93377527_63d3a3e801.jpg?v=0" border=0&gt; &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Now, when you're fixing bugs or adding features, you'll see line numbers. And when you get near the bottom of a file, you'll have another reminder that the class is growing out of control. Then you can plan some refactoring to break up the monster method or class. And improve your code base. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Turn on line numbers in your editor. They're an early warning system. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
Technorati tags: 
&lt;a href="http://technorati.com/tag/CodeGaffes" rel="tag"&gt;CodeGaffes&lt;/a&gt;, 
&lt;a href="http://technorati.com/tag/Geekswithblogs" rel="tag"&gt;Geekswithblogs&lt;/a&gt;
&lt;/DIV&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=67659"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=67659" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dchestnutt/aggbug/67659.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dave Chestnutt</dc:creator>
            <guid>http://geekswithblogs.net/dchestnutt/archive/2006/01/30/67659.aspx</guid>
            <pubDate>Tue, 31 Jan 2006 00:46:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dchestnutt/comments/67659.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dchestnutt/archive/2006/01/30/67659.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dchestnutt/comments/commentRss/67659.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dchestnutt/services/trackbacks/67659.aspx</trackback:ping>
        </item>
    </channel>
</rss>