<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Sneal</title>
    <link>http://www.sneal.net/blog/</link>
    <description>The development of Shawn Neal</description>
    <language>en-us</language>
    <copyright>Shawn Neal</copyright>
    <lastBuildDate>Mon, 04 Jan 2010 07:15:41 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>sneal@sneal.net</managingEditor>
    <webMaster>sneal@sneal.net</webMaster>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=858f6ac8-b802-49ed-8bf0-0c7d0b321292</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,858f6ac8-b802-49ed-8bf0-0c7d0b321292.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,858f6ac8-b802-49ed-8bf0-0c7d0b321292.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=858f6ac8-b802-49ed-8bf0-0c7d0b321292</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <title>MonoDevelop is getting there</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,858f6ac8-b802-49ed-8bf0-0c7d0b321292.aspx</guid>
      <link>http://www.sneal.net/blog/2010/01/04/MonoDevelopIsGettingThere.aspx</link>
      <pubDate>Mon, 04 Jan 2010 07:15:41 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;I've been using MonoDevelop on Ubuntu this weekend, because it just doesn't feel right to use it on Windows.  If you have Windows and need to write C# code, I'm sorry you're going to use Visual Studio, period.&lt;/p&gt;
&lt;p&gt;
Sun VirtualBox (VBox) has been instrumental in getting a Mono environment setup. VBox just rocks, but I did have one hickup.  Initially I started with Suse Linux 11.2 because that's officially supported by MonoDevelop, but it kept throwing segmentation faults on bootup when trying to load the NIC driver.  I tried several reinstalls, 32 bit, 64 bit, KDE, Gnome, different NICs inside VBox; nothing worked, so I gave up and went back to my tried and true friend Ubuntu. I never did figure out the root cause.
&lt;/p&gt;
&lt;p&gt;
Instead of compiling MonoDevelop from SVN or from the latest release tarballs (like I did last time) I just grabbed the latest and gratest version of MonoDevelop (v 2.0) out of the multiverse, which to my surprise is pretty new. This took a LOT less effort and was much more stable.
&lt;/p&gt;
&lt;p&gt;
I was actually able to make some changes to my command line library and for the most part get the tests to pass in Linux/Mono. The SVN integration worked perfectly. The MonoDevelop usability was pretty good.  No hard crashes.  No super strange compilation errors, everything pretty much worked right out of the gates.
&lt;/p&gt;
&lt;p&gt;
I did have a few issues:
&lt;ul&gt;
&lt;li&gt;Rename method or property fails and shows an exception dialog.&lt;/li&gt;
&lt;li&gt;Adding a NUnit test class automatically references the NUnit.Core and NUnit.Framework Mono package - which causes a compilation error: Duplicate TestFixture attributes.  Removing the auto added NUnit package references fixes this, but this was less than obvious.&lt;/li&gt;
&lt;li&gt;Find Usages works most of the time, but also displays the declaration in the results.&lt;/li&gt;
&lt;li&gt;Go to declaration doesn't always appear on a method.&lt;/li&gt;
&lt;li&gt;No (obvious) way to interactively debug an NUnit test. Maybe there's a way to do this, but the only way I could find was to create a console app which runs an NUnit suite.&lt;/li&gt;
&lt;li&gt;The syntax highlighting is pretty monotone (at least the default scheme)&lt;/li&gt;
&lt;li&gt;The ability to automatically add a using statement when a used type isn't imported would be super handy. I've been using Re# far too long to NOT have this.&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
I will continue to use MonoDevelop, because its good enough and runs on Linux. Clearly it has a ways to go to compete with Visual Studio on Windows or many other Java or Ruby IDEs, but if you need to write C# code on Linux it'll certainly do. I'm hopeful the development experience with MonoDevelop will only get better in 2010.
&lt;/p&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=858f6ac8-b802-49ed-8bf0-0c7d0b321292"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,858f6ac8-b802-49ed-8bf0-0c7d0b321292.aspx</comments>
      <category>Linux</category>
      <category>Mono</category>
    </item>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=e2a52c99-b516-4046-aeaf-9b3c5b21def5</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,e2a52c99-b516-4046-aeaf-9b3c5b21def5.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,e2a52c99-b516-4046-aeaf-9b3c5b21def5.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=e2a52c99-b516-4046-aeaf-9b3c5b21def5</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <title>Model mismatch</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,e2a52c99-b516-4046-aeaf-9b3c5b21def5.aspx</guid>
      <link>http://www.sneal.net/blog/2009/12/19/ModelMismatch.aspx</link>
      <pubDate>Sat, 19 Dec 2009 16:43:04 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;A single model cannot be appropriate for reporting, searching, and transactional behaviors.&lt;/p&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=e2a52c99-b516-4046-aeaf-9b3c5b21def5"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,e2a52c99-b516-4046-aeaf-9b3c5b21def5.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=55a96b2a-d368-498b-824b-0fcb003ec387</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,55a96b2a-d368-498b-824b-0fcb003ec387.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,55a96b2a-d368-498b-824b-0fcb003ec387.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=55a96b2a-d368-498b-824b-0fcb003ec387</wfw:commentRss>
      <title>Using Expressions in Guard clauses</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,55a96b2a-d368-498b-824b-0fcb003ec387.aspx</guid>
      <link>http://www.sneal.net/blog/2009/12/01/UsingExpressionsInGuardClauses.aspx</link>
      <pubDate>Tue, 01 Dec 2009 02:14:31 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;Ruby was the impetus for me to write a Guard clause that automatically get a parameter name from code. What do I mean by that? This passes:&lt;/p&gt;  &lt;pre&gt;[Test]
