<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Humblecoder</title>
	
	<link>http://www.humblecoder.co.uk</link>
	<description>Apprentice unit tester, expert rambler</description>
	<lastBuildDate>Mon, 09 Aug 2010 10:51:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Humblecoder" /><feedburner:info uri="humblecoder" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Stop TFS From Telling You “Windows Live Messenger is not running”</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/BST1BTm-Aqg/</link>
		<comments>http://www.humblecoder.co.uk/?p=148#comments</comments>
		<pubDate>Mon, 09 Aug 2010 10:51:23 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=148</guid>
		<description><![CDATA[I’ve recently stopped using Live Messenger (moved to Pidgin) and one unexpected side effect of switching was TFS reminding me every time I went to Team Explorer that Messenger isn’t running with this lovely error message:

For the past few weeks I’ve been living with it, but it’s becoming increasingly annoying.&#160; So today I finally worked [...]<p><a href="http://www.humblecoder.co.uk/?p=148">Stop TFS From Telling You &ldquo;Windows Live Messenger is not running&rdquo;</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I’ve recently stopped using Live Messenger (moved to Pidgin) and one unexpected side effect of switching was TFS reminding me every time I went to Team Explorer that Messenger isn’t running with this lovely error message:</p>
<p><a href="http://www.humblecoder.co.uk/wp-content/uploads/2010/08/image.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" class="wlDisabledImage" title="image" border="0" alt="image" src="http://www.humblecoder.co.uk/wp-content/uploads/2010/08/image_thumb.png" width="357" height="198" /></a></p>
<p>For the past few weeks I’ve been living with it, but it’s becoming increasingly annoying.&#160; So today I finally worked out how to stop it:</p>
<ol>
<li>Go to the Team Members item in Team Explorer and right click on it</li>
<li>Select <em>Personal Settings </em></li>
<li>On the dialog there is a Collaboration setting, change the provider to <em>None</em></li>
<li>Be free of annoying dialog.</li>
</ol>
<p>Hope this helps some else regain their sanity <img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.humblecoder.co.uk/wp-content/uploads/2010/08/wlEmoticonsmile.png" /></p>
<p><a href="http://www.humblecoder.co.uk/?p=148">Stop TFS From Telling You &ldquo;Windows Live Messenger is not running&rdquo;</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/BST1BTm-Aqg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=148</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=148</feedburner:origLink></item>
		<item>
		<title>Multiple Asserts</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/nOqIr5FLL3s/</link>
		<comments>http://www.humblecoder.co.uk/?p=143#comments</comments>
		<pubDate>Tue, 01 Jun 2010 16:31:09 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[nUnit]]></category>
		<category><![CDATA[OAPT]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=143</guid>
		<description><![CDATA[I’ve read many books and blogs that advocate only having one assert in a unit test and lots of people take that to mean literally assert statement.&#160; I’ve always disagreed with taking it literally, I’ve always thought of it as one logical assert, as in you assert one concept at a time which could lead [...]<p><a href="http://www.humblecoder.co.uk/?p=143">Multiple Asserts</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I’ve read many books and blogs that advocate only having one assert in a unit test and lots of people take that to mean literally assert statement.&#160; I’ve always disagreed with taking it literally, I’ve always thought of it as one logical assert, as in you assert one concept at a time which could lead to multiple assert statements. </p>
<p>The main arguments against having more than one assert statement seems to be it’s not as readable and it’s sometimes difficult to understand what is failing because of it.&#160; My normal response is to create my own asserts that accurately describe what the multiple asserts do and hide the real asserts in there.&#160; For example: </p>
<div id="codeSnippetWrapper">&#160;</div>
<div>
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> AssertIsValidClone(Customer oldCustomer, Customer actualCustomer)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     Assert.AreNotSame(oldCustomer, actualCustomer);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     StringAssert.AreEqual(oldCustomer.Name, actualCustomer.Name);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     StringAssert.AreEqual(oldCustomer.Address, actualCustomer.Address);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> [Test]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Clone_ValidCustomer_ValuesAreTheSameReferenceIsDifferent()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>     <span style="color: #008000">//Some setup</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>     var result = aCustomer.Clone();</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>     AssertIsValidClone(aCustomer, result);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span>     </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>&#160;</p>
<p>Ok so this is a very contrived example but we can clearly see what the intent of the assert is rather than having several making it harder to understand.&#160; But what this doesn’t do is address the second concern. IE anyone of those three asserts could fail, so we fix it then the next fails, etc.</p>
<p>Enter an nUnit plug in called <a href="http://rauchy.net/oapt/" target="_blank">OAPT</a>, this allows you to have multi asserts that generate multi unit tests in the runner so you can see exactly what is failing.&#160; I won’t warble on too much about the details because it’s all in the link But let’s just rewrite our unit test:</p>
<p>&#160;</p>
<div id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [Test, ForEachAssert]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Clone_ValidCustomer_CloneIsNewItemWithValidData()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     <span style="color: #008000">//some setup</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     var newCustomer = originalCustomer.Clone();</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>     AssertOne.From(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         () =&gt; Assert.AreNotSame(originalCustomer, newCustomer)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>         () =&gt; StringAssert.AreEqual(originalCustomer.Name, newCustomer.Name)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>         () =&gt; StringAssert.AreEqual(originalCustomer.Address, newCustomer.Address));</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>&#160;</p>
<p>Much more concise and it will run as three separate tests.&#160; I still do have an issue with it though, each test uses the test name with an appended number. It would be nice if you could pass in some text for it to append.&#160; But then again it is open source so maybe I could add that feature myself <img src='http://www.humblecoder.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.humblecoder.co.uk/?p=143">Multiple Asserts</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/nOqIr5FLL3s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=143</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=143</feedburner:origLink></item>
		<item>
		<title>Directory Linker 2.1 – XP Support</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/GMbwFAqiAb4/</link>
		<comments>http://www.humblecoder.co.uk/?p=142#comments</comments>
		<pubDate>Wed, 05 May 2010 06:23:13 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Directory Linker]]></category>
		<category><![CDATA[DirLinker]]></category>
		<category><![CDATA[Reparse points]]></category>
		<category><![CDATA[Symbolic Links]]></category>
		<category><![CDATA[XP]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=142</guid>
		<description><![CDATA[Today I have pushed new binaries to CodePlex for DirLinker.&#160; This new release brings support for folder links in Windows XP/2003.&#160; It is not able to create file links, this is because of the limitations in reparse points in earlier versions of Windows.
This is something I didn’t think I would do but after releasing Dirlinker [...]<p><a href="http://www.humblecoder.co.uk/?p=142">Directory Linker 2.1 &ndash; XP Support</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Today I have pushed new binaries to <a href="http://dirlinker.codeplex.com">CodePlex for DirLinker</a>.&#160; This new release brings support for folder links in Windows XP/2003.&#160; It is not able to create file links, this is because of the limitations in reparse points in earlier versions of Windows.</p>
<p>This is something I didn’t think I would do but after releasing Dirlinker 2 on Codeplex, a ticket was raised in the bug tracker because it was failing on XP and I was chatting to a friend on IM about it who basically said “Well why doesn’t it?”.&#160; The main reason was because the API call for creating symbolic links is only available in Vista and later.&#160; XP does have an equivalent but the behaviour of the links they create is subtly different.&#160; In XP they are Reparse Points where as in Vista+ they are hard links (similar to *nix), I will go in to the difference in a future post.</p>
<p>It turns out that with a little help from <a href="http://www.codeproject.com/KB/files/JunctionPointsNet.aspx">a CodeProject article</a>, it took less than an hour to put in and test, so it made it in.&#160; I am definitely parking this to new features now.&#160; Only bug fixes will be added from now on.</p>
<p><a href="http://www.humblecoder.co.uk/?p=142">Directory Linker 2.1 &ndash; XP Support</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/GMbwFAqiAb4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=142</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=142</feedburner:origLink></item>
		<item>
		<title>Directory Linker 2</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/YwTBd2D2c80/</link>
		<comments>http://www.humblecoder.co.uk/?p=141#comments</comments>
		<pubDate>Mon, 03 May 2010 07:14:50 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CodePlex]]></category>
		<category><![CDATA[Directory Linker]]></category>
		<category><![CDATA[DirLinker]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=141</guid>
		<description><![CDATA[After literally months of procrastination Directory Linker 2 is finally in state that I’m not too ashamed of.&#160; So today I have posted up new binaries on Codeplex.
What’s New?

Undo Support&#160;– If the process of moving and deleting a folder before creating a link at the same location failed, you could end up with some files [...]<p><a href="http://www.humblecoder.co.uk/?p=141">Directory Linker 2</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>After literally months of procrastination Directory Linker 2 is finally in state that I’m not too ashamed of.&#160; So today I have posted up <a href="http://dirlinker.codeplex.com">new binaries on Codeplex</a>.</p>
<h3><strong>What’s New?</strong></h3>
<ul>
<li><strong>Undo Support</strong>&#160;<strong>–</strong> If the process of moving and deleting a folder before creating a link at the same location failed, you could end up with some files in the new location, some in old and two partial directory structures.&#160; If this happens now DirLinker will offer to put the original folder back how it was.      </p>
<p>If you’re using the just delete option and it fails, undo <strong>can not</strong> undelete any files but it will put back any folders it deleted.</li>
<li><strong>File Links</strong> – It can now create symbolic links for files as well as directories.&#160; You don’t have to do anything different, just select a file in the link location or the link to field.&#160; There has been a small change to the UI to allow you to browse for files aswell as folders.
<p>In a future post I’m going to talk about the difference between symbolic links and shortcuts.&#160; But for now the important difference is the application opening file doesn’t know the file is only a link when using symbolic links. </li>
<li><strong>Progress Window Changes – </strong>The progress window has been slightly overhaul and now keeps a list of everything it has done.&#160; So if it does fail or something goes wrong, you can work out exactly what it’s done.</li>
</ul>
<p><a href="http://www.humblecoder.co.uk/wp-content/DirectoryLinker2_AE58/progressWindow.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="Progress Window" border="0" alt="Progress Window" src="http://www.humblecoder.co.uk/wp-content/DirectoryLinker2_AE58/progressWindow_thumb.png" width="616" height="299" /></a></p>
<p>With these features I’m planning on parking Directory Linker development, I will of course fix any bugs that may come up but I can’t see any new features being added.</p>
<p>Enjoy!</p>
<p>PS, If you have no idea what Directory Linker is, <a href="http://www.humblecoder.co.uk/?p=50">this is</a> a good place to start.</p>
<p><a href="http://www.humblecoder.co.uk/?p=141">Directory Linker 2</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/YwTBd2D2c80" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=141</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=141</feedburner:origLink></item>
		<item>
		<title>Visual Studio Versions || .Net Versions != C# Version</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/BgAEQzb_1jM/</link>
		<comments>http://www.humblecoder.co.uk/?p=137#comments</comments>
		<pubDate>Sun, 18 Apr 2010 09:47:35 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=137</guid>
		<description><![CDATA[**Update** Generic variance can be used (and a couple of other things) when multi targeting see here: http://blogs.msdn.com/ed_maurer/archive/2010/03/31/multi-targeting-and-the-c-and-vb-compilers.aspx
I’m finally getting stuck into finishing off DirLinker 2.0 and with VS2010 being released I decided to upgrade the project to VS2010 still targeting .NET 3.5 for compatibility.&#160; While enjoying the new IDE features, I discovered some of [...]<p><a href="http://www.humblecoder.co.uk/?p=137">Visual Studio Versions || .Net Versions != C# Version</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>**Update** Generic variance can be used (and a couple of other things) when multi targeting see here: <a href="http://blogs.msdn.com/ed_maurer/archive/2010/03/31/multi-targeting-and-the-c-and-vb-compilers.aspx">http://blogs.msdn.com/ed_maurer/archive/2010/03/31/multi-targeting-and-the-c-and-vb-compilers.aspx</a></p>
<p>I’m finally getting stuck into finishing off <a href="http://dirlinker.codeplex.com">DirLinker</a> 2.0 and with VS2010 being released I decided to upgrade the project to VS2010 still targeting .NET 3.5 for compatibility.&#160; While enjoying the new IDE features, I discovered some of the C# 4.0 features work when targeting .NET 3.5.&#160; </p>
<h3></h3>
<h3><strong>Optional and Named Parameters</strong></h3>
<p>This is something I’ve been looking forward to, I think it will make my code prettier by removing the ridiculous number of overloads you can some times end up with.&#160; I’m not going to explain the feature because it has been well covered by better writers than I <img src='http://www.humblecoder.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .&#160; So imagine my surprise when I discovered I could use this feature while targeting .NET 3.5.&#160; Just to test the theory I wrote the following console application and targeted it at .NET 2.0:</p>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:fcb380f1-6afa-46d8-8195-431913aa9e67" class="wlWriterEditableSmartContent">
<pre name="code" class="c#">static void Main(string[] args)
{
    FunctionCalledUsingNamedParams("str1", "str2");
    FunctionCalledUsingNamedParams(String2: "str2", string1: "str1");

    FunctionWithTwoOptionalParams();
    FunctionWithTwoOptionalParams(200);
    FunctionWithTwoOptionalParams(56, "Called from main");
    FunctionWithTwoOptionalParams(message: "test", number: 29);

    Console.ReadKey();
}

static void FunctionCalledUsingNamedParams(String string1, String String2)
{
    Console.WriteLine(String.Format("{0} : {1}", string1, String2));
}

static void FunctionWithTwoOptionalParams(Int32 number = 1, String message = "default message")
{
    Console.WriteLine(String.Format("{0}: {1}", message, number));
}</pre>
</div>
<p>This compiles, runs and outputs the correct information just fine.&#160; I even ran it to a machine that had never seen .NET 4.0 to be sure.&#160; It would appear it’s C# 4.0 feature not a .NET 4.0 feature.&#160; I have only tried this with optional params but I doubt that dynamic <strike>and co/contra-variance will work</strike>, I think the general rule is if it doesn&#8217;t require the Base Class Library or CLR support then it will work. </p>
<p>(The source for app along with a compiled version is available <a href="http://bitbucket.org/humblecoder/BlogPostCode/">here</a> )</p>
<h3><strong>Of Course This is Not New </strong></h3>
<p>Within the past 12 months my work place has moved to VS2008 from VS2005 but still targeting .NET 2.0.&#160; One of the things I quickly discovered was that lambdas, auto properties and&#160; object initialization syntax all still works perfectly when targeting .NET 2.0 from VS2008.&#160; Making them a feature of C# 3.0 not .NET 3.5!&#160; </p>
<p>So it’s important to remember this simple expression:</p>
<p align="center"><strong><font size="4">Visual Studio Version || .Net Version != C# Version</font></strong></p>
<p><a href="http://www.humblecoder.co.uk/?p=137">Visual Studio Versions || .Net Versions != C# Version</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/BgAEQzb_1jM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=137</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=137</feedburner:origLink></item>
		<item>
		<title>Why Can’t TFS Remember My Credentials?!</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/fq5o35yUyM8/</link>
		<comments>http://www.humblecoder.co.uk/?p=132#comments</comments>
		<pubDate>Mon, 29 Mar 2010 12:45:09 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Frustration]]></category>
		<category><![CDATA[TFS]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=132</guid>
		<description><![CDATA[At the office we use TFS and it pesters me for credentials every time I start  Visual Studio because I’m not on the domain.  This does quickly become very  tiresome.
Solution
I set about trying to cache my credentials this morning after, mixed with a  case of the Mondays, I’d finally had enough with [...]<p><a href="http://www.humblecoder.co.uk/?p=132">Why Can’t TFS Remember My Credentials?!</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>At the office we use TFS and it pesters me for credentials every time I start  Visual Studio because I’m not on the domain.  This does quickly become very  tiresome.</p>
<h3><strong>Solution</strong></h3>
<p>I set about trying to cache my credentials this morning after, mixed with a  case of the Mondays, I’d finally had enough with it pestering me.  The dialog  does not have any <em>remember my password option</em> so the next stop is to save it in  my Windows Profile.  To do this:</p>
<ol>
<li>Open “Control Panel”</li>
<li>Go to “User Accounts” and select the option “Manage your network passwords”</li>
<li>In the dialog enter the path to your TFS server and your credentials, for  example</li>
</ol>
<p><a href="http://www.humblecoder.co.uk/wp-content/uploads/2010/03/AddNetworkPassword1.png"><img class="aligncenter size-medium wp-image-133" title="Add Network Password" src="http://www.humblecoder.co.uk/wp-content/uploads/2010/03/AddNetworkPassword1-271x300.png" alt="Add Network Password" width="271" height="300" /></a></p>
<p>This worked great for Visual Studio but I still had to log into the TFS  Sharepoint portal site every time.  I discovered you also have to enter the TFS  server address into the “Intranet Zone” in “Internet Options”.  To do this:</p>
<ol>
<li>Open “Control Panel”</li>
<li>Go To “Internet Options” and select the “Security” tab</li>
<li>Then select “Intranet Zone” and click on the “Sites” option</li>
<li>Now enter the address of the TFS server, for example:</li>
</ol>
<p><a href="http://www.humblecoder.co.uk/wp-content/uploads/2010/03/intranetZone1.png"><img class="aligncenter size-medium wp-image-134" title="Intranet Zone" src="http://www.humblecoder.co.uk/wp-content/uploads/2010/03/intranetZone1-300x196.png" alt="Intranet Zone" width="300" height="196" /></a></p>
<p>Then you should never be harassed again <img src='http://www.humblecoder.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   This works / is needed on Sever  2008 and Vista, as per usual the story is a lot better under Win 7 and Server  2008 R2.  It’s just a shame my main development VM is 2008 and I don’t have time  to reimage it.</p>
<p><a href="http://www.humblecoder.co.uk/?p=132">Why Can’t TFS Remember My Credentials?!</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/fq5o35yUyM8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=132</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=132</feedburner:origLink></item>
		<item>
		<title>OCInject Release 2</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/RZifSIGdCwc/</link>
		<comments>http://www.humblecoder.co.uk/?p=128#comments</comments>
		<pubDate>Mon, 22 Mar 2010 10:00:02 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[OCInject]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=128</guid>
		<description><![CDATA[When I originally released OCInject I omitted one important feature, lifestyle management.&#160; This coupled with the release of a feature full TinyIOC has made me re-evaluate my position on not adding too many features to OCInject.&#160; Release 2 of OCinject brings the following features:

Life style management – It’s possible to register types as singletons or [...]<p><a href="http://www.humblecoder.co.uk/?p=128">OCInject Release 2</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>When I originally <a href="http://www.humblecoder.co.uk/?p=102">released OCInject</a> I omitted one important feature, lifestyle management.&#160; This coupled with the release of a <a href="http://www.grumpydev.com/2010/03/02/announcing-tinyioc-an-easy-to-use-hassle-free-inversion-of-control-container/">feature full TinyIOC</a> has made me re-evaluate my position on not adding too many features to OCInject.&#160; Release 2 of OCinject brings the following features:</p>
<ul>
<li><strong><a href="#lifes">Life style management</a></strong> – It’s possible to register types as singletons or instance </li>
<li><strong><a href="#FuncT">Func&lt;T&gt; factories</a></strong> – OCInject from day one supported delegate factories, now you can use Func&lt;TContract&gt; instead of typed delegates </li>
<li><strong><a href="#Simple">Simplified Registrations </a>– </strong>In the previous release of OCInject types are registered using TContract –&gt; TImplemenation to enforce programming to interface.&#160; It’s now possible to register with TContract as the concrete type with one call </li>
<li><strong><strong><a href="#large">Largest Resolvable Constructor</a></strong> – </strong>In the previous release of OCInject it simply grabbed the first constructor it found.&#160; It will now select the greediest constructor it can resolve.&#160; It makes the assumption that <em>any known types are resolvable</em>, for performance reasons. </li>
<li><a href="#unresolve"><strong>Unresolveable Callback</strong></a><strong> – </strong>It is now possible to supply a call back function if the container can’t resolve a type. </li>
<li><strong><a href="#child">Child Container Support</a> – </strong>OCInject can create child containers that call back to the parent for any unknown types.&#160; </li>
</ul>
<p>The latest stable version can be downloaded from <a href="http://ocinject.codeplex.com">Codeplex</a> and all stableish development releases can be found at <a href="http://bitbucket.org/humblecoder/ocinject">BitBucket</a>.</p>
<h3></h3>
<h3><strong>Future Features</strong></h3>
<p>One major feature still missing from OCInject is named registrations.&#160; This is because I personally dislike ‘magic strings’, with this in mind a planned future feature of OCInject is factory delegate registration only.&#160; Also, auto generated factories from interfaces.&#160; More to come on this in a future post.</p>
<div id="lifes">
<h3><strong>Life Style Management</strong></h3>
</p></div>
<p>By default all types registered with the OCInject container are transient. You can register a type as singleton in two ways.&#160; The first method is to use <em>.AsSingleton() </em>this will cause the object to be created the first time it is requested.&#160; The second method is to use <em>.AlwaysReturnObject(obj), </em>this will return the instance you specified.&#160;&#160; When using either method, if the type implements IDisposable it will be disposed when the container is.&#160; Usage example:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:a20484ae-26e2-409a-a51b-0e62c9ae9b85" class="wlWriterEditableSmartContent">
<pre name="code" class="c#">ClassFactory container = new ClassFactory();

//Normal Singleton
container.RegisterType&lt;TestClass&gt;()
           .AsSingleton();

//Preconstructed Singleton
AnotherClass instanceOfAClass = new AnotherClass();

container.RegisterType&lt;TestClass&gt;()
         .AlwaysReturnObject(instanceOfAClass);
</pre>
</div>
<div id="FuncT">
<h3><strong>Func&lt;T&gt; Factories</strong></h3>
</div>
<p>When resolving constructors if OCInject discovers a Func&lt;T&gt; where T is a registered type, it will pass in a func to create the type.&#160; This uses the standard container resolve, so if T is a singleton you will always get the same instance when the factory is called. Usage example:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:1b76c700-0653-4975-aa04-55aa803a518e" class="wlWriterEditableSmartContent">
<pre name="code" class="c#">class FuncConsumer
{
	public FuncConsumer(Func&lt;TestClass&gt; factory)
	{
	}
}

ClassFactory container = new ClassFactory();

container.RegisterType&lt;FuncConsumer&gt;();
container.RegisterType&lt;TestClass&gt;();

//Successfully created with the ability to create TestClass
FuncConsumer f = container.ManufactureType&lt;FuncConsumer&gt;();</pre>
</div>
<div id="simple">
<h3><strong>Simplified Registrations </strong></h3>
</div>
<p>Registrations no longer require the separation of contract and implement so just an implementation can be registered.&#160; Usage example: </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:72e25bbe-0a36-4369-a244-9d3dda8f34d9" class="wlWriterEditableSmartContent">
<pre name="code" class="c#">ClassFactory container = new ClassFactory();

container.RegisterType&lt;TestClass&gt;();

var t = container.ManufactureType&lt;TestClass&gt;();</pre>
</div>
<div id="large">
<h3><strong>Largest Resolvable Constructor</strong></h3>
</div>
<p>This is quite a complicated area that is worthy of a blog post itself but OCInject’s behaviour has changed.&#160; When creating a type the constructors are ordered so the largest, in terms of parameters, is first.&#160; It then looks at each parameter and to see if it can resolve it, first by checking ‘resolve time args’ (values passed in when the resolve is requested, normally from generated factories) then by seeing if the type is a registered contract within the container.&#160;&#160; <strong>It does not check if the type can be created just that it knows about it, if it’s registered it assumes it can be created.</strong></p>
<p>The first completely resolvable constructor will be used to construct the type.</p>
<div id="Unresolve">
<h3><strong>Unresolveable Callback</strong> </h3>
</div>
<p>If the container is unable to resolve the type you can now register a function that is called before the container throws an exception.&#160; To do this you need register a <em>Func&lt;Object, Type&gt;</em> with the <em>CallToResolve </em>propriety.&#160; Returning null will cause the container to throw an exception.&#160; Usage example:</p>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:b062eccc-fbe4-4fbd-a066-531fb5ea93c0" class="wlWriterEditableSmartContent">
<pre name="code" class="c#">ClassFactory container = new ClassFactory();

container.CallToResolve = (type) =&gt; { return new TestClass(); };

ITestClass manufacturedType = factory.ManufactureType&lt;ITestClass&gt;();
</pre>
</div>
<div id="child">
<h3><strong>Child Container Support</strong></h3>
</div>
<p>Calling <em>CreateChildContainer() </em>will return a new <em>ClassFactory </em>object with no registrations but a link back to the parent.&#160; If a type is not known to the child it will ask the parent to fulfil the request.&#160; Any registrations with the child will not effect the parent and singletons registered with the child will be disposed when it is. Usage example:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:24c8160b-ef8a-4c19-8e86-f49a94d52ab8" class="wlWriterEditableSmartContent">
<pre name="code" class="c#">ClassFactory container = new ClassFactory();
ClassFactory child = factory.CreateChildContainer();</pre>
</div>
<p><a href="http://www.humblecoder.co.uk/?p=128">OCInject Release 2</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/RZifSIGdCwc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=128</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=128</feedburner:origLink></item>
		<item>
		<title>"hg push -b default" is Massively Handy</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/10Lx87Z9j-8/</link>
		<comments>http://www.humblecoder.co.uk/?p=127#comments</comments>
		<pubDate>Mon, 22 Mar 2010 06:56:53 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[branching]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[Mercurial]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=127</guid>
		<description><![CDATA[A little while ago I wrote a quick start guide to branching in Mercurial and, as is normally the case when you don’t actively follow development, Mercurial 1.5 has been released with a lovely new feature which impacts working with branches.&#160; 
My biggest annoyance when working with branches is by default all branches are pushed/pulled [...]<p><a href="http://www.humblecoder.co.uk/?p=127">&quot;hg push -b default&quot; is Massively Handy</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>A little while ago I wrote a <a href=" http://www.humblecoder.co.uk/?p=113">quick start guide to branching in Mercurial</a> and, as is normally the case when you don’t actively follow development, Mercurial 1.5 has been released with a lovely new feature which impacts working with branches.&#160; </p>
<p>My biggest annoyance when working with branches is by default <strong>all</strong> branches are pushed/pulled to the remote repository.&#160; When in reality, I often want to just push the branch I’m currently on.&#160; Mercurial addressed this by adding a branch only option to Push, Pull, Clone, Incoming and Outgoing.&#160; To use the branch only option you append –<em>b </em>to the command followed by the branch name, for example: </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:1e9a42d9-65fa-4fc7-9d81-b4c6b3340ca0" class="wlWriterEditableSmartContent">
<pre name="code" class="xml">hg push -b default</pre>
</div>
<p>This will only push the default branch back to where the repository was cloned from (You can still specify a location to push to if required.)&#160; This works exactly the same for all the other commands.</p>
<p>A handy shortcut to push the current branch is use ‘.’ as the branch name: </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:0a98a4a8-f42b-4c6a-8a6d-6a21865f1649" class="wlWriterEditableSmartContent">
<pre name="code" class="xml">-b .</pre>
</div>
<h3></h3>
</p>
<p><strong></strong></p>
<p>This will perform the command only to the branch you’re currently on.&#160; Since I tend to push more than I do most of the others, I have set up an alias to map push current branch to <em>pc.&#160; </em>You can do this by adding a section to your <a href="http://www.selenic.com/mercurial/hgrc.5.html">hgrc</a> like:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:55d75568-3d15-4e49-9843-ada73acc1931" class="wlWriterEditableSmartContent">
<pre name="code" class="xml">[alias]
pc = push -b .</pre>
</div>
<h3><strong>Branching Without Having It In Your History</strong></h3>
<p>Cloning locally has always been an option to create a branch or fork of the code that is still linked to the original code base, IE you can push and pull to it, but it doesn’t become part of your history in the other repo unless you pushed it back.&#160; But I’ve never liked it because it takes a copy of everything and sets the current branch to the default branch.&#160; Trivial, maybe, but not something I found desirable.</p>
<p>The new branch options makes cloning locally a lot more attractive to me.&#160; It means I can just clone a branch, make a quick change or two and either merge it back in or delete the directory and pretend I never had that idea!</p>
<h3><strong></strong></h3>
<h3><strong>Powershell and Mercurial</strong></h3>
</p>
<p>As part of my continuous improvement I’ve been learning PowerShell.&#160; One way I’ve done this is by replacing all my cmd.exe usage with the PowerShell prompt instead.&#160; This led me to discover an excellent cmd-let (script or whatever the proper name is, I’m still learning <img src='http://www.humblecoder.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) to display the name of the current branch and status of it when you’re in a Mercurial repository.&#160; It looks like:</p>
<p><a href="http://www.humblecoder.co.uk/wp-content/uploads/2010/03/ps.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Powershell Status Display" border="0" alt="Powershell Status Display" src="http://www.humblecoder.co.uk/wp-content/uploads/2010/03/ps_thumb.png" width="433" height="47" /></a> More information can be found about this <a href="http://www.learnaholic.me/2009/12/24/powershell-prompt-with-mercurial-status/">here</a>.</p>
<p><a href="http://www.humblecoder.co.uk/?p=127">&quot;hg push -b default&quot; is Massively Handy</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/10Lx87Z9j-8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=127</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=127</feedburner:origLink></item>
		<item>
		<title>Passing Reference Types Using Ref, Take Two</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/2hy-3FCSLvo/</link>
		<comments>http://www.humblecoder.co.uk/?p=122#comments</comments>
		<pubDate>Tue, 16 Mar 2010 11:42:44 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Basics]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=122</guid>
		<description><![CDATA[In my last post I talked about passing reference types using the ref keyword but it didn’t make a lot of sense.&#160; So I just want to go over it again, hopefully making a bit more sense. 
When a method is called in C# a copy of the all parameters are given to the method.&#160; [...]<p><a href="http://www.humblecoder.co.uk/?p=122">Passing Reference Types Using Ref, Take Two</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.humblecoder.co.uk/?p=121">my last post</a> I talked about passing reference types using the ref keyword but it didn’t make a lot of sense.&#160; So I just want to go over it again, hopefully making a bit more sense. </p>
<p>When a method is called in C# a <strong>copy </strong>of the all parameters are given to the method.&#160; This is fairly obvious with value types because if we change the value of an int, for example, the caller does not get the updated value. </p>
<p>However this is not so clear for reference types.&#160; The called method can update the state of the object it was passed, for example append extra data to a StringBuilder, and the caller’s object will have these updates.&#160; This can lead to confusion about what is really happening, it looks as if the StringBuilder was passed by reference but a copy of the reference to it was taken.&#160;&#160; </p>
<p>It maybe subtle semantics under normal use but it becomes key to understanding behaviour when the <em>ref</em> keyword is used.&#160; For value types this means that if we increment an int we are passed, the caller will have the new value too.&#160; For reference types the reference we are passed is actually a reference to the caller’s reference. Meaning if we assign a new reference to it, the caller will get the new reference.</p>
<p>We can demonstrate this with the following code:&#160; </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:68f4adcb-0edf-4c1b-bb61-650028da5455" class="wlWriterEditableSmartContent">
<pre name="code" class="c#">static void Main(string[] args)
{
    StringBuilder sb = new StringBuilder();
    sb.AppendLine("Added by Main");

    AddToSBPassedAsNormal(sb);
    Console.Write(sb.ToString());
    //Output: Added by Main
    //        AddToSBPassedAsNormal

    AddToSBPassedByRef(ref sb);
    Console.Write(sb.ToString());
    //Output: AddToSBPassedByRef

    AddToSBPassedAsNormalNewUsed(sb);
    Console.Write(sb.ToString());
    //Output: AddToSBPassedByRef

    Console.ReadLine();
}

private static void AddToSBPassedAsNormal(StringBuilder sb)
{
    sb.AppendLine("AddToSBPassedAsNormal");
}

private static void AddToSBPassedByRef(ref StringBuilder sb)
{
    sb = new StringBuilder();
    sb.AppendLine("AddToSBPassedByRef");
}

private static void AddToSBPassedAsNormalNewUsed(StringBuilder sb)
{
    sb = new StringBuilder();
    sb.AppendLine("AddToSBPassedAsNormalNewUsed");
}</pre>
</div>
<p>From the code above we can see that the StringBuilder after the first method contains both strings.&#160; But after the method call, where it is passed by ref, the previously entered data has been lost and, finally, using new when not being passing by reference has no effect on <em>Main()</em>’s reference to the StringBuilder.</p>
<p>Before passing a reference type using the <em>ref </em>keyword you must think carefully about the implications of the caller changing the reference.&#160; As it can lead to some esoteric and difficult to track down bugs.</p>
<p><a href="http://www.humblecoder.co.uk/?p=122">Passing Reference Types Using Ref, Take Two</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/2hy-3FCSLvo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=122</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=122</feedburner:origLink></item>
		<item>
		<title>C# Basics: Ref’ing References, Ref’ing Hell</title>
		<link>http://feedproxy.google.com/~r/Humblecoder/~3/aeaGi0z70WA/</link>
		<comments>http://www.humblecoder.co.uk/?p=121#comments</comments>
		<pubDate>Fri, 12 Mar 2010 23:20:33 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Basics]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.humblecoder.co.uk/?p=121</guid>
		<description><![CDATA[For the past couple of weeks I’ve been deep in some legacy code.&#160; The code has all kind of hidden charms, while I’m not going to be overly critical because it was written at a time when a .NET 2.0 application was cutting edge.&#160; I uncovered this gem:

public void SomeHighLevelFunction(out String feedback)
{
	StringBuilder mySb = new [...]<p><a href="http://www.humblecoder.co.uk/?p=121">C# Basics: Ref&rsquo;ing References, Ref&rsquo;ing Hell</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
]]></description>
			<content:encoded><![CDATA[<p>For the past couple of weeks I’ve been deep in some legacy code.&#160; The code has all kind of hidden charms, while I’m not going to be overly critical because it was written at a time when a .NET 2.0 application was cutting edge.&#160; I uncovered this gem:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:e09e1789-0082-41ce-bdc2-17ce728802ba" class="wlWriterEditableSmartContent">
<pre name="code" class="c#">public void SomeHighLevelFunction(out String feedback)
{
	StringBuilder mySb = new StringBuilder();

	_WorkerItem1.DoWorkOne(ref mySb);
	_WorkerItem2.DoWorkTwo(ref mySb);
	_WorkerItem3.DoWorkThree(ref mySb);

	feedback = mySb.ToString();
}</pre>
</div>
<p>Ignoring the void with the out String, why pass the StringBuilder by ref?&#160; This code was written by a migrating C++ programmer; if you’ve worked with C++ at all a little light bulb may have just gone off for you.&#160; It works, even though it might be the very definition of programming by coincidence, so why is this so bad?&#160; </p>
<h4></h4>
<h3><strong>Why So Bad?</strong></h3>
<p>When calling a method in C# all parameters are passed by value.&#160; It is a common misconception that reference types are passed by reference when they are infact passed by value.&#160; This backs up the position of the C++ programmer, so what is the difference?</p>
<p>C# and its documentation has no concept of pointers (outside of IntPtr) when they are used extensively under the hood.&#160; When you call a method and pass a reference type you are actually passing a pointer (that lives on the stack) to a memory location on the heap.&#160;&#160;&#160; The pointer is copied so you can still manipulate the memory but you can’t affect the reference.&#160; <a href="http://bitbucket.org/humblecoder/blogpostcode/src/22e29d9b8ae8/RefDemo/">For example</a>:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:143faae3-d4b4-4aa2-9b93-5bcf5a663357" class="wlWriterEditableSmartContent">
<pre name="code" class="c#">static void Main(string[] args)
{
    StringBuilder sb = new StringBuilder();
    sb.AppendLine("Added by Main");

    AddToSBPassedByRef(ref sb);
    AddToSBPassedAsNormal(sb);

    Console.Write(sb.ToString());

    Console.ReadLine();
}

private static void AddToSBPassedByRef(ref StringBuilder sb)
{
    sb = new StringBuilder();
    sb.AppendLine("Added by AddToSBPassedByRef");
}

private static void AddToSBPassedAsNormal(StringBuilder sb)
{
    sb = new StringBuilder();
    sb.AppendLine("AddToSBPassedAsNormal");
}</pre>
</div>
<p>&#160;</p>
<p>Has the output of:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:e8709021-4cab-44b3-908d-786bf203b51e" class="wlWriterEditableSmartContent">
<pre name="code" class="xml">Added by AddToSBPassedByRef</pre>
</div>
<p>This could be confusing to a C++ developer because all classes, in C++, are created on the stack unless you declare a pointer and use <em>new </em>to create them on the heap.&#160; Having said that a simple rule applies to both to C# and C++, if you have to use <em>new </em>it gets created on the heap and everything else is created on the stack.&#160; Anything on the stack, value types or reference types, is copied between method calls.</p>
<p>&lt;/rant&gt;</p>
<p><a href="http://www.humblecoder.co.uk/?p=121">C# Basics: Ref&rsquo;ing References, Ref&rsquo;ing Hell</a> is a post from: <a href="http://www.humblecoder.co.uk">Humblecoder</a></p>
<img src="http://feeds.feedburner.com/~r/Humblecoder/~4/aeaGi0z70WA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.humblecoder.co.uk/?feed=rss2&amp;p=121</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.humblecoder.co.uk/?p=121</feedburner:origLink></item>
	</channel>
</rss>
