<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>.Net Smoothie &#187; Visual Studio</title>
	<atom:link href="http://www.richardbushnell.net/tag/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richardbushnell.net</link>
	<description></description>
	<lastBuildDate>Wed, 30 Dec 2009 11:42:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Remove and Sort Those Ugly &#8220;using-Statements&#8221;</title>
		<link>http://www.richardbushnell.net/2008/03/03/remove-and-sort-those-ugly-using-statements/</link>
		<comments>http://www.richardbushnell.net/2008/03/03/remove-and-sort-those-ugly-using-statements/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 08:10:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C# 3.0]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Commands]]></category>
		<category><![CDATA[PowerCommands]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/03/03/remove-and-sort-those-ugly-using-statements/</guid>
		<description><![CDATA[Visual Studio 2008 has lots of goodies in it, like LINQ syntax, CSS editing, and testing tools. There&#8217;s a lesser-known feature which I really appreciate though &#8211; the &#8220;Remove and Sort Usings&#8221; command in the C# editor. You activate the command by placing your cursor over the using statements and clicking on the right mouse-button. [...]]]></description>
			<content:encoded><![CDATA[
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F03%2F03%2Fremove-and-sort-those-ugly-using-statements%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<br><p>Visual Studio 2008 has lots of goodies in it, like LINQ syntax, CSS editing, and testing tools. There&#8217;s a lesser-known feature which I really appreciate though &#8211; the &#8220;Remove and Sort Usings&#8221; command in the C# editor.</p>
<p>You activate the command by placing your cursor over the using statements and clicking on the right mouse-button.</p>
<p><a href="http://www.richardbushnell.net/wp-content/uploads/2008/03/image2.png"><img src="http://www.richardbushnell.net/wp-content/uploads/2008/03/image-thumb.png" style="border: 0px none " alt="image" border="0" height="411" width="488" /></a></p>
<p><span id="more-65"></span></p>
<p>Using this groovy tool, I&#8217;ve been able to go through my old ugly C# files and get rid of all the superfluous using statements, then tidy them up, all at the click of a button. It&#8217;s something I always wanted to do, but had no time for, and didn&#8217;t want to pay for an extra tool to do it for me.</p>
<p>The <em>only </em>problem with the feature is that you have to go through every file and right-click on the &#8220;using&#8221; statements to tidy them up. That can get a bit tedious, but it&#8217;s worth it.</p>
<p>But now it&#8217;s the Visual Studio Extensibility Team to the rescue!</p>
<p>The VSX team at Microsoft have just released <a href="http://www.visualstudiogallery.com/ExtensionDetails.aspx?ExtensionID=df3f0c30-3d37-4e06-9ef8-3bff3508be31">PowerCommands for Visual Studio 2008</a>. It&#8217;s a free tool for Visual Studio with loads of new tools for making a VS-developer&#8217;s life easier. And one of those new tools is a Remove and Sort Usings command at the project level.</p>
<p>You activate it with a right-click on the project itself.</p>
<p><a href="http://www.richardbushnell.net/wp-content/uploads/2008/03/image3.png"><img src="http://www.richardbushnell.net/wp-content/uploads/2008/03/image-thumb1.png" style="border: 0px none ; margin: 0pt 140px 0pt 0pt" alt="image" border="0" height="288" width="357" /></a></p>
<p>The tool then does the same Remove and Sort command for every file in the project.</p>
<p><strong>Tip: </strong>Make sure your project is buildable before using the tool. If there is an error stopping the build from running, you will get dialogs asking you to confirm every change in every file.</p>
<p>PowerCommands for Visual Studio 2008 also contains commands for:</p>
<ul>
<li>Collapse Projects</li>
<li>Copy Class</li>
<li>Paste Class</li>
<li>Copy References</li>
<li>Paste References</li>
<li>Copy As Project Reference</li>
<li>Edit Project File</li>
<li>Open Containing Folder</li>
<li>Open Command Prompt</li>
<li>Unload Projects</li>
<li>Reload Projects</li>
<li>Remove and Sort Usings</li>
<li>Extract Constant</li>
<li>Clear Recent File List</li>
<li>Clear Recent Project List</li>
<li>Transform Templates</li>
<li>Close All</li>
</ul>
<p>So, where can you get the tool?</p>
<p>The official site for PowerCommands is at the <a href="http://www.visualstudiogallery.com/ExtensionDetails.aspx?ExtensionID=df3f0c30-3d37-4e06-9ef8-3bff3508be31">Visual Studio Gallery</a>, but when you get there, you won&#8217;t see a download button. You actually have to click the &#8220;Learn More&#8221; button to go to the <a href="http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=PowerCommands&amp;ReleaseId=559.">download page at the MSDN code gallery</a>.</p>
<p>You can read more about PowerCommands on the <a href="http://blogs.msdn.com/vsxteam/archive/2008/02/29/PowerCommands-for-Visual-Studio-2008-released.aspx">Visual Studio Team Extensibility blog</a>.</p>

<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F03%2F03%2Fremove-and-sort-those-ugly-using-statements%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
]]></content:encoded>
			<wfw:commentRss>http://www.richardbushnell.net/2008/03/03/remove-and-sort-those-ugly-using-statements/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Writing Custom Exception Classes the Quick Way</title>
		<link>http://www.richardbushnell.net/2008/02/15/writing-custom-exception-classes-the-quick-way/</link>
		<comments>http://www.richardbushnell.net/2008/02/15/writing-custom-exception-classes-the-quick-way/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 16:00:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C# 2.0]]></category>
		<category><![CDATA[C# 3.0]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/02/15/writing-custom-exception-classes-the-quick-way/</guid>
		<description><![CDATA[Until recently I thought this was a well-known feature. After demonstrating it a few times, I found out it wasn&#8217;t. A long time ago, in an cubicle far, far away, someone created the .Net Framework. To cut a long story short, they simultaneously produced guidelines for creating Exception classes, which you should always use or [...]]]></description>
			<content:encoded><![CDATA[
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F02%2F15%2Fwriting-custom-exception-classes-the-quick-way%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<br><p>Until recently I thought this was a well-known feature. After demonstrating it a few times, I found out it wasn&#8217;t.</p>
<p>A long time ago, in an cubicle far, far away, someone created the .Net Framework. To cut a long story short, they simultaneously produced guidelines for creating Exception classes, which you should always use or face having your fingernails pulled out with a staple-gun.</p>
<p>The guidelines state:</p>
<blockquote>
<p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Arial','sans-serif'">&#8220;Use the common constructors shown in the following code example when creating exception classes. &#8220;<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">[C#]<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">public</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">class</span> XxxException : ApplicationException<br />
</span><span style="font-size: 10pt; font-family: 'Courier New'">{<br />
</span><span style="font-size: 10pt; font-family: 'Courier New'"><span>   </span><span style="color: blue">public</span> XxxException() {&#8230; }<br />
</span><span style="font-size: 10pt; font-family: 'Courier New'"><span>   </span><span style="color: blue">public</span> XxxException(<span style="color: blue">string</span> message) {&#8230; }<br />
</span><span style="font-size: 10pt; font-family: 'Courier New'"><span>   </span><span style="color: blue">public</span> XxxException(<span style="color: blue">string</span> message, Exception inner) {&#8230; }<br />
</span><span style="font-size: 10pt; font-family: 'Courier New'"><span>   </span><span style="color: blue">public</span> XxxException(SerializationInfo info, StreamingContext context) {&#8230;}<br />
</span><span style="font-size: 10pt; font-family: 'Courier New'">}<o:p></o:p></span></p></blockquote>
<p><span id="more-53"></span><br />
If you don&#8217;t believe me, you can look here:</p>
<p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp" title="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp</a></p>
<p>Now, I don&#8217;t know about you, but I can&#8217;t remember all that every time I create a custom exception class. Maybe that&#8217;s why the guidelines also state:</p>
<blockquote><p>In most cases, use the predefined exception types. Only define new exception types for programmatic scenarios, where you expect users of your class library to catch exceptions of this new type and perform a programmatic action based on the exception type itself.</p></blockquote>
<p>But let&#8217;s ignore that. It&#8217;s not relevant.</p>
<p>So, <em>did you know</em> that there is a Visual Studio code snippet that does the work for you? Here&#8217;s how you use it.</p>
<ol>
<li>Create a new class.</li>
<li>inside the namespace definition of the new class, type
<pre class="code">Exception</pre>
<p><a href="http://11011.net/software/vspaste"></a></li>
<li>Press the tab key twice.</li>
</ol>
<p>You then get the following code, free of charge:</p>
<pre class="code">[<span style="color: blue">global</span>::System.<span style="color: #2b91af">Serializable</span>]
<span style="color: blue">public class </span><span style="color: #2b91af">MyException </span>: <span style="color: #2b91af">Exception </span>{
<span style="color: green">
  </span><span style="color: blue">public </span>MyException() { }
  <span style="color: blue">public </span>MyException(<span style="color: blue">string </span>message) : <span style="color: blue">base</span>(message) { }
  <span style="color: blue">public </span>MyException(<span style="color: blue">string </span>message, <span style="color: #2b91af">Exception </span>inner) : <span style="color: blue">base</span>(message, inner) { }
  <span style="color: blue">protected </span>MyException(
  System.Runtime.Serialization.<span style="color: #2b91af">SerializationInfo </span>info,
  System.Runtime.Serialization.<span style="color: #2b91af">StreamingContext </span>context)
    : <span style="color: blue">base</span>(info, context) { }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>What&#8217;s more, you get code snippet functionality which automatically changes the names of all the constructors when you change the name of the class.</p>
<p>I wonder what other code snippets are available. Do you know of any cool ones? What are your favorites?</p>

<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F02%2F15%2Fwriting-custom-exception-classes-the-quick-way%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
]]></content:encoded>
			<wfw:commentRss>http://www.richardbushnell.net/2008/02/15/writing-custom-exception-classes-the-quick-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>.Net Source Code Now Available</title>
		<link>http://www.richardbushnell.net/2008/01/17/net-source-code-now-available/</link>
		<comments>http://www.richardbushnell.net/2008/01/17/net-source-code-now-available/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 07:54:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[scott guthrie]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/01/17/net-source-code-now-available/</guid>
		<description><![CDATA[Scott Guthrie has just announced that the source code for the .Net framework has just been made available for reference use. It will be particularly useful to see how the controls in ASP.Net and Windows Forms have been done. Detailed instructions for how to set it up are here. One caveat: it&#8217;s not available for [...]]]></description>
			<content:encoded><![CDATA[
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F01%2F17%2Fnet-source-code-now-available%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<br><p><a href="http://weblogs.asp.net/scottgu" target="_blank">Scott Guthrie</a> has just announced that the source code for the .Net framework has <a href="http://weblogs.asp.net/scottgu/archive/2008/01/16/net-framework-library-source-code-now-available.aspx" target="_blank">just been made available for reference use</a>.</p>
<p>It will be particularly useful to see how the controls in ASP.Net and Windows Forms have been done.</p>
<p>Detailed instructions for how to set it up are <a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx" target="_blank">here</a>.</p>
<p>One caveat: it&#8217;s not available for the Express editions of Visual Studio. Shame! I was just starting to have some fun with them too.</p>

<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F01%2F17%2Fnet-source-code-now-available%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
]]></content:encoded>
			<wfw:commentRss>http://www.richardbushnell.net/2008/01/17/net-source-code-now-available/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