&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Expression_guard_can_get_parameter_name_from_expression()
{
	&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; address = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;
	Assert.Throws&amp;lt;ArgumentException&amp;gt;(() =&amp;gt; Guard.AgainstNull(() =&amp;gt; address),
		&amp;quot;&lt;span style="color: #8b0000"&gt;The parameter address must not be null&lt;/span&gt;&amp;quot;);
}&lt;/pre&gt;

&lt;p&gt;Notice how I didn’t specify the string “address” anywhere, the Guard.AgainstNull method got it from the expression () =&amp;gt; address. I’m sure I’ve &lt;em&gt;used&lt;/em&gt; constructs like this in C# before, but I haven’t &lt;em&gt;written&lt;/em&gt; any yet. I wonder in what other ways I can abuse Expressions?&lt;/p&gt;

&lt;p&gt;The implementation, that is not well tested by any means:&lt;/p&gt;

&lt;pre&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AgainstNull&amp;lt;T&amp;gt;(Expression&amp;lt;Func&amp;lt;T&amp;gt;&amp;gt; expression)
{
	AgainstNull(expression, &amp;quot;&lt;span style="color: #8b0000"&gt;expression&lt;/span&gt;&amp;quot;);

	&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; paramName = &amp;quot;&lt;span style="color: #8b0000"&gt;&lt;/span&gt;&amp;quot;;
	var memberExpression = expression.Body &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; MemberExpression;
	&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (memberExpression != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)
	{
		paramName = memberExpression.Member.Name;
	}
	T instance = expression.Compile().Invoke();
	AgainstNull(instance, paramName);
}&lt;/pre&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=55a96b2a-d368-498b-824b-0fcb003ec387"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,55a96b2a-d368-498b-824b-0fcb003ec387.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=50c478ae-ccd3-4260-98a8-4a46e165cf8a</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,50c478ae-ccd3-4260-98a8-4a46e165cf8a.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,50c478ae-ccd3-4260-98a8-4a46e165cf8a.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=50c478ae-ccd3-4260-98a8-4a46e165cf8a</wfw:commentRss>
      <title>ReSharper 5 won't run unit tests in Visual Studio 2010</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,50c478ae-ccd3-4260-98a8-4a46e165cf8a.aspx</guid>
      <link>http://www.sneal.net/blog/2009/11/07/ReSharper5WontRunUnitTestsInVisualStudio2010.aspx</link>
      <pubDate>Sat, 07 Nov 2009 19:59:07 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;I've been playing around with Visual Studio 2010, and of course the latest ReSharper, version 5.  Unfortunately my NUnit tests wouldn't run inside the ReSharper runner.  Instead they would spin for a second then turn grey, like nothing happened.&lt;/p&gt;
