<?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>Ashley Ross • 27.am &#187; Coding</title>
	<atom:link href="http://27.am/category/coding/feed" rel="self" type="application/rss+xml" />
	<link>http://27.am</link>
	<description></description>
	<lastBuildDate>Thu, 20 Oct 2011 11:36:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Legend of FinkyPieheimer@zoobatz.com</title>
		<link>http://27.am/posts/the-legend-of-finkypieheimerzoobatz-com</link>
		<comments>http://27.am/posts/the-legend-of-finkypieheimerzoobatz-com#comments</comments>
		<pubDate>Thu, 29 Sep 2011 12:56:02 +0000</pubDate>
		<dc:creator>Ashley Ross</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://27.am/?p=190</guid>
		<description><![CDATA[Occasionally, you want a quick disposable email address for registering on suspicious websites, or in my case, for testing your own website&#8217;s registration system. While there are several options, I use Mailinator because you don&#8217;t need to set up anything &#8230; <a href="http://27.am/posts/the-legend-of-finkypieheimerzoobatz-com">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Occasionally, you want a quick disposable email address for registering on suspicious websites, or in my case, for testing your own website&#8217;s registration system. While there are several options, I use <a href="http://mailinator.com/">Mailinator</a> because you don&#8217;t need to set up anything first. You just enter whatever you want, followed by <i>@mailinator.com</i> as your email address, and it just works.</p>
<p>This is what I was doing last week when I noticed that all the email sent by my website&#8217;s registration system was apparently from <i>FinkyPieheimer@zoobatz.com</i>. That&#8217;s definitely not what I set, and I confirmed that a valid from address was being used. The only recent change was that a friendly display name was now being included, instead of just the email address by itself. So what gives?</p>
<p>Upon examining the raw email (When viewing an email in Mailinator, click the <i>Text View</i> button), I noticed a linebreak in the <i>From</i> header.</p>
<pre>
...
MIME-Version: 1.0
From: "Quux Baz"
 &lt;noreply@foo.bar&gt;
To: test@mailinator.com
...
</pre>
<p>While that&#8217;s unusual, other email programs and systems handle it just fine. Mailinator, however, doesn&#8217;t like it one bit. It seems to regard it as invalid, and as such, replaces the field with <i>FinkyPieheimer@zoobatz.com</i> as a sort of placeholder.</p>
<p>So what can you do about it? If you&#8217;re just registering on a website, don&#8217;t worry about it. If you&#8217;re working on your own website, see if you can change how the <i>From</i> email address is set.</p>
<p>In my case, I was using .NET&#8217;s SmtpClient, MailMessage and MailAddress classes. I found a <a href="http://stackoverflow.com/questions/5137321/net-or-mssmtp-adding-a-line-break-in-the-from-header"</a>StackOverflow question</a> about the strange carriage return &amp; line feed, which only appears when you set the <i>DisplayName</i> property of a MailAddress instance. This only happens under .NET 4.0, and you can see the hardcoded &#8220;\r\n &#8221; are the end of the <a href="http://typedescriptor.net/name/members/086C4827B03BC13039391486C79CB0C0-System.Net.Mail.MailAddress.Encode%28Int32%29">MailAddress.Encode(Int32) method</a>. To resolve this, either convert the project to .NET 3.5, remove the display name, or, if you have an intermediate delivery system, add a processing step to fix this after it leaves the .NET SmtpClient.</p>
]]></content:encoded>
			<wfw:commentRss>http://27.am/posts/the-legend-of-finkypieheimerzoobatz-com/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting to the (Reparse) Point: Notes</title>
		<link>http://27.am/posts/getting-to-the-reparse-point-notes</link>
		<comments>http://27.am/posts/getting-to-the-reparse-point-notes#comments</comments>
		<pubDate>Thu, 18 Aug 2011 09:08:30 +0000</pubDate>
		<dc:creator>Ashley Ross</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://27.am/?p=147</guid>
		<description><![CDATA[These are the links, notes and resources for my presentation Getting to the (Reparse) Point, which I&#8217;ll be giving at Microsoft Devs4Devs on Saturday, 20 August 2011 at 09:30. Code Manta, my open source .NET library with functionality for managing &#8230; <a href="http://27.am/posts/getting-to-the-reparse-point-notes">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>These are the links, notes and resources for my presentation <i>Getting to the (Reparse) Point</i>, which I&#8217;ll be giving at Microsoft Devs4Devs on Saturday, 20 August 2011 at 09:30.</p>
<h4>Code</h4>
<ul>
<li><a href="http://27.am/projects/manta">Manta, my open source .NET library with functionality for managing hardlinks, reparse points, junctions and symbolic links</a></li>
</ul>
<h4>Applications</h4>
<ul>
<li><a href="http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html"><b>Recommended:</b> Link Shell Extension &#8211; Explorer extension to manage hardlinks, symbolic links, junctions and mount points (2000+)</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/cc753059.aspx">fsutil &#8211; View and delete reparse points (XP+)</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/cc753194.aspx">mklink &#8211; Create hardlinks, symbolic links and junctions (Vista+)</a></li>
<li><a href="http://technet.microsoft.com/en-us/sysinternals/bb896768">junction- Create and delete junctions (2000+)</a></li>
<li><a href="http://support.microsoft.com/kb/205524">linkd, mountvol &amp; delrp &#8211; Junction, mount point and reparse point management (2000+)</a></li>
</ul>
<h4>Documentation</h4>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa365006.aspx">Hard Links and Junctions</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa365503.aspx">Reparse Points</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa365680.aspx">Symbolic Links</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://27.am/posts/getting-to-the-reparse-point-notes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing Manta</title>
		<link>http://27.am/posts/announcing-manta</link>
		<comments>http://27.am/posts/announcing-manta#comments</comments>
		<pubDate>Thu, 18 Aug 2011 09:05:13 +0000</pubDate>
		<dc:creator>Ashley Ross</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Manta]]></category>

		<guid isPermaLink="false">http://27.am/?p=166</guid>
		<description><![CDATA[It&#8217;s taken much too long, but I&#8217;ve finally created an online project for Manta, which until recently didn&#8217;t even have an official name. Manta is an open source .NET library that currently features a variety of I/O- and web-related classes &#8230; <a href="http://27.am/posts/announcing-manta">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s taken much too long, but I&#8217;ve finally created an online project for Manta, which until recently didn&#8217;t even have an official name. Manta is an open source .NET library that currently features a variety of I/O- and web-related classes that simplify and ease solving hard problems.</p>
<p>On the I/O side, Manta offers support for managing hardlinks, reparse points, junctions, symbolic links. It also comes with unit tests and documented methods and classes.</p>
<p>On the web side, Manta enables easy manipulation of URLs, RSS feeds and phpBB posts. It too features unit tests and documentation.</p>
<p>You can <a href="http://27.am/projects/manta">find out more about Manta</a> or <a href="http://mantalib.codeplex.com">download it from CodePlex</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://27.am/posts/announcing-manta/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Quines</title>
		<link>http://27.am/posts/c-quines</link>
		<comments>http://27.am/posts/c-quines#comments</comments>
		<pubDate>Thu, 02 Jul 2009 09:34:39 +0000</pubDate>
		<dc:creator>Ashley Ross</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Quines]]></category>

		<guid isPermaLink="false">http://27.am/?p=22</guid>
		<description><![CDATA[Writing quines is a fun way to while away an afternoon, especially when trying to make them as short as possible. This is the result of my attempt at writing the shortest C# quine possible (155 characters, source file): class &#8230; <a href="http://27.am/posts/c-quines">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Writing <a href="http://en.wikipedia.org/wiki/Quine_%28computing%29">quines</a> is a fun way to while away an afternoon, especially when trying to make them as short as possible. This is the result of my attempt at writing the shortest C# quine possible (155 characters, <a href="http://27.am/d/q/quine.cs">source file</a>):</p>
<pre lang="csharp" >class q{static void Main(){string s="class q{{static void Main(){{string s={0}{1}{0};System.Console.Write(s,'{0}',s);}}}}";System.Console.Write(s,'"',s);}}</pre>
<p><i>PS</i>: I came across a <a href="http://yetanotherdeveloper.com/post/2008/01/20/My-Quine.aspx">shorter C# 3.5 quine (149 characters)</a>, which uses <i>var</i> instead of <i>string</i>. Clever. Oh well, c&#8217;est la vie.</p>
]]></content:encoded>
			<wfw:commentRss>http://27.am/posts/c-quines/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crouching Enumerator, Hidden Boxing</title>
		<link>http://27.am/posts/crouching-enumerator-hidden-boxing</link>
		<comments>http://27.am/posts/crouching-enumerator-hidden-boxing#comments</comments>
		<pubDate>Thu, 02 Jul 2009 09:13:26 +0000</pubDate>
		<dc:creator>Ashley Ross</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://27.am/?p=20</guid>
		<description><![CDATA[A few months ago, I was playing around with a simple C# permutation generator to build a word list, with each character position having its own list of characters to iterate through: List&#60;T&#62;.Enumerator enumerator = characterList.GetEnumerator(); while (condition) { if &#8230; <a href="http://27.am/posts/crouching-enumerator-hidden-boxing">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I was playing around with a simple C# permutation generator to build a word list, with each character position having its own list of characters to iterate through:</p>
<pre lang="csharp" line="1">
List&lt;T&gt;.Enumerator enumerator = characterList.GetEnumerator();

while (condition) {
	if (!enumerator.MoveNext()) {
		enumerator.Reset();
		enumerator.MoveNext();
	}

	Consume(enumerator.Current);
}
</pre>
<p>Oddly, I was getting a compilation error on line 5, as <i>enumerator</i> doesn&#8217;t have a Reset() method despite the IEnumerator interface defining one. MSDN quickly cleared things up, though, revealing that List&lt;T&gt;.Enumerator explicitly implements the method as <i>void IEnumerator.Reset()</i>, which is implicitly private. You can still call private interface methods if you first cast to that interface, so I changed line 5 to the following:</p>
<pre lang="csharp" line="5">
		((IEnumerator) enumerator).Reset();
</pre>
<p>I thought that was the end of it, but bizarely, the second call to MoveNext() on line 6 also returns false. I confirmed that the private Reset() method actually implements reset functionality, which it certainly does, yet it seemed to have no effect.</p>
<p>The answer lies in the fact that List&lt;T&gt;.Enumerator is a struct. This means that behind the scenes, the cast to IEnumerator is creating a <a href="http://msdn.microsoft.com/en-us/library/aa664476(VS.71).aspx">boxed copy</a> of <i>enumerator</i>, and that&#8217;s what&#8217;s being reset. The original is left untouched, so the call to MoveNext() will naturally return false. Rather than trying to keep the boxed copy that you get from the cast, the correct solution is to use IEnumerator&lt;T&gt; from the outset, rather than List&lt;T&gt;.Enumerator:</p>
<pre lang="csharp" line="1">
IEnumerator&lt;T&gt; enumerator = characterList.GetEnumerator();

while (condition) {
	if (!enumerator.MoveNext()) {
		enumerator.Reset();
		enumerator.MoveNext();
	}

	Consume(enumerator.Current);
}
</pre>
<p>All this drama could have been avoided if I hadn&#8217;t checked the return type for List&lt;T&gt;.GetEnumerator() and used that. So much for more explicit typing being helpful.</p>
<p>Still, it&#8217;s rather odd that List&lt;T&gt;.Enumerator is both public and a struct. The former encourages its direct use, and the latter results in the problem I was experiencing. Sadly, this design is constant throughout the System.Collections.Generic namespace. By contrast, the equivalent non-generic collection is ArrayList, and there, the GetEnumerator() method returns an IEnumerator, which is implemented by a private class nested within the ArrayList type &#8211; a design that is constant throughout the rest of the System.Collections namespace, and is, in my opinion, better for everyone.</p>
]]></content:encoded>
			<wfw:commentRss>http://27.am/posts/crouching-enumerator-hidden-boxing/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Joy of ASP.NET, Visual Studio and Proxies</title>
		<link>http://27.am/posts/the-joy-of-asp-net-visual-studio-and-proxies</link>
		<comments>http://27.am/posts/the-joy-of-asp-net-visual-studio-and-proxies#comments</comments>
		<pubDate>Wed, 01 Jul 2009 14:11:21 +0000</pubDate>
		<dc:creator>Ashley Ross</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://27.am/?p=11</guid>
		<description><![CDATA[Some time ago, the web project I was working on started refusing to open. Every time I tried to reload the ASP.NET project, Visual Studio (In this case, VS.NET 2003, but it may affect 2005 and 2008) gave a strange &#8230; <a href="http://27.am/posts/the-joy-of-asp-net-visual-studio-and-proxies">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some time ago, the web project I was working on started refusing to open. Every time I tried to reload the ASP.NET project, Visual Studio (In this case, VS.NET 2003, but it may affect 2005 and 2008) gave a strange error message:</p>
<blockquote><p>The Web server reported the following error when attempting to create or open the Web project located at the following URL:<br />
&#8216;http://Localhost:/xyz/ACME.XYZ.Widget&#8217;. &#8216;The connection with the server was reset&#8217;.</p></blockquote>
<p>The project files hadn&#8217;t changed and I hadn&#8217;t made any changes to IIS recently. In my search for a solution, I come across someone else having problems creating ASP.NET projects from Visual Studio on a network that used a proxy, getting the message <i>&#8216;A connection with the server could not be established&#8217;</i> &#8211; this proved to be the key to the answer. In short, Visual Studio needs to support environments where your ASP.NET project is not hosted on your own machine, so it uses the system&#8217;s proxy settings.</p>
<p>In my case, under <b>Control Panel</b> &gt; <b>Internet Options</b> &gt; <b>Connections</b> &gt; <b>LAN Settings&#8230;</b>, I had enabled <b>Use a proxy server for your LAN</b> but had neglected to also tick the <b>Bypass proxy server for local addresses</b> checkbox. When Visual Studio gave the proxy a request for <i>localhost</i>, the proxy responded by closing the connection, and thus Visual Studio came back with the error message. Simple, logical, and entirely frustrating.</p>
]]></content:encoded>
			<wfw:commentRss>http://27.am/posts/the-joy-of-asp-net-visual-studio-and-proxies/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

