<?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; .NET</title>
	<atom:link href="http://27.am/tag/net/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>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>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>
	</channel>
</rss>