&lt;p&gt;
Running the tests under the debugger turned up an interesting exception in the VS output window: BadImageFormatException.  I also noticed a bunch of DLLs being loaded out of the v2.0 framework GAC, and not .NET 4.  Shouldn't my .NET 4 app be using the .NET 4.0 GAC?
&lt;/p&gt;
Of course it should. There's an easy fix to this. ReSharper shells out to another exe that actuall runs the unit tests JetBrains.ReSharper.TaskRunner.exe.  If we modify the JetBrains.ReSharper.TaskRunner.exe.config in the ReSharper installation directory we can force the test runner to run under the .NET 4.0 framework. At the bottom of the file you'll find the associated startup element already there, just commented out and with the .NET 4.0 beta 1 framework version.  To fix it, just incomment it and change the version to the .NET beta 2 framework version.
&lt;/p&gt;
&lt;p&gt;

  &amp;lt;!-- Needed in dev10, not needed in dev9/8 --&amp;gt;

  &amp;lt;startup&amp;gt;
    &amp;lt;requiredRuntime version="v4.0.21006"/&amp;gt;
  &amp;lt;/startup&amp;gt;
&lt;/p&gt;
&lt;p&gt;
Now you can run unit tests via ReSharper in VS 2010 beta 2.
&lt;/p&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=50c478ae-ccd3-4260-98a8-4a46e165cf8a"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,50c478ae-ccd3-4260-98a8-4a46e165cf8a.aspx</comments>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=52622b21-310d-4117-b601-498416f98ac1</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,52622b21-310d-4117-b601-498416f98ac1.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,52622b21-310d-4117-b601-498416f98ac1.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=52622b21-310d-4117-b601-498416f98ac1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <title>Erlang’s sweet spot</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,52622b21-310d-4117-b601-498416f98ac1.aspx</guid>
      <link>http://www.sneal.net/blog/2009/10/19/ErlangsSweetSpot.aspx</link>
      <pubDate>Mon, 19 Oct 2009 15:52:56 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;Most every language has a sweet spot, something it does better than any other language around it.&lt;/p&gt;  &lt;p&gt;C and C++ are really good for writing console video games because of its speed, portability, and deterministic finalization.&amp;#160; Perl is really good at string manipulation. Java has a gazillion OSS frameworks and application servers. Ruby is damn pretty and has a couple of really super productive web frameworks.&lt;/p&gt;  &lt;p&gt;Erlang has a very succinct and elegant syntax, a syntax that is highly optimized for writing recursive functions. One could argue that’s just a property of being a functional language, but I think there’s more too it than just being functional.&lt;/p&gt;  &lt;p&gt;C# 3 has a decent functional syntax that is clearly more succinct than Java or C# 2, but it just doesn’t stack up to Erlang.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#ffff00"&gt;&lt;font color="#ff8040"&gt;Warning&lt;/font&gt;: &lt;/font&gt;&lt;font color="#000000"&gt;don’t use these code samples in production code! They use Ω(n) extra storage space and are toy functions.&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;For example, take this Erlang quick sort function:&lt;/p&gt;  &lt;pre&gt;qsort([]) -&amp;gt; [];
qsort([Pivot|T]) -&amp;gt;
	qsort([X || X &amp;lt;- T, X &amp;lt; Pivot])
	++ [Pivot] ++
	qsort([X || X &amp;lt;- T, X &amp;gt;= Pivot]).&lt;/pre&gt;

&lt;p&gt;That is, IMO, beautiful code.&amp;#160; Small, compact, succinct, powerful, readable. On the other hand, what does a comparable implementation look like in C# 3?&amp;#160; &lt;/p&gt;

&lt;pre&gt;&lt;span style="color: #0000ff"&gt;static&lt;/span&gt; IEnumerable&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt; Qsort(IEnumerable&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt; list)
{
    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (list.Count() &amp;lt;= 1)
        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; list;

    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; pivot = list.First();
    var tail = list.Skip(1).Take(list.Count() - 1);

    var result = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt;();
    result.AddRange(Qsort(tail.Where(o =&amp;gt; o &amp;lt; pivot)));
    result.Add(pivot);
    result.AddRange(Qsort(tail.Where(o =&amp;gt; o &amp;gt;= pivot)));
    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;
}&lt;/pre&gt;

