<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.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>Peter Ritchie's MVP Blog : Visual Studio 2008</title><link>http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx</link><description>Tags: Visual Studio 2008</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>DevTeach 2009 Vancouver</title><link>http://msmvps.com/blogs/peterritchie/archive/2009/03/26/devteach-2009-vancouver.aspx</link><pubDate>Thu, 26 Mar 2009 16:33:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1681658</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1681658</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2009/03/26/devteach-2009-vancouver.aspx#comments</comments><description>&lt;p&gt;The schedule for DevTeach 2009 Vancouver has been announced (&lt;a href="http://www.devteach.com/" title="http://www.devteach.com/"&gt;http://www.devteach.com/&lt;/a&gt;).&amp;nbsp; There&amp;rsquo;s lots of great software development sessions from some of the leaders in our industry.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re planning on improving yourself, this is the conference to go to.&amp;nbsp; Not only can you attend excellent sessions; but you can hob-knob with the presenters and pick their brains.&lt;/p&gt;
&lt;p&gt;If you have a friend or co-worker who&amp;rsquo;s interested, there&amp;rsquo;s a limited-time two-for-one offer for an even better price: &lt;a href="http://www.devteach.com/Register.aspx" title="http://www.devteach.com/Register.aspx"&gt;http://www.devteach.com/Register.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2009%2f03%2f26%2fdevteach-2009-vancouver.aspx"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2009%2f03%2f26%2fdevteach-2009-vancouver.aspx" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1681658" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Design_2F00_Coding+Guidance/default.aspx">Design/Coding Guidance</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+3.x/default.aspx">.NET 3.x</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_+3.0/default.aspx">C# 3.0</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/DevTeach/default.aspx">DevTeach</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/DDD/default.aspx">DDD</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development+Practices/default.aspx">Software Development Practices</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development+Guidance/default.aspx">Software Development Guidance</category></item><item><title>Unable To Step Into .NET Source</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/11/24/unable-to-step-into-net-source.aspx</link><pubDate>Mon, 24 Nov 2008 20:59:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1653924</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1653924</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/11/24/unable-to-step-into-net-source.aspx#comments</comments><description>&lt;p&gt;I began getting a problem a while ago that I was unable to step into the .NET source in Visual Studio 2008.&amp;nbsp; It happened suddenly, and I noticed it shortly after installing SP1.&amp;nbsp; Given my observation it appears to be due to upgrading the SP1; but I couldn&amp;rsquo;t find anyone else not having the same problem.&amp;nbsp; I had another computer where it worked, so I basically put it aside.&lt;/p&gt;
&lt;p&gt;Today I had a chance to have a closer look.&amp;nbsp; I had configured 2008 (RTM, not SP1) to get the .NET source based on Shawn Burke&amp;rsquo;s blog and had not encountered any problems.&amp;nbsp; Once I upgraded to SP1 and checked &amp;ldquo;enabled .Net source stepping&amp;rdquo;, I all I ever got when trying to step through source is a dialog asking me for the location of the CS file.&lt;/p&gt;
&lt;p&gt;What I had configured was to place the debug symbols into a folder in the Visual Studio 2008 user directory (c:\Documents and Settings\PRitchie\My Documents\Visual Studio 2008\Symbols, for example).&lt;/p&gt;
&lt;p&gt;Despite creating a new subdirectory for SP1, I still could not step through the source.&lt;/p&gt;
&lt;p&gt;It wasn&amp;rsquo;t until I moved the directory down the hierarchy that I finally got some joy.&amp;nbsp; I first tried it on the root and it worked fine.&amp;nbsp; I then tried it as a sub directory within my documents and it worked fine.&amp;nbsp; I imagine that the path was longer that 260 and rather than present the user with an error with that detail it assumed it couldn&amp;rsquo;t find the file it was looking for and asked the user for the location of it.&amp;nbsp; But, I&amp;rsquo;m guessing.&lt;/p&gt;
&lt;p&gt;Hope this helps someone else.&lt;/p&gt;
&lt;div style="text-align:left;margin:0px;padding:4px 4px 4px 4px;" class="wlWriterHeaderFooter"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://msmvps.com/blogs/peterritchie/archive/2008/11/12/unable-to-step-into-net-source.aspx&amp;amp;title=Unable%20To%20Step%20Into%20.NET%20Source"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://msmvps.com/blogs/peterritchie/archive/2008/11/12/unable-to-step-into-net-source.aspx&amp;amp;bgcolor=0080C0&amp;amp;fgcolor=FFFFFF&amp;amp;border=000000&amp;amp;cbgcolor=D4E1ED&amp;amp;cfgcolor=000000" alt="DotNetKicks Image" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1653924" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008+SP1/default.aspx">Visual Studio 2008 SP1</category></item><item><title>Becoming a Visual Studio Jedi Part 1</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/09/02/becoming-a-visual-studio-jedi.aspx</link><pubDate>Tue, 02 Sep 2008 18:49:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1640948</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1640948</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/09/02/becoming-a-visual-studio-jedi.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-size:large;"&gt;Becoming a Visual Studio 2008 (and often Visual Studio 2005) Jedi&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In much the same grain as James&amp;#39; &lt;a href="http://www.jameskovacs.com/blog/BecomingAJediPart1OfN.aspx"&gt;Resharper Jedi&lt;/a&gt; posts, I&amp;#39;m beginning a series of posts on becoming a Visual Studio Jedi.&amp;nbsp; It involves getting the most out of Visual Studio off-the-shelf, doing things as quickly as possible and with as little friction as possible.&amp;nbsp; I think it&amp;#39;s useful for all users; but especially useful for those who are in situations where they can&amp;#39;t install refactoring tools like Refactor Pro! or Resharper.&lt;/p&gt;
&lt;p&gt;First, familiarize yourself with &lt;a href="http://blogs.msdn.com/saraford/archive/tags/Visual+Studio+2008+Tip+of+the+Day/default.aspx"&gt;Sara&amp;#39;s Visual Studio Tips&lt;/a&gt; blog; then subscribe to her blog.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll attempt to provide detail at a less granular level than Sara&amp;#39;s blog (i.e. using a series of commands to perform a specific task); but I may overlap here and there&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:large;"&gt;Take advantage of Auto-Hide &lt;br /&gt;&lt;/span&gt;Like Jimmy Bogard and Jeffery Palermo, I have my Visual Studio UI very lean. 99% of the time, I&amp;#39;m working in code.&amp;nbsp; The Solution Explorer (SE), Properties, Output, etc are auto-hide panes.&amp;nbsp; When I need to use them I hover the mouse over the tab to make them visible, do what I need to do with them, then get back to the code.&amp;nbsp; The Code Editor is the only window that isn&amp;#39;t auto-hide or floating. &lt;br /&gt;&lt;img src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peterritchie/lean-VS2k8.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:large;"&gt;Navigate find results via keyboard&lt;/span&gt; &lt;br /&gt;Whenever anything is displayed in a find results window, you can iterate each item in the list via a keystroke.&amp;nbsp; The default C# keyboard map had F8 and Shift+F8 as the shortcuts for next and previous.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Press Ctrl+Shift+F to bring up the Find in Files form. &lt;/li&gt;
&lt;li&gt;Enter &amp;quot;TODO\:.*refactor&amp;quot; in the &amp;quot;Find what&amp;quot; text box. &lt;/li&gt;
&lt;li&gt;Ensure Match case, Match whole word are unchecked. &lt;/li&gt;
&lt;li&gt;Ensure Use is checked and has Regular expressions selected. &lt;/li&gt;
&lt;li&gt;Press Alt+F to search. &lt;br /&gt;&lt;img src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peterritchie/Find-in-Files.JPG" alt="" /&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A Find Results window is displayed that shows the results of the search. &lt;br /&gt;&lt;img src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peterritchie/Find-Results.JPG" alt="" /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;F8&lt;/strong&gt; goes to the first result.&lt;/li&gt;
&lt;li&gt;Pressing &lt;strong&gt;F8&lt;/strong&gt; again goes to the next. &lt;/li&gt;
&lt;li&gt;Pressing &lt;strong&gt;Shift+F8&lt;/strong&gt; goes to the previous result.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See also: &lt;br /&gt;&lt;a href="http://blogs.msdn.com/saraford/archive/2008/04/18/did-you-know-you-can-use-f8-and-shift-f8-to-navigate-among-errors-in-the-output-window.aspx"&gt;http://blogs.msdn.com/saraford/archive/2008/04/18/did-you-know-you-can-use-f8-and-shift-f8-to-navigate-among-errors-in-the-output-window.aspx&lt;/a&gt; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/saraford/archive/2007/11/08/did-you-know-how-to-use-f8-to-navigate-the-find-results-window.aspx"&gt;http://blogs.msdn.com/saraford/archive/2007/11/08/did-you-know-how-to-use-f8-to-navigate-the-find-results-window.aspx&lt;/a&gt; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/saraford/archive/2005/03/30/403887.aspx"&gt;http://blogs.msdn.com/saraford/archive/2005/03/30/403887.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;F8 and Shift+F8 work for most lists like Find Results 1, Find Results 2, Error List, Output:Build, etc.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:large;"&gt;File name extensions when adding classes&lt;/span&gt; &lt;br /&gt;Do you find your self selecting text in the file name when you use the Add Class wizard?&amp;nbsp; Or, do you always type &amp;quot;.cs&amp;quot; at the end of your file name?&amp;nbsp; You may be happy to know you don&amp;#39;t have to do that.&amp;nbsp; Simply invoke the Add Class wizard and type the name of the class.&amp;nbsp; The wizard adds the missing .cs for you.&amp;nbsp; For example: &lt;br /&gt;Press Alt+P, C &lt;br /&gt;Enter &amp;quot;MyNewClass&amp;quot; &lt;br /&gt;Press Enter &lt;br /&gt;A file MyNewClass.cs is added to your project and it contains class named &amp;quot;MyNewClass&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:large;"&gt;Consider a Custom toolbar&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;There&amp;#39;s generally only handful of toolbar buttons that you might need, especially if you&amp;#39;re a keyboard user like me.&amp;nbsp; There&amp;#39;s some things that simply don&amp;#39;t have a default keyboard mapping.&amp;nbsp; Another good reason for having a custom toolbar item with only the buttons you use is if you often change the size of your Visual Studio window.&amp;nbsp; The default layout has two or more toolbars (depending on the edition and any add-ins you have installed).&amp;nbsp; You can carefully position those toolbars so they may take up one or two lines; but when you then shrink the size of your window the get wrapped and they won&amp;#39;t restore if you expand the size of your window.&amp;nbsp; Having a single toolbar means this wrapping of toolbars can never happen.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:large;"&gt;Export Settings&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Once you get your UI the way you want it, you can actually save the layout.&amp;nbsp; &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click on Tools\Import and Export Settings.&lt;/li&gt;
&lt;li&gt;Select Export selected environment settings.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is really handy if you get into low-resource situations (like the application you&amp;#39;re developing or its framework uses up too many GDI handles and Visual Studio can&amp;#39;t allocate a handle to display a toolbar or a frame.&amp;nbsp; When this happens Visual Studio actually turns off those GUI elements; when you close and restart those panes/frames are no longer displayed by default.)&lt;/p&gt;
&lt;div style="text-align:left;margin:0px;padding:4px 4px 4px 4px;" class="wlWriterHeaderFooter"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://msmvps.com/blogs/peterritchie/archive/2008/07/15/becoming-a-visual-studio-jedi.aspx&amp;amp;title=Becoming%20a%20Visual%20Studio%20Jedi%20Part%201"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://msmvps.com/blogs/peterritchie/archive/2008/07/15/becoming-a-visual-studio-jedi.aspx&amp;amp;bgcolor=0080C0&amp;amp;fgcolor=FFFFFF&amp;amp;border=000000&amp;amp;cbgcolor=D4E1ED&amp;amp;cfgcolor=000000" alt="DotNetKicks Image" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1640948" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Design_2F00_Coding+Guidance/default.aspx">Design/Coding Guidance</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/DevCenterPost/default.aspx">DevCenterPost</category></item><item><title>Drag and drop of control selections onto forms designer toolbox</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/08/21/drag-and-drop-of-control-selections-onto-forms-designer-toolbox.aspx</link><pubDate>Thu, 21 Aug 2008 16:43:39 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1645402</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1645402</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/08/21/drag-and-drop-of-control-selections-onto-forms-designer-toolbox.aspx#comments</comments><description>&lt;p&gt;A while back I blogged about the ability we have in Visual Studio to select text in a text editor and drag it onto the toolbox.&amp;#160; Once on the toolbox you could drag those items back into the text editor to effectively “paste” frequently needed snippets of code into other text files.&lt;/p&gt;  &lt;p&gt;Imagine my surprise when we didn’t have this ability in the forms designer.&amp;#160; When writing code, it’s a bit specious to want to have multiple copies of hard-coded snippets of code (DRY should come to mind).&amp;#160; But, for forms, the only alternative is to create user controls to contain commonly-used control groups.&amp;#160; User controls is very heavy weight and basically becomes unusable when talking about simple groups of buttons.&amp;#160; For example, “OK” and “Cancel” buttons.&lt;/p&gt;  &lt;p&gt;So, as a result, I’ve &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=362827" target="_blank"&gt;logged a suggestion&lt;/a&gt; on Microsoft Connect suggesting this ability be added to Visual Studio.&lt;/p&gt;  &lt;p&gt;If you want to see the potential of a feature like this, see &lt;a title="http://machine.nukeation.com/preview.html" href="http://machine.nukeation.com/preview.html"&gt;http://machine.nukeation.com/preview.html&lt;/a&gt;&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="text-align:left;margin:0px;padding:4px 4px 4px 4px;"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://msmvps.com/blogs/peterritchie/archive/2008/08/21/drag-and-drop-of-control-selections-onto-forms-designer-toolbox.aspx&amp;amp;title=Drag%20and%20drop%20of%20control%20selections%20onto%20forms%20designer%20toolbox"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://msmvps.com/blogs/peterritchie/archive/2008/08/21/drag-and-drop-of-control-selections-onto-forms-designer-toolbox.aspx&amp;amp;bgcolor=0080C0&amp;amp;fgcolor=FFFFFF&amp;amp;border=000000&amp;amp;cbgcolor=D4E1ED&amp;amp;cfgcolor=000000" alt="DotNetKicks Image" border="0/" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1645402" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+vNext/default.aspx">Visual Studio vNext</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Connect+Suggestion/default.aspx">Connect Suggestion</category></item><item><title>Working with Resharper's External Annotation XML Files</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/07/21/working-with-resharper-s-external-annotation-xml-files.aspx</link><pubDate>Mon, 21 Jul 2008 20:32:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1640964</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1640964</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/07/21/working-with-resharper-s-external-annotation-xml-files.aspx#comments</comments><description>&lt;p&gt;Resharper 4.0 has external annotation XML files that you can create to give Resharper more information about your code.&amp;nbsp; For example, you can tell Resharper that a particular method does not accept a null argument.&amp;nbsp; For example, the following method does not accept a null argument:&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;border:black 1px solid;"&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; Utility&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;{&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Text&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; GetLength(&lt;span style="color:#2b91af;"&gt;String&lt;/span&gt; text)&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;if&lt;/span&gt; (text == &lt;span style="color:blue;"&gt;null&lt;/span&gt;) &lt;span style="color:blue;"&gt;throw&lt;/span&gt; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;text&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; text.Length;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;An external annotation file can be created to inform Resharper of this fact and have it warn you when possible null values are passed as an argument:&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;border:black 1px solid;"&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;String&lt;/span&gt; text = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Utility.Text.GetLength(text);&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;First, you need to create a directory within the Resharper ExternalAnnotations directory.&amp;nbsp; This ExternalAnnotations directory is usually in the form of &amp;quot;%SystemDrive%\Program Files\JetBrains\ReSharper\vBuild#\Bin\ExternalAnnotations&amp;quot; for example &amp;quot;C:\Program Files\JetBrains\ReSharper\v4.0.816.4\Bin\ExternalAnnotations&amp;quot;.&lt;/p&gt;
&lt;p&gt;The directory we need to create is the same name as our assembly (without the extension).&amp;nbsp; In our case this would be &amp;quot;C:\Program Files\JetBrains\ReSharper\v4.0.816.4\Bin\ExternalAnnotations\Utility&amp;quot;.&lt;/p&gt;
&lt;p&gt;Next, we need to create an XML file to contain the information required by Resharper.&amp;nbsp; The name of this file is the same as the directory name, plus &amp;quot;.xml&amp;quot;.&amp;nbsp; So, the full file name would be &amp;quot;C:\Program Files\JetBrains\ReSharper\v4.0.816.4\Bin\ExternalAnnotations\Utility\Utility.xml&amp;quot;.&amp;nbsp; This file essentially has an assembly element with child member elements that provide meta-data about methods and arguments.&amp;nbsp; In our case we want to tell Resharper that the Utility.Text.GetLength(String) method does not accept null values for the argument named &amp;quot;text&amp;quot;.&amp;nbsp; To do this we populate the file with the following XML:&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;border:black 1px solid;"&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a31515;"&gt;xml&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;encoding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; ?&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;assembly&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Utility&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;member&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;M:Utility.Text.GetLength(System.String)&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;parameter&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;text&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;attribute&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;ctor&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;M:JetBrains.Annotations.NotNullAttribute.#ctor&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;parameter&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;member&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;After restarting Visual Studio, Resharper will now warn that &amp;quot;text&amp;quot;, when passed to GetLength, in the following code, has a &amp;quot;Possible &amp;#39;null&amp;#39; assignment to entity marked with &amp;quot;NotNull&amp;quot; attribute&amp;quot;.&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;border:black 1px solid;"&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;String&lt;/span&gt; text = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Utility.Text.GetLength(text);&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I&amp;#39;ve tried this with the GA build and with both Visual Studio 2005 (SP1) and Visual Studio 2008.&lt;/p&gt;
&lt;p&gt;For more information about the annotation options, search for AssertionConditionType in the Resharper help and browse around &amp;quot;%SystemDrive%\Program Files\JetBrains\ReSharper\vBuild#\Bin\ExternalAnnotations&amp;quot; for examples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1640964" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Resharper/default.aspx">Resharper</category></item><item><title>Drag-copying in Visual Studio Solution Explorer.</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/07/18/drag-copying-in-visual-studio-solution-explorer.aspx</link><pubDate>Fri, 18 Jul 2008 16:46:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1640926</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1640926</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/07/18/drag-copying-in-visual-studio-solution-explorer.aspx#comments</comments><description>&lt;p&gt;NOTE: I&amp;#39;ve tried this in Visual Studio 2008 (VS2k8), I&amp;#39;m assuming the same thing happens in Visual Studio 2005 (VS2k5).&lt;/p&gt;
&lt;p&gt;In the process of refactoring, it&amp;#39;s *very* common for me to rename a type.&amp;nbsp; This is most easily done by renaming the file in the Solution Explorer (SE)--which renames the file, the type, and and any uses of the type in the entire solution.&lt;/p&gt;
&lt;p&gt;Occasionally, I need to create a new type based on another.&amp;nbsp; Copying an abstract type in order to implement the abstract type is often handy--I just fill in the abstract members (and delete &amp;quot;abstract&amp;quot;) in the copied type after renaming it.&lt;/p&gt;
&lt;p&gt;Drag-copy in the SE seems like it would take care of a couple of steps at once for me: make a copy and rename it.&amp;nbsp; Unfortunately it doesn&amp;#39;t do that.&amp;nbsp; It makes a copy of the file (as &amp;quot;Copy of typename.xx&amp;quot;) but doesn&amp;#39;t rename any types in the class that match the file name.&lt;/p&gt;
&lt;p&gt;This might seem somewhat trivial... I can simply rename the file name then refactor rename the type in the file so that the type and all it&amp;#39;s constructors are renamed in one fell swoop.&amp;nbsp; Alas, this simply opens a can of worms that can completely confound a newcomer and annoy an expert.&lt;/p&gt;
&lt;p&gt;That simple, intuitive method of renaming a copy of a file then the type within the file actually renames *all* types of that name.&amp;nbsp; Since we&amp;#39;ve just made a copy of the type, that means it&amp;#39;s always going rename types in two files.&amp;nbsp; The side-effect of drag-copy in SE means you *must* manually rename the type in the file you just copied.&amp;nbsp; You can do this with search-replace; but that&amp;#39;s friction I don&amp;#39;t want and really makes SE drag-copy unusable.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=355239"&gt;logged a bug about it on Connect&lt;/a&gt;; but the olde &amp;quot;by design&amp;quot; card was played... &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1640926" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Product+Bugs/default.aspx">Product Bugs</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Poor+UI/default.aspx">Poor UI</category></item><item><title>Nested Types</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/07/15/nested-types.aspx</link><pubDate>Tue, 15 Jul 2008 14:47:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1640904</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1640904</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/07/15/nested-types.aspx#comments</comments><description>&lt;p&gt;Recently &lt;a href="http://www.michaelfeathers.com/"&gt;Michael Features&lt;/a&gt; &lt;a href="http://michaelfeathers.typepad.com/michael_feathers_blog/2008/06/are-nested-clas.html"&gt;blogged about nested types&lt;/a&gt;.&amp;nbsp; The title was almost &amp;quot;nested types considered harmful&amp;quot;.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t agree.&amp;nbsp; I don&amp;#39;t agree that they&amp;#39;re any more harmful than any other C# construct (except goto...).&amp;nbsp; Nested types are like anything else in our tool-belt: they have a time and place and can be abused.&lt;/p&gt;
&lt;p&gt;But, when to use them?&amp;nbsp; Well, for the most part I agree with Michael, you should avoid them. But, there are times when they&amp;#39;re simply the best solution in a given set of circumstances.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s look at asynchronous programming model (APM) in .NET.&lt;/p&gt;
&lt;div style="BORDER-RIGHT:black 1px solid;BORDER-TOP:black 1px solid;FONT-SIZE:10pt;BACKGROUND:white;BORDER-LEFT:black 1px solid;COLOR:black;BORDER-BOTTOM:black 1px solid;FONT-FAMILY:Courier New;"&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Paraphrased from MSDN&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&lt;span style="color:#008000;"&gt;        // Accept one client connection asynchronously.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; DoBeginAcceptTcpClient(&lt;span style="color:#2b91af;"&gt;TcpListener&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; listener)&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Start to listen for connections from a client.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Trace&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;Waiting for a connection...&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Accept the connection. &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// BeginAcceptSocket() creates the accepted socket.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; listener.BeginAcceptTcpClient(&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DoAcceptTcpClientCallback,&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; listener);&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Process the client connection.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; DoAcceptTcpClientCallback(&lt;span style="color:#2b91af;"&gt;IAsyncResult&lt;/span&gt; ar)&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Get the listener that handles the client request.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;TcpListener&lt;/span&gt; listener = (&lt;span style="color:#2b91af;"&gt;TcpListener&lt;/span&gt;)ar.AsyncState;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// End the operation and display the received data on &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// the console.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;TcpClient&lt;/span&gt; client = listener.EndAcceptTcpClient(ar);&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// TODO: do something with client.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Process the connection here. (Add the client to a&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// server table, read data, etc.)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Trace&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;Client connected completed&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;pre style="BACKGROUND:cornsilk;MARGIN:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;In this simple scenario we are getting by with a state of simply a TcpListener object.&amp;nbsp; In a more complex scenario, you&amp;#39;ll likely also want a connection-specific queue, some sort of information about what to do after a connection, etc.&amp;nbsp; While you can use existing types of have several collection instance fields to keep track of each of these things; you then have to introduce synchronization of those collections, managing the content of those collections, etc.--it&amp;#39;s much easier and safer to send that information on the stack.&amp;nbsp; One method I&amp;#39;ve tried is simply passing an Object collection as the state; but that quickly becomes hard to manage because of the lack of type-safety on the elements in the array (if I remove an element and replace it with another type, the compile can&amp;#39;t know and I&amp;#39;ll get a run-time error instead of a compile-time error).&amp;nbsp; To get type safety I generally introduce a new type to aggregate all the types I need in this asynchronous callback.&amp;nbsp; While this new type *could* be reusable by other classes; it likely isn&amp;#39;t and I don&amp;#39;t want to then be bound that that explicit contract I&amp;#39;ve signed by making the types publicly available.&amp;nbsp; The only option of not making them publicly available is as private nested types.&amp;nbsp; For example: &lt;/p&gt;

&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;border:black 1px solid;"&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;AcceptTcpClientParameters&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;CommandQueue&lt;/span&gt; CommandQueue { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Command&lt;/span&gt; NextCommand { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;TcpListener&lt;/span&gt; TcpListener { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; AcceptTcpClientParameters(&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; commandQueue, &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; nextCommand, &lt;span style="color:#2b91af;"&gt;TcpListener&lt;/span&gt; tcpListener)&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; CommandQueue = commandQueue;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NextCommand = nextCommand;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TcpListener = tcpListener;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Accept one client connection asynchronously.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; DoBeginAcceptTcpClient(&lt;span style="color:#2b91af;"&gt;TcpListener&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; listener, &lt;span style="color:#2b91af;"&gt;CommandQueue&lt;/span&gt; commandQueue, &lt;span style="color:#2b91af;"&gt;Command&lt;/span&gt; nextCommand)&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Start to listen for connections from a client.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Trace&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;Waiting for a connection...&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Accept the connection. &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// BeginAcceptSocket() creates the accepted socket.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; listener.BeginAcceptTcpClient(&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DoAcceptTcpClientCallback,&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;AcceptTcpClientParameters&lt;/span&gt;(commandQueue, nextCommand, listener));&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#008000;"&gt;// Process the client connection.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; DoAcceptTcpClientCallback(&lt;span style="color:#2b91af;"&gt;IAsyncResult&lt;/span&gt; ar)&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;AcceptTcpClientParameters&lt;/span&gt; parameters = ar.AsyncState &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;AcceptTcpClientParameters&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;(parameters == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;) &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;TcpClient&lt;/span&gt; client = parameters.TcpListener.EndAcceptTcpClient(ar);&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; parameters.NextCommand.Process(parameters.CommandQueue, client);&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I find this use of nested types to be more object-oriented (the needs of the DoAcceptTcpClientCallback are abstracted), more intention revealing, better implements Single Responsibility Principle (SRP), better separates concerns, more maintainable and more agile.&lt;/p&gt;
&lt;p&gt;Now, to be clear; this is forced set of circumstances.&amp;nbsp; You&amp;#39;re using a library that implements the APM (right?&amp;nbsp; You haven&amp;#39;t implemented APM yourself...).&amp;nbsp; But, that&amp;#39;s my point--nested types are almost essential in a given set of circumstances.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2008%2f07%2f15%2fnested-types.aspx"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2008%2f07%2f15%2fnested-types.aspx" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1640904" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Design_2F00_Coding+Guidance/default.aspx">Design/Coding Guidance</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_+3.0/default.aspx">C# 3.0</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/TCP/default.aspx">TCP</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Asynchronous+Programming+Model+_2800_APM_2900_/default.aspx">Asynchronous Programming Model (APM)</category></item><item><title>Trace to output window without adding code.</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/06/13/trace-to-output-window-without-adding-code.aspx</link><pubDate>Fri, 13 Jun 2008 17:08:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1634781</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1634781</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/06/13/trace-to-output-window-without-adding-code.aspx#comments</comments><description>&lt;p&gt;Want to trace some run-time data to the output window while debugging&amp;nbsp;without changing and recompiling your code?&amp;nbsp; Use Tracepoints: &lt;a href="http://blogs.msdn.com/saraford/archive/2008/06/13/did-you-know-you-can-use-tracepoints-to-log-printf-or-console-writeline-info-without-editing-your-code-237.aspx"&gt;http://blogs.msdn.com/saraford/archive/2008/06/13/did-you-know-you-can-use-tracepoints-to-log-printf-or-console-writeline-info-without-editing-your-code-237.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1634781" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Interesting+Find/default.aspx">Interesting Find</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category></item><item><title>No "Add Method Stub" When Passing or Assigning Delegates</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/15/no-quot-add-method-stub-quot-when-passing-or-assigning-delegates.aspx</link><pubDate>Fri, 15 Feb 2008 20:45:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1515425</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1515425</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/02/15/no-quot-add-method-stub-quot-when-passing-or-assigning-delegates.aspx#comments</comments><description>&lt;p&gt;I finally noticed the other day the &amp;quot;Add method stub&amp;quot; SmartTag wasn&amp;#39;t appearing for a new method name I type in.&amp;nbsp; I decided I&amp;#39;d have a closer look...&lt;/p&gt;
&lt;p&gt;When you&amp;#39;re practicing Test-Driven Development (TDD) you want to write a test for methods before you write the methods.&amp;nbsp; This means you write a test method that calls several other methods that don&amp;#39;t exist yet.&amp;nbsp; The Visual Studio IDE, in an effort to promote TDD, recognizes this and when you have your caret over a call to one of these methods a SmartTag shows up and you can select &lt;em&gt;Generate method stub for &amp;#39;SomeMethod&amp;#39; in &amp;#39;SomeNamespace.SomeClass&amp;#39;&lt;/em&gt;.&amp;nbsp; For example, if you have the following:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt;[] args)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; SomeMethod();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;...if you place the caret (e.g. click on &amp;quot;SomeMethod&amp;quot;)&amp;nbsp;somewhere on &amp;quot;SomeMethod&amp;quot; (and it doesn&amp;#39;t exist in the current class) the&amp;nbsp;SmartTag rectangle under the &amp;#39;S&amp;#39; in&amp;nbsp;SometMethod appears and you can hover your mouse over&amp;nbsp;the word &amp;quot;SomeMethod&amp;quot; and the options icon appears that you can click and select &lt;em&gt;Generate method stub for &amp;#39;SomeMethod&amp;#39; in &amp;#39;SomeNamespace.SomeClass&amp;#39;&lt;/em&gt;, and it will generate a method like the following:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;private&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; SomeMethod()&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;throw&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;NotImplementedException&lt;/span&gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;Well, I figured this would also happen when I tried to assign a non-existent method&amp;nbsp;to a delegate.&amp;nbsp; For example, if I had the following:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt;[] args)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Action&lt;/span&gt; action = SomeOtherMethod;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;...I would expect that placing&amp;nbsp;the caret over &amp;quot;SomeOtherMethod&amp;quot; that the SmartTag would show up and&amp;nbsp;I would be able to select&amp;nbsp;&lt;em&gt;&amp;#39;SomeOtherMethod&amp;#39; in &amp;#39;SomeNamespace.SomeClass&amp;#39;&lt;/em&gt; and it would generate a method like the following:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;private&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; SomeOtherMethod()&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;throw&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;NotImplementedException&lt;/span&gt;();&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;Alas, the IDE doesn&amp;#39;t recognize use of an undeclared method when used with delegates.&amp;nbsp; i.e. it doesn&amp;#39;t appear in these circumstances either:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; ProcessDelegate(&lt;span style="COLOR:#2b91af;"&gt;Action&lt;/span&gt; action)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;//...&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt;[] args)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessDelegate(SomeOtherMethod);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessDelegate(&lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Action&lt;/span&gt;(SomeOtherMethod));&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;I thought&amp;nbsp;&amp;quot;Add method stub&amp;quot;&amp;nbsp;would be&amp;nbsp;more useful in these circumstances because you&amp;#39;re not explicitly&amp;nbsp;passing arguments to the method so it&amp;#39;s more likely that you don&amp;#39;t&amp;nbsp;know what signature you need to declare.&amp;nbsp; So, I logged a suggestion for it:&amp;nbsp;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=328782"&gt;https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=328782&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;By the way, the non-generic Action delegate (System.Core.Delegate) is new to .NET 3.5.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1515425" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Product+Suggestions/default.aspx">Product Suggestions</category></item><item><title>Is C++/CLI a Second Class Language with Microsoft?</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/01/29/is-c-cli-a-second-class-language-with-microsoft.aspx</link><pubDate>Tue, 29 Jan 2008 16:03:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1485713</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1485713</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/01/29/is-c-cli-a-second-class-language-with-microsoft.aspx#comments</comments><description>&lt;p&gt;The post frequency on the &lt;a class="" href="http://blogs.msdn.com/vcblog/"&gt;Visual C++ team blog&lt;/a&gt; is reasonably high.&amp;nbsp;Some posts deal with new features that were added to VC++ 2008.&lt;/p&gt;
&lt;p&gt;But, is Visual C++ a second-class citizen in the Visual Studio product group?&amp;nbsp; Recently the &lt;a class="" href="http://blogs.msdn.com/robcaron/archive/2008/01/27/7278319.aspx"&gt;Visual Studio 2008 Product Comparison&lt;/a&gt; was released (don&amp;#39;t ask me why it wasn&amp;#39;t released at the same time as the products...).&amp;nbsp; In the product comparisons VC++ Express has an inordinate&amp;nbsp;number of features that only it doesn&amp;#39;t have.&amp;nbsp; When you look at the Visual C++ 2008 Express Edition &lt;a class="" href="http://www.microsoft.com/express/product/default.aspx"&gt;product&lt;/a&gt; &lt;a class="" href="http://www.microsoft.com/express/vc/"&gt;sites&lt;/a&gt;, it seems pretty clear that it&amp;#39;s geared towards native-only software development.&amp;nbsp; Despite this the product comparison shows VC++ Express has Managed Debugging, Mixed-Mode Debugging and&amp;nbsp;Compiler Support for any CPU (which details &amp;quot;...compile your managed application...&amp;quot;).&amp;nbsp; But, VC++ 2008 Express is the only edition that doesn&amp;#39;t support adding reference to WCF services (&amp;quot;Service Reference&amp;quot;), Code Snipped Manager, Code Snippets, Rename Refactoring, Text File (you can&amp;#39;t create a plain text file with VC++ 2008 Express?), and one of two editions&amp;nbsp;that doesn&amp;#39;t include support for XML File (create a blank XML file), and SQL Server 2005 Compact Edition.&amp;nbsp; As well, only VC++ 2008 doesn&amp;#39;t include managed-only features like&amp;nbsp;Object Browser, Object Relational Designer, and SQLMetal (the last two deal with .NET-only LINQ-to-SQL.&lt;/p&gt;
&lt;p&gt;C++ has stagnated as a language for quite some time, but Visual C++ 2008 includes new language features like C++0x and TR1 that help evolve the language for the parallel future.&amp;nbsp; But, despite assurances that &lt;a class="" href="http://channel9.msdn.com/ShowPost.aspx?PostID=281987"&gt;native development is still a focus&lt;/a&gt; at Microsoft, there is the appearance that VC++ just isn&amp;#39;t getting the same resources as the other editions.&amp;nbsp; Makes you wonder how much longer will Microsoft keep it in the Visual Studio family...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1485713" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2B002B002F00_CLI/default.aspx">C++/CLI</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Pontification/default.aspx">Pontification</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category></item><item><title>New Warning CS1060 in C# 3 (Visual Studio 2008)</title><link>http://msmvps.com/blogs/peterritchie/archive/2007/12/09/new-warning-cs1060-in-c-3-visual-studio-2008.aspx</link><pubDate>Sun, 09 Dec 2007 22:38:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1396573</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1396573</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2007/12/09/new-warning-cs1060-in-c-3-visual-studio-2008.aspx#comments</comments><description>&lt;p&gt;Recompiling C# 2 (Visual Studio 2005) code in C# 3 (Visual Studio 2008), you may incounter a new warning that didn&amp;#39;t used to ocur:&lt;/p&gt;
&lt;p&gt;Warning CS1060: Use of&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; possibly unassigned field &amp;#39;fieldName&amp;#39;. Struct instance variables are initially unassigned if struct is unassigned.&lt;/p&gt;
&lt;p&gt;Dealing strictly with syntax, C# let&amp;#39;s you declare a value type (struct) with a reference member, for example:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console Modified;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;namespace&lt;/span&gt; Examples&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;using&lt;/span&gt; System.Drawing;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Program&lt;/span&gt;&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;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Main()&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;LabelEntry&lt;/span&gt; labelEntry;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font style="BACKGROUND-COLOR:#ffcc00;"&gt;labelEntry.Location.Point.X = 0;&lt;/font&gt;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&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;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;struct&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;LabelEntry&lt;/span&gt;&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;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;LabelLocation&lt;/span&gt; Location;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;String&lt;/span&gt; Label;&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;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;LabelLocation&lt;/span&gt;&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;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Point&lt;/span&gt; Point;&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Unfortunately, in C# 2, and previous, it wouldn&amp;#39;t give you an warning if you tried to read a value type reference member before initializing it, as in the highlighted code.&lt;/p&gt;
&lt;p&gt;As I&amp;#39;ve alluded to before, syntactic correctness does not imply conceptional correctness and this warning improves syntax correctness.&lt;/p&gt;
&lt;p&gt;If avoiding reference members in structs isn&amp;#39;t clear, let me know and&amp;nbsp;I can do a post on that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1396573" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_+3.0+Breaking+Changes/default.aspx">C# 3.0 Breaking Changes</category></item><item><title>New warning CS0809 in C# 3 (Visual Studio 2008)</title><link>http://msmvps.com/blogs/peterritchie/archive/2007/11/26/new-warning-cs0809-in-c-3-visual-studio-2008.aspx</link><pubDate>Mon, 26 Nov 2007 20:31:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1358620</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1358620</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2007/11/26/new-warning-cs0809-in-c-3-visual-studio-2008.aspx#comments</comments><description>&lt;p&gt;There were several breaking changes (fixes) in C# 3 from C# 2.&amp;nbsp; One is the ability to attribute a member override with ObsoleteAttribute without also attributing it the virtual member in the base class.&lt;/p&gt;
&lt;p&gt;For example, the following will compile without error In C# 2 (Visual Studio 2005/.NET 2.0):&lt;/p&gt;
&lt;blockquote&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;&lt;pre style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; System;&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;internal&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;BaseClass&lt;/span&gt;&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;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;virtual&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Method()&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;/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;internal&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;DerivedClass&lt;/span&gt; : &lt;span style="COLOR:#2b91af;"&gt;BaseClass&lt;/span&gt;&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:#2b91af;"&gt;Obsolete&lt;/span&gt;]&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;override&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Method()&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;/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;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Progam&lt;/span&gt;&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;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Main()&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;span style="COLOR:#2b91af;"&gt;BaseClass&lt;/span&gt; baseClass = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;DerivedClass&lt;/span&gt;();&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; baseClass.Method();&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="MARGIN:0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;This same code will generate a CS0809 warning with C# 3.&lt;/p&gt;
&lt;p&gt;This change was done because, as you can see in the example, if DerivedClass.Method is accessed via a BaseClass reference, the compiler can&amp;#39;t reliably warn you that you&amp;#39;re in fact calling an Obsolete method.&lt;/p&gt;
&lt;p&gt;In reality, even you you did call DerivedClass.Method() via a DerivedClass reference you still wouldn&amp;#39;t get a warning.&amp;nbsp; This may have something to do with a quirk in the way the compiler detects attributes with overrides and virtual methods; but I&amp;#39;m surmising.&lt;/p&gt;
&lt;p&gt;The fix, if you have access to the base class, is to attribute bot the base and the derived class member with ObsoleteAttribute.&amp;nbsp; If you don&amp;#39;t have access to the base class, you&amp;#39;ll have to live with or suppress the warning.&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1358620" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Design_2F00_Coding+Guidance/default.aspx">Design/Coding Guidance</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_+3.0/default.aspx">C# 3.0</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_+3.0+Breaking+Changes/default.aspx">C# 3.0 Breaking Changes</category></item><item><title>New Contributor to the C# Developer Centre</title><link>http://msmvps.com/blogs/peterritchie/archive/2007/10/25/new-contributor-to-the-c-developer-centre.aspx</link><pubDate>Thu, 25 Oct 2007 22:17:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1264253</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1264253</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2007/10/25/new-contributor-to-the-c-developer-centre.aspx#comments</comments><description>&lt;p&gt;A new contributor to the C# Developer Centre has posted a new article.&amp;nbsp; This article goes into great detail about extension methods, what they are and how they&amp;#39;re implemented.&amp;nbsp; If you&amp;#39;re more than curious about this feature of the soon-to-be-release Visual Studio 2008 and C# 3.0, it&amp;#39;s a great read.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://msdn2.microsoft.com/en-ca/vcsharp/bb905825.aspx"&gt;http://msdn2.microsoft.com/en-ca/vcsharp/bb905825.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1264253" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_+Nugget/default.aspx">C# Nugget</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_+3.0/default.aspx">C# 3.0</category></item><item><title>Web seminars on Visual Studio 2008</title><link>http://msmvps.com/blogs/peterritchie/archive/2007/09/13/web-seminars-on-visual-studio-2008.aspx</link><pubDate>Thu, 13 Sep 2007 15:43:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1191575</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1191575</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2007/09/13/web-seminars-on-visual-studio-2008.aspx#comments</comments><description>&lt;p&gt;In the same fashion as Visual Studio 2008, Bill Lodin of IT Mentors is giving Web seminars on Visual Studio 2008.&amp;nbsp; Introducing Microsoft Visual Studio 2008, Microsoft Visual Studio 2008 - Next-Generation Web Applications, and Microsoft Visual Studio 2008 - Rich Windows Client Applications have been presented and recordings can be downloaded for each:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a class="" href="http://www.msreadiness.com/CourseDetail.aspx?id=6602"&gt;Introducing Microsoft Visual Studio 2008&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a class="" href="http://www.msreadiness.com/CourseDetail.aspx?id=6603"&gt;Microsoft Visual Studio 2008 - Next-Generation Web Applications&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a class="" href="http://www.msreadiness.com/CourseDetail.aspx?id=6604"&gt;Microsoft Visual Studio 2008 - Rich Windows Client Applications&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Future web seminars by Bill on Visual Studio 2008 will include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Microsoft Silverlight and Microsoft Visual Studio 2008&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Building Better Web Services with Microsoft Visual Studio 2008 &lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Microsoft ASP.NET AJAX and Microsoft Visual Studio 2008&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Web Development with Microsoft Visual Studio 2008&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Microsoft Visual Studio 2008 - Office Business Applications.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1191575" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category></item><item><title>My Visual Studio 2008 Code Analysis Rules</title><link>http://msmvps.com/blogs/peterritchie/archive/2007/09/04/my-visual-studio-2008-code-analysis-rules.aspx</link><pubDate>Tue, 04 Sep 2007 16:02:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1164356</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1164356</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2007/09/04/my-visual-studio-2008-code-analysis-rules.aspx#comments</comments><description>&lt;p&gt;Although a couple of suggestion for changes to existing rules seem to have made it into Visual Studio 2008 Beta 2, unfortunately, none of my suggestions for new Code Analysis rules made it into Orcas Beta 2 (and thus likely not in RTM).&lt;/p&gt;
&lt;p&gt;I was holding off on writing my own rules waiting for a stable SDK because I didn&amp;#39;t really want to write several different versions of the same rule.&amp;nbsp; But, unfortunately that also wasn&amp;#39;t in the cards for Orcas, so I&amp;#39;ve begun writing a few rules for Visual Studio 2008 that I feel are important.&lt;/p&gt;
&lt;p&gt;Some of the rules I&amp;#39;ve suggested over the years that I&amp;#39;ve implemented in this Code Analysis add-in are:&lt;br /&gt;&lt;strong&gt;DoNotUseCurrentUICultureAsIFormatProviderArgument&lt;/strong&gt;&lt;br /&gt;I&amp;#39;ve blogged about issues using CurrentUICulture for formatting and parsing methods (i.e. as an IFormatProvider argument) in the past.&amp;nbsp; The issue is that CurrentUICulture can be assigned a neutral or a specific culture but formatting and parsing requires a specific culture.&amp;nbsp; A neutral culture is one that only specifies language and not region or country.&amp;nbsp; Region and country define the formatting specifications.&amp;nbsp; Using a neutral culture, although syntactically correct, as an IFormatProvider argument will result in an exception.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;DoNotLockOnOPubliclyVisibleObjects&lt;/strong&gt;&lt;br /&gt;This guideline is from from the MSDN documentation (in various places, see &lt;a href="http://msdn2.microsoft.com/en-us/library/c5kehkcz(vs.80).aspx"&gt;http://msdn2.microsoft.com/en-us/library/c5kehkcz(vs.80).aspx&lt;/a&gt; for one).&amp;nbsp; Code Analysis already checks for locks on typeof but it doesn&amp;#39;t check for locks on this or other public members.&amp;nbsp; DoNotLockOnOPubliclyVisibleObjects checks for lock on &amp;quot;this&amp;quot; (or SyncLock on &amp;quot;Me&amp;quot;) as well as direct use of Monitor.Enter/Exit.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve created some rules for checking some of the issues I&amp;#39;ve blogged about in the past:&lt;br /&gt;&lt;strong&gt;DoNotUseThreadAbort&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;DoNotUseThreadSleep&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;DoNotUsesleepWithZeroArgument&lt;/strong&gt;&lt;br /&gt;...I won&amp;#39;t flog that horse more than it&amp;#39;s already been flogged...&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I created one of many (I hope) C#3/VB9 rules: &lt;br /&gt;&lt;strong&gt;AvoidExtensionMethodsThatDuplicateInstanceMethods&lt;/strong&gt;&lt;br /&gt;In Visual C# Orcas you can write an extension method that has the same signature as an instance method.&amp;nbsp; With the method resolution rules in C# this extension method will never get called; but no warning is issued to that effect.&amp;nbsp; For example:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; ArrayExtensions;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;namespace&lt;/span&gt; Application&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Program&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; Main ( &lt;span style="COLOR:blue;"&gt;string&lt;/span&gt;[] args )&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;[] arr = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;[10];&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; arr.SetValue(10, 0);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;namespace&lt;/span&gt; ArrayExtensions&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;internal&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Extensions&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;void&lt;/span&gt; SetValue ( &lt;span style="COLOR:blue;"&gt;this&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Array&lt;/span&gt; array, &lt;span style="COLOR:blue;"&gt;object&lt;/span&gt; value, &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt; index )&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; array.SetValue(value, index);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;No warning is given that Extensions.SetValue can never be called as an&amp;nbsp;extension method.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On much the same lines as AvoidExtensionMethodsThatDuplicateInstanceMethods I&amp;#39;ve also added:&lt;br /&gt;&lt;strong&gt;DoNotRecursivelyReferenceProperty&lt;br /&gt;&lt;/strong&gt;Rather than requesting either of these be added to Code Analysis I&amp;#39;d recommend these checks actually be performed by the compiler (as I have with recursively calling a property).&amp;nbsp; In the meantime, these rules can be flagged as errors in Visual Studio.&amp;nbsp; Syntactically in C# there&amp;#39;s nothing wrong with calling a property from itself.&amp;nbsp; This, of course, will result in a StackOverflowException and your application&amp;#39;s termination because of the infinite recursion--without warning or error.&amp;nbsp; With DoNotRecursivelyReferenceProperty, there isn&amp;#39;t enough metadata to efficiently distinguish between directly calling an object&amp;#39;s property from itself or calling another object&amp;#39;s property from the same property, so this rule will be raised on code like this:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Entity&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;private&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;Entity&lt;/span&gt; otherEntity;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;private&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; text;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;String&lt;/span&gt; Text&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;get&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;if&lt;/span&gt; (otherEntity != &lt;span style="COLOR:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; otherEntity.Text;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;this&lt;/span&gt;.text;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;//...&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I don&amp;#39;t think this is a bad thing.&amp;nbsp; For one thing it&amp;#39;s an unlikely scenario; and another, there&amp;#39;s no way to tell if the code might get hit by an infinite recursion&amp;nbsp;(otherEntity could be assigned &amp;quot;this&amp;quot;).&amp;nbsp; In the unlikely event this scenario is legit (i.e. you&amp;#39;re checking to make sure the object is not &amp;quot;this&amp;quot;) then you can simply add a suppression for this rule where appropriate.&amp;nbsp; For example:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [System.Diagnostics.CodeAnalysis.&lt;span style="COLOR:#2b91af;"&gt;SuppressMessage&lt;/span&gt;(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;PRI.Design&amp;quot;&lt;/span&gt;, &lt;span style="COLOR:#a31515;"&gt;&amp;quot;PRICA1001:DoNotRecursivelyReferenceProperty&amp;quot;&lt;/span&gt;)]&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;String&lt;/span&gt; Text&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;get&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;if&lt;/span&gt; (otherEntity != &lt;span style="COLOR:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; otherEntity.Text;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;this&lt;/span&gt;.text;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Download&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The add-ins may be downloaded from here: &lt;a href="http://www.peterritchie.com/Hamlet/Downloads/105.aspx"&gt;http://www.peterritchie.com/Hamlet/Downloads/105.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Deployment&lt;/strong&gt;&lt;br /&gt;After exiting all instances of Visual Studio 2008 Beta 2, simply unzip the contents to&amp;nbsp;&amp;quot;C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\Rules&amp;quot; and re-load Visual Studio.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1164356" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Code+Analysis+Rules/default.aspx">Code Analysis Rules</category></item><item><title>Visual Studio 2008 Managed Code Analysis</title><link>http://msmvps.com/blogs/peterritchie/archive/2007/08/27/visual-studio-2008-managed-code-analysis.aspx</link><pubDate>Mon, 27 Aug 2007 20:04:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1141613</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1141613</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2007/08/27/visual-studio-2008-managed-code-analysis.aspx#comments</comments><description>&lt;p&gt;I had a quick look at the managed code analysis (FxCop) rules the other day to see what&amp;#39;s new and what&amp;#39;s been removed.&amp;nbsp; Unfortunately, one of the analysis engines wasn&amp;#39;t able to be &amp;quot;resurrected&amp;quot; in time for the release, so there&amp;#39;s a few really useful rules that haven&amp;#39;t stayed with Beta 2 the reslease of Visual Studio 2008.&amp;nbsp; Fortunately, there have been some additions too.&amp;nbsp; Fortunately, there is not a deficit, we&amp;#39;re up by 12 new rules.&lt;/p&gt;
&lt;p&gt;Following are the new rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;DoNotRaiseExceptionsInUnexpectedLocations&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;NormalizeStringsToUppercase&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;SpecifyMarshalingForPInvokeStringArguments&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;SpecifyStringComparison&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;UseOrdinalStringComparison&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;AvoidUnmaintainableCode&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ReviewMisleadingFieldNames&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;AvoidExcessiveClassCoupling&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;IdentifiersShouldBeCasedCorrectly&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;IdentifiersShouldBeSpelledCorrectly&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;IdentifiersShouldDifferByMoreThanCase&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;IdentifiersShouldNotContainTypeNames&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;OnlyFlagsEnumsShouldHavePluralNames&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ResourceStringCompoundWordsShouldBeCasedCorrectly&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ResourceStringsShouldBeSpelledCorrectly&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;MarkAssembliesWithNeutralResourcesLanguage&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;RemoveEmptyFinalizers&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;CatchNonClsCompliantExceptionsInGeneralHandlers&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;TestForNaNCorrectly&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;AttributeStringLiteralsShouldParseCorrectly&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;SecurityTransparentAssembliesShouldNotContainSecurityCriticalCode&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;SecurityTransparentCodeShouldNotAssert&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;SecurityTransparentCodeShouldNotReferenceNonpublicSecurityCriticalCode&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;CatchNonClsCompliantExceptionsInGeneralHandlers&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;And following are the rules that were removed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;ProvideCorrectArgumentsToFormattingMethods&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;DisposeMethodsShouldCallBaseClassDispose&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;DoNotCallPropertiesThatCloneValuesInLoops&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;DoNotDisposeObjectsMultipleTimes&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;SpecifyMarshalingForPInvokeStringArguments&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;DoNotPassLiteralsAsLocalizedParameters&lt;/div&gt;&lt;/li&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;LongAcronymsShouldBePascalCased&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;ShortAcronymsShouldBeUppercase&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;AvoidUnnecessaryStringCreation&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;DoNotConcatenateStringsInsideLoops&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;SecureGetObjectDataOverrides&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;AssembliesShouldDeclareMinimumSecurity&lt;/li&gt;&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1141613" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category></item></channel></rss>