&lt;p&gt;It works, it doesn’t contain any loops and only one if statement (the initial C# 2 version was even longer and uglier), but its still very much lacking in the beautiful code department.&amp;#160; Did you also notice it was more than twice as long as the Erlang function? Perhaps you can improve the syntax?&lt;/p&gt;

&lt;p&gt;I don’t have numbers to prove this, but the Erlang implementation can also be made faster with a lot less effort since each recursive call can be run in parallel.&amp;#160; Try that in C# without writing extra threading code. Even if you did, your threads are probably going to be a lot slower than the light weight threads in Erlang.&lt;/p&gt;

&lt;p&gt;Recursive functions in Erlang are definitely a sweet spot.&lt;/p&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=52622b21-310d-4117-b601-498416f98ac1"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,52622b21-310d-4117-b601-498416f98ac1.aspx</comments>
      <category>Erlang</category>
    </item>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=3cd93898-78c8-45dd-b7ff-68ba4f38a3c1</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,3cd93898-78c8-45dd-b7ff-68ba4f38a3c1.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,3cd93898-78c8-45dd-b7ff-68ba4f38a3c1.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=3cd93898-78c8-45dd-b7ff-68ba4f38a3c1</wfw:commentRss>
      <title>I’m enjoying learning Erlang</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,3cd93898-78c8-45dd-b7ff-68ba4f38a3c1.aspx</guid>
      <link>http://www.sneal.net/blog/2009/10/09/ImEnjoyingLearningErlang.aspx</link>
      <pubDate>Fri, 09 Oct 2009 01:09:12 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;Sometimes you need a paradigm shift, a different way to look at the same set of problems. Erlang I hope will give me that paradigm shift. Hopefully I can add another a screwdriver to my toolbox, if not, hopefully something besides a hammer.&lt;/p&gt;  &lt;p&gt;I just bought a copy (on PDF) of &lt;em&gt;Programming Erlang Software for a Concurrent World&lt;/em&gt;. I’ve only gotten through the first few pages of chapter 1, and so far I’m impressed. I guess its no surprise as the book is published by Pragmatic Programmers.&lt;/p&gt;  &lt;p&gt;I &lt;em&gt;finally&lt;/em&gt; understand why mathematicians like functional languages.&amp;#160; Its so obvious now, and it has a lot to do with immutability. From the book:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;When I went to school, my math teacher said, “If there’s an X in several different parts in the same equation, then all the Xs mean the same thing.” That’s how we can solve equations: if we know that X+Y=10 and X-Y=2, then X will be 6 and Y will be 4 in both equations. But when I learned my first programming language, we were shown stuff like this:     &lt;br /&gt;X = X + 1      &lt;br /&gt;Everyone protested, saying “you can’t do that!” But the teacher said we were wrong, and we had to unlearn what we learned in math class. X isn’t a math variable: it’s like a pigeon hole/little box.... In Erlang, variables are just like they are inmath.When you associate a value with a variable, you’re making an assertion—a statement of fact. This variable has that value. And that’s that.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I guess mutability is a strange beast for most people when learning to program, forcing a lot of them to quit while in their first year of CS.&amp;#160; Well, that and pointers. Its an odd way to think of things for people living in a concrete world. I wonder if first year CS students wouldn’t have an easier time learning a functional language?&lt;/p&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=3cd93898-78c8-45dd-b7ff-68ba4f38a3c1"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,3cd93898-78c8-45dd-b7ff-68ba4f38a3c1.aspx</comments>
      <category>Erlang</category>
    </item>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=59f75922-c05d-4447-8f90-748406fc6cc2</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,59f75922-c05d-4447-8f90-748406fc6cc2.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,59f75922-c05d-4447-8f90-748406fc6cc2.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=59f75922-c05d-4447-8f90-748406fc6cc2</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <title>Fluent NUnit Assertions</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,59f75922-c05d-4447-8f90-748406fc6cc2.aspx</guid>
      <link>http://www.sneal.net/blog/2009/10/01/FluentNUnitAssertions.aspx</link>
      <pubDate>Thu, 01 Oct 2009 01:19:34 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;I found another reason to love open source NUnit over MSTest, &lt;a href="http://code.google.com/p/nunitex/wiki/SyntaxOverview"&gt;NUnitEx&lt;/a&gt;. NUnitEx provides a fluent DSL to write NUnit assertions where Visual Studio intellisense is your guiding friend. I’m sure you’re thinking, “Yeah whatever, show me some code.”&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;pre&gt;[Test]
&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AdjacencyGraph_is_directed_by_default()
{
    var graph = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AdjacencyGraph&amp;lt;Task, TaskDependency&amp;gt;(DoNotAllowParallelEdges);
    graph.IsDirected.Should().Be.True();
}&lt;/pre&gt;

&lt;p&gt;Nice eh? graph.IsDirected is the property I want to test.&amp;#160; Everything after that is the NUnitEx extension methods. I know I find it much more readable than this:&lt;/p&gt;

&lt;pre&gt;[Test]
&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AdjacencyGraph_is_directed_by_default()
{
    var graph = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AdjacencyGraph&amp;lt;Task, TaskDependency&amp;gt;(DoNotAllowParallelEdges);
    Assert.IsTrue(graph.IsDirected);
}&lt;/pre&gt;

&lt;p&gt;I would also like to add that this syntax is likely to be included in NUnit 3, which would be excellent!&lt;/p&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=59f75922-c05d-4447-8f90-748406fc6cc2"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,59f75922-c05d-4447-8f90-748406fc6cc2.aspx</comments>
      <category>Testing</category>
    </item>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=68a0ce6d-6f97-4cf1-b399-79f63ba2ae23</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,68a0ce6d-6f97-4cf1-b399-79f63ba2ae23.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,68a0ce6d-6f97-4cf1-b399-79f63ba2ae23.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=68a0ce6d-6f97-4cf1-b399-79f63ba2ae23</wfw:commentRss>
      <title>Visual Studio webtests hurt my eyes</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,68a0ce6d-6f97-4cf1-b399-79f63ba2ae23.aspx</guid>
      <link>http://www.sneal.net/blog/2009/09/23/VisualStudioWebtestsHurtMyEyes.aspx</link>
      <pubDate>Wed, 23 Sep 2009 00:47:31 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;Ive spent the last couple of days writing visual studio web tests to create a load test scenario for a critical section of application. Unfortunately i find it repetitive and boring.&lt;/p&gt;
&lt;p&gt;The web tests recorder in VS doesn't capture everything and additionally it hurts to look at the produced code. I did find fiddler much better at recording tests but they still needed serious cleaning up.&lt;/p&gt;
&lt;p&gt;I wish there was a more polished tool for this kind of test. I doubt other tools like JMeter are much better, and for .NET their probably worse because of viewstate and other platform specifics.&lt;/p&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=68a0ce6d-6f97-4cf1-b399-79f63ba2ae23"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,68a0ce6d-6f97-4cf1-b399-79f63ba2ae23.aspx</comments>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=fd1e03ad-007e-4682-a853-56b68719bea0</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,fd1e03ad-007e-4682-a853-56b68719bea0.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,fd1e03ad-007e-4682-a853-56b68719bea0.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=fd1e03ad-007e-4682-a853-56b68719bea0</wfw:commentRss>
      <title>Check for parameter null, more ReSharper goodness</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,fd1e03ad-007e-4682-a853-56b68719bea0.aspx</guid>
      <link>http://www.sneal.net/blog/2009/09/17/CheckForParameterNullMoreReSharperGoodness.aspx</link>
      <pubDate>Thu, 17 Sep 2009 15:46:55 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;I just found another useful thing that resharper does for you, it can generate code to check for null method parameters.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sneal.net/blog/content/binary/CheckforparameternullmoreReSharpergoodne_79E3/image.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="141" alt="image" src="http://www.sneal.net/blog/content/binary/CheckforparameternullmoreReSharpergoodne_79E3/image_thumb.png" width="428" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Just put the cursor on the parameter….&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sneal.net/blog/content/binary/CheckforparameternullmoreReSharpergoodne_79E3/image_3.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="96" alt="image" src="http://www.sneal.net/blog/content/binary/CheckforparameternullmoreReSharpergoodne_79E3/image_thumb_3.png" width="576" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Nice huh!?&lt;/p&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=fd1e03ad-007e-4682-a853-56b68719bea0"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,fd1e03ad-007e-4682-a853-56b68719bea0.aspx</comments>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.sneal.net/blog/Trackback.aspx?guid=3e30d1b1-a5fe-4588-a109-276f0db03fce</trackback:ping>
      <pingback:server>http://www.sneal.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.sneal.net/blog/PermaLink,guid,3e30d1b1-a5fe-4588-a109-276f0db03fce.aspx</pingback:target>
      <dc:creator>Sneal</dc:creator>
      <wfw:comment>http://www.sneal.net/blog/CommentView,guid,3e30d1b1-a5fe-4588-a109-276f0db03fce.aspx</wfw:comment>
      <wfw:commentRss>http://www.sneal.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=3e30d1b1-a5fe-4588-a109-276f0db03fce</wfw:commentRss>
      <title>The singleton that wasn’t</title>
      <guid isPermaLink="false">http://www.sneal.net/blog/PermaLink,guid,3e30d1b1-a5fe-4588-a109-276f0db03fce.aspx</guid>
      <link>http://www.sneal.net/blog/2009/09/15/TheSingletonThatWasnt.aspx</link>
      <pubDate>Tue, 15 Sep 2009 01:54:46 GMT</pubDate>
      <description>&lt;div&gt;&lt;p&gt;Its amazing how one single line of code and a bad assumption (or misunderstanding) can cause all sorts of strange production issues. &lt;/p&gt;  &lt;p&gt;The day started out with static content throwing exceptions that contained our UnitOfWork in the call stack.&amp;#160; My first question was, why on earth is a static resource request hitting our begin unit of work.&amp;#160; Well it turns out that we map all requests through the ASP.NET pipeline because of some nameless .NET document management module.&amp;#160; Unfortunately we generally don’t have wild card mapping enabled for ASP.NET in our dev environment because:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;We weren’t aware of the requirement.&lt;/li&gt;    &lt;li&gt;There’s no documentation surrounding proper dev environment setup (e.g. script).&lt;/li&gt;    &lt;li&gt;Only one dev in our entire organization has ever actively touched this module.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Why is the wildcard mapping a big deal?&amp;#160; Because a single page load will create 10, 20, or more HTTP get requests for static content.&amp;#160; If you have a threading bug in your begin request, they’re much, much more likely to show up with numerous requests.&amp;#160; &lt;/p&gt;  &lt;p&gt;The sad truth of the matter is that because our environment we have a lot of NHibernate session factories, which is not normal for most applications. All of these session factories need to be configured and were using Fluent NHibernate to do so.&amp;#160; FNH is a great tool and makes configuration so much easier for us devs, but the fact remains FNH is not thread safe.&lt;/p&gt;  &lt;p&gt;Seems easy enough, put a lock around the FNH stuff.&amp;#160; Well, we did, but the locker class was not static, we were relying on AutoFac to ensure that our NHibernate session factory class (the class with the lock) was a singleton.&amp;#160; Not too hard since AutoFac defaults to singleton.&lt;/p&gt;  &lt;p&gt;Here’s the mistake.&amp;#160; ASP.NET creates not one, but many HttpApplication instances for each app domain.&amp;#160; I was falsely under the assumption is only ever created one, maybe two, but only ever kept one around.&amp;#160; Our AutoFac registration was setup in the Global instance constructor, so each app instance was getting its own container instance.&amp;#160; Can you guess why this is bad?&lt;/p&gt;  &lt;p&gt;Each request had its own NHibernate configuration class with its own instance lock, thus multiple threads were entering into the critical section at the same time since they couldn’t see each other.&amp;#160; Lots of weirdness ensued.&amp;#160; We saw all sorts of the strange Nhibernate and FNH errors, things like property “XYZ” doesn’t exist on class “ABC&amp;quot;.&amp;#160; Odd stuff that definitely smelt of threading.&lt;/p&gt;  &lt;p&gt;I was starting to think SELECT was broken (e.g. AutoFac), but soon realized the errors of my ways with a simple Debug.Assert. Yep, multiple container, produce multiple “singletons”.&amp;#160; &lt;/p&gt;&lt;img width="0" height="0" src="http://www.sneal.net/blog/aggbug.ashx?id=3e30d1b1-a5fe-4588-a109-276f0db03fce"/&gt;&lt;/div&gt;</description>
      <comments>http://www.sneal.net/blog/CommentView,guid,3e30d1b1-a5fe-4588-a109-276f0db03fce.aspx</comments>
      <category>WTF</category>
    </item>
  </channel>
</rss>