<?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/" version="2.0">

<channel>
	<title>Farblondzshet in Code</title>
	
	<link>http://matthewmanela.com</link>
	<description>The life and work of Matthew Manela</description>
	<lastBuildDate>Wed, 01 Sep 2010 21:54:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Farblondzshet" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="farblondzshet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Making an executable take pipelined input in PowerShell</title>
		<link>http://matthewmanela.com/2010/08/29/making-an-executable-take-pipelined-input-in-powershell/</link>
		<comments>http://matthewmanela.com/2010/08/29/making-an-executable-take-pipelined-input-in-powershell/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 04:59:25 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://matthewmanela.com/?p=573</guid>
		<description><![CDATA[It annoys me when I am working with PowerShell try to pipe the results of a cmdlet into a exe which doesn’t understand pipelined data.  To solve this problem I began aliasing some of the common programs I would like &#8230; <a href="http://matthewmanela.com/2010/08/29/making-an-executable-take-pipelined-input-in-powershell/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It annoys me when I am working with PowerShell try to pipe the results of a cmdlet into a exe which doesn’t understand pipelined data.  To solve this problem I began aliasing some of the common programs I would like to pipe data to with custom functions.</p>

<p>For example, I have the following function in my profile to alias notepad.exe:</p>

<div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:3775e2c1-58b3-488f-9496-260b4a33084e" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"><pre class="brush: powershell; gutter: true; first-line: 1; tab-size: 4;  toolbar: false;  width: 486px; height: 160px;" style="width: 486px; height: 160px; overflow: auto;">function n($file) {
  if($file -ne $null){
    notepad $file
  } else {
    notepad $input
  }
}</pre>

<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p></div>

<p>I can use the function named <strong>n </strong>whenever I want to open a file using notepad. This function will take a file name either through piping or as a regular argument.</p>

<p>So I can open a file in notepad this way:</p>

<div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:32f66b00-75a0-4a46-85af-fb8f72a0e2f5" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"><pre class="brush: powershell; gutter: true; first-line: 1; tab-size: 4;  toolbar: false;  width: 486px; height: 35px;" style="width: 486px; height: 35px; overflow: auto;">n someFile.txt</pre>

<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p></div>

<p>or this way:</p>

<div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:8d2bc72e-82db-403d-a8b1-d6233d2133bc" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"><pre class="brush: powershell; gutter: true; first-line: 1; tab-size: 4;  toolbar: false;  width: 486px; height: 54px;" style="width: 486px; height: 54px; overflow: auto;">ls *.txt | n</pre>

<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p></div>

<p>You can create similar functions for other programs as well.  Here is the one I use for Emacs:</p>

<div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:a05302cd-1c4e-4c12-82f4-de5f5066717d" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"><pre class="brush: powershell; gutter: true; first-line: 1; tab-size: 4;  toolbar: false;  width: 486px; height: 170px;" style="width: 486px; height: 170px; overflow: auto;">$emacs = "emacs.exe -nw --no-splash"
function emacs($file){
  if($file -ne $null){
    Invoke-Expression "$emacs $file"
  }
  else {
    Invoke-Expression "$emacs $input"
  }
}</pre>

<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p></div>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/iDyB0C2QiLE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/08/29/making-an-executable-take-pipelined-input-in-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FastSharp 2.0</title>
		<link>http://matthewmanela.com/2010/08/08/fastsharp-2-0/</link>
		<comments>http://matthewmanela.com/2010/08/08/fastsharp-2-0/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 05:57:37 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[FastSharp]]></category>
		<category><![CDATA[Visual Studio Gallery]]></category>

		<guid isPermaLink="false">/b/matt/archive/2010/08/08/fastsharp-2-0.aspx</guid>
		<description><![CDATA[I just released a new version of my FastSharp program.  Download it&#160; or&#160; View the source code  This release contains some notable enhancements:     Support for multiple languages             C#         Visual Basic         F#             Pers... <a href="http://matthewmanela.com/2010/08/08/fastsharp-2-0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just released a new version of my FastSharp program.</p>

<p><a href="http://matthewmanela.com/projects/fastsharp/"><span style="font-family: &quot;Calibri&quot;; font-size: medium;">Download it</span></a><span style="font-family: &quot;Calibri&quot;;"> or </span><a href="http://code.matthewmanela.com/FastSharp/"><span style="font-family: &quot;Calibri&quot;; font-size: medium;">View the source code</span></a></p>

<p>This release contains some notable enhancements:</p>

<ul>
    <li>Support for multiple languages 
<ul>
    <li>C# </li>
    <li>Visual Basic </li>
    <li>F# </li>
</ul>
</li>
    <li>Persistence of your current code language and snippet. This allows you to close FastSharp and start right back up from where you left off next time you run it. </li>
</ul>

<p><a href="http://matthewmanela.com/wp-content/uploads/2010/08/2844.FastSharpForm_thumb_17790FFA.png"><img class="alignleft size-full wp-image-513" title="FastSharp" src="http://matthewmanela.com/wp-content/uploads/2010/08/2844.FastSharpForm_thumb_17790FFA.png" alt="" width="504" height="400" /></a></p>

<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10047639" alt="" width="1" height="1" /></p>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/QNOuzeF_GI0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/08/08/fastsharp-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A StructureMap Gotcha</title>
		<link>http://matthewmanela.com/2010/08/06/a-structuremap-gotcha/</link>
		<comments>http://matthewmanela.com/2010/08/06/a-structuremap-gotcha/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 18:41:26 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[structuremap]]></category>

		<guid isPermaLink="false">/b/matt/archive/2010/08/06/a-structuremap-gotcha.aspx</guid>
		<description><![CDATA[I started converting one of the projects I work on to use the StructureMap DI/IOC framework. The previous framework I used was a super simple one that was built in house.&#160;&#160; When switching to StructureMap the plethora of options was a concern ... <a href="http://matthewmanela.com/2010/08/06/a-structuremap-gotcha/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I started converting one of the projects I work on to use the <a href="http://structuremap.github.com/structuremap/index.html">StructureMap</a> DI/IOC framework. The previous framework I used was a super simple one that was built in house.   When switching to StructureMap the plethora of options was a concern at first but once I started the conversion I was amazed how easy it went.  However, there was one subtle difference between the behavior of the old framework I used and StructureMap around object lifecycle.</p>

<p>By default, the old framework created a new instance of an object every time it encountered its corresponding interface in a given object graph. I had assumed that was the same behavior StructureMap would use but I was wrong. StructureMap’s default is called PerRequest.</p>

<p>So when you just write this:</p>

<pre class="brush:c#">For&lt;IThing&gt;().Use&lt;Thing&gt;();</pre>

<p>It will create a new instance of Thing only <strong>once</strong> per object graph.  What that means is if in a given graph with 3 classes that all have IThing in their constructor they will all receive the same instance of the Thing object.</p>

<p>This is an  issue since I have a couple classes that unfortunately have mutable state and do not behave well if the same instance is used. To fix this I just needed to tell StructureMap to always use a unique instance:</p>

<pre class="brush:c#">For&lt;IThing&gt;().LifecycleIs(new UniquePerRequestLifecycle()).Use&lt;Thing&gt;();</pre>

<p>I personally think this should be the default behavior and any instance reuse should be specifically declared instead. At least it was easy enough to change.</p>

<p><strong>Related Links</strong></p>

<ul>
    <li><a href="http://blog.ploeh.dk/2010/07/20/StructureMapPerRequestVsUniqueLifetimes.aspx">StructureMap PerRequest vs. Unique lifetimes</a> </li>
    <li><a href="http://groups.google.com/group/structuremap-users/browse_thread/thread/da8ed4767c24b3e0">Sanity check on unique per request</a> </li>
</ul>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/zZZ6hK61jgA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/08/06/a-structuremap-gotcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenWithTest released on Visual Studio Gallery</title>
		<link>http://matthewmanela.com/2010/06/30/openwithtest-released-on-visual-studio-gallery/</link>
		<comments>http://matthewmanela.com/2010/06/30/openwithtest-released-on-visual-studio-gallery/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 23:59:00 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio Gallery]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">/b/matt/archive/2010/06/30/quot-open-with-test-quot-released-on-visual-studio-gallery.aspx</guid>
		<description><![CDATA[Download
Either download from the extension manager by searching OpenWithTest or go to the project page here.
Summary 
Open with Test is a Visual Studio extension which serves one simple task: To always open your test files and implementation files tog... <a href="http://matthewmanela.com/2010/06/30/openwithtest-released-on-visual-studio-gallery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Download</h3>

<p>Either download from the extension manager by searching OpenWithTest or go to the project page <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/40ed230b-067a-44c6-9a3b-93f661aa4ab6">here</a>.</p>

<h3>Summary</h3>

<p>Open with Test is a Visual Studio extension which serves one simple task: To always open your test files and implementation files together.</p>

<h3>Details</h3>

<p>When writing unit tested applications (especially while practicing TDD) you will often open an implementation file (i.e SomeClass.cs) followed by the test file(i.e. SomeClassTests.cs).  This extension makes this a one step process.</p>

<p>It works by detecting when you open a new file and attempting to find via convention the test file. It assumes that you create one test file per class.  So, if you create a class called Car in the file Car.cs then you will have a test file named CarTests.cs which tests the car class.</p>

<p>Currently, only C# (.cs) files are supported but I plan to expand this to other files types soon.</p>

<h3>Configuration</h3>

<p>Out of the box, this extension will assume a file is a test file if it ends with the suffix <strong>Test</strong>,<strong>Tests</strong>, <strong>Fact</strong> or <strong>Facts</strong>.  However, this can be configured.  To change these go to Tools -&gt; Options -&gt; Open With Test and you will see this screen:</p>

<p style="text-align: center;"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-89-61-metablogapi/6403.image_5F00_068513EA.png"></a><a href="http://matthewmanela.com/wp-content/uploads/2010/06/6403.image_068513EA.png"><img class="size-full wp-image-456 aligncenter" title="6403.image_068513EA" src="http://matthewmanela.com/wp-content/uploads/2010/06/6403.image_068513EA.png" alt="" width="600" height="349" /></a></p>

<p><br class="spacer_" /></p>

<h3><strong>Feedback</strong></h3>

<p>I would love to get feedback about features or suggestion so please feel free to leave a comment on this blog post or start a discussion post on the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/40ed230b-067a-44c6-9a3b-93f661aa4ab6">Visual Studio Gallery page</a>.</p>

<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10033207" alt="" width="1" height="1" /></p>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/zVZgJLZ6QYI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/06/30/openwithtest-released-on-visual-studio-gallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snippet Designer 1.3 Released!</title>
		<link>http://matthewmanela.com/2010/06/01/snippet-designer-1-3-released/</link>
		<comments>http://matthewmanela.com/2010/06/01/snippet-designer-1-3-released/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 04:59:09 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Snippet Designer]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio Gallery]]></category>

		<guid isPermaLink="false">/b/matt/archive/2010/06/01/snippet-designer-1-3-released.aspx</guid>
		<description><![CDATA[I just released Snippet Designer 1.3.  CodePlex Page: http://snippetdesigner.codeplex.com/   Visual Studio Gallery Page: http://visualstudiogallery.msdn.microsoft.com/en-us/B08B0375-139E-41D7-AF9B-FAEE50F68392  The key features of this release are supp... <a href="http://matthewmanela.com/2010/06/01/snippet-designer-1-3-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h4>I just released Snippet Designer 1.3.</h4>

<p><p><strong>CodePlex Page</strong>: <a href="http://snippetdesigner.codeplex.com/">http://snippetdesigner.codeplex.com/</a></p>

<p><strong>Visual Studio Gallery Page:</strong> <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/B08B0375-139E-41D7-AF9B-FAEE50F68392">http://visualstudiogallery.msdn.microsoft.com/en-us/B08B0375-139E-41D7-AF9B-FAEE50F68392</a></p>

<p>The key features of this release are support for HTML/ASP.NET, JavaScript and SQL snippets and a much improved snippet searching experience.</p>

<p>If you already have it installed for Visual Studio 2010 you will get an update in your extension manager for the new version.</p>

<h4>Change log</h4>

<p><strong>Changes for Visual Studio 2010</strong></p>

<p><p> <strong></strong></p>

<ul>
<li>Fixed bug where &quot;Export as Snippet&quot; was failing in a website project </li>
<li>Changed Snippet Explorer search to use a relevance based algorithm which yields much better results </li>
<li>Added support for JavaScript snippets </li>
<li>Added support for SQL snippets </li>
<li>Added support for HTML/ASP.Net snippets </li>
<li>Added support for <AlternativeShortcuts> tag </li>
<li>Made the color of the snippet replacement highlighting configurable </li>
</ul>

<p><strong>Changes for Visual Studio 2008</strong></p>

<p><p> <strong></strong></p>

<ul>
<li>Fixed bug where &quot;Export as Snippet&quot; was failing in a website project </li>
<li>Changed Snippet Explorer search to use a relevance based algorithm which yields much better results </li>
</ul>

<div style="clear:both;"></div>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/LkhNMZHo7IE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/06/01/snippet-designer-1-3-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DiffPlex 1.1 Released</title>
		<link>http://matthewmanela.com/2010/04/21/diffplex-1-1-released/</link>
		<comments>http://matthewmanela.com/2010/04/21/diffplex-1-1-released/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 13:41:18 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[DiffPlex]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blogs.msdn.com/matt/archive/2010/04/21/diffplex-1-1-released.aspx</guid>
		<description><![CDATA[I released a small update to DiffPlex that helps improve performance for both the release and debug builds.&#160; I now also package the release build in the download zip file instead of the debug.&#160; The release build shows a significant performanc... <a href="http://matthewmanela.com/2010/04/21/diffplex-1-1-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I released a small update to <a href="http://diffplex.codeplex.com/">DiffPlex</a> that helps improve performance for both the release and debug builds.  I now also package the release build in the download zip file instead of the debug.  The release build shows a significant performance improvement over the debug dll’s.</p>

<p><br class="spacer_" /></p>

<p>You can download the new version at the <a href="http://diffplex.codeplex.com/">DiffPlex</a> home page.</p>

<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=9999999" alt="" width="1" height="1" /></p>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/DW439IOgNp0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/04/21/diffplex-1-1-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Mercurial PowerShell Prompt</title>
		<link>http://matthewmanela.com/2010/04/01/a-mercurial-powershell-prompt/</link>
		<comments>http://matthewmanela.com/2010/04/01/a-mercurial-powershell-prompt/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 04:36:50 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Mercurial]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://blogs.msdn.com/matt/archive/2010/04/01/a-mercurial-powershell-prompt.aspx</guid>
		<description><![CDATA[Since switching to Mercurial I often use the “hg summary” command.     hg summary [--remote]     aliases: sum     summarize working directory state     &#160;&#160;&#160; This generates a brief summary of the working directory state, including     ... <a href="http://matthewmanela.com/2010/04/01/a-mercurial-powershell-prompt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since switching to Mercurial I often use the “hg summary” command.</p>

<blockquote><span style="font-size: xx-small;">hg summary [--remote]</span>

<span style="font-size: xx-small;"> </span><span style="font-size: xx-small;">aliases: sum </span>

<span style="font-size: xx-small;">summarize working directory state </span>

<span style="font-size: xx-small;"> This generates a brief summary of the working directory state, including

parents, branch, commit status, and available updates. </span>

<span style="font-size: xx-small;"> With the &#8211;remote option, this will check the default paths for incoming

and outgoing changes. This can be time-consuming.</span></blockquote>

<blockquote><br class="spacer_" /></blockquote>

<p>When you execute this command in a directory that is under source control you will see something like this:</p>

<blockquote><span style="font-size: xx-small;">parent: 35:008279cba4b4 tip

This is the commit message of the last checkin

branch: default

commit: 1 modified, 1 unknown

update: (current)</span></blockquote>

<p><br class="spacer_" /></p>

<p>I am usually most interested in which branch I am currently working in and what is the current status of my working directory.  Since I use PowerShell as my command line I decided to overwrite the default PowerShell prompt (PS &gt;) with some of the data from the “hg summary” command.</p>

<p>To do this I added the following code to my PowerShell profile:</p>

<pre class="brush:ps">
if (test-path function:\prompt)       { 
  $oldPrompt = ls function: | ? {$_.Name -eq "prompt"}
  remove-item -force function:\prompt 
  } 
  
function prompt() {
  $host.ui.rawui.WindowTitle = (get-location).Path
  
  $summary = hg summary 2&gt;&amp;1
  if($summary.Exception -eq $null) {
    $regex = "(?si)(parent:(?&lt;parent&gt;.*?)(\n|\r)+.*?)(branch:(?&lt;branch&gt;.*)\s)(commit:(?&lt;commit&gt;.*)\s)(update:(?&lt;update&gt;.*))";
    $summary = [System.String]::Join([System.Environment]::NewLine,$summary)
    $res = $summary -match $regex
    $format = "hg b:{0} c:{1}" -f $matches["branch"].Trim(), $matches["commit"].Trim()
    write-host ($format) -NoNewLine 
    write-host ("&gt;") -NoNewLine 
  }
  else {
    &amp; $oldPrompt
  }
 
  return " "
 
}
</pre>

<p>With this in place when you are in a directory that is not controlled by Mercurial you will see the normal prompt.  But once you enter a source controlled directory the prompt will look like:</p>

<blockquote><a href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/AMercurialPowershellPrompt_E54A/image_2.png"><img style="display: inline; border-width: 0px;" title="image" src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/AMercurialPowershellPrompt_E54A/image_thumb.png" border="0" alt="image" width="425" height="39" /></a></blockquote>

<p>This quickly shows me that I am in the default branch and I have 1 file modified and 1 unknown file in my directory.</p>

<p>After committing it will show:</p>

<p><a href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/AMercurialPowershellPrompt_E54A/image_4.png"><img style="display: inline; border-width: 0px;" title="image" src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/AMercurialPowershellPrompt_E54A/image_thumb_1.png" border="0" alt="image" width="248" height="39" /></a></p>

<p>Which shows that the current working directory is in a clean state.</p>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/Oz3Lv16Hk4o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/04/01/a-mercurial-powershell-prompt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DiffPlex 1.0 Released!!</title>
		<link>http://matthewmanela.com/2010/02/27/diffplex-1-0-released/</link>
		<comments>http://matthewmanela.com/2010/02/27/diffplex-1-0-released/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 02:10:00 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Codeplex]]></category>
		<category><![CDATA[DiffPlex]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blogs.msdn.com/matt/archive/2010/02/27/diffplex-1-0-released.aspx</guid>
		<description><![CDATA[The DiffPlex (http://diffplex.codeplex.com) project is now available on Codeplex!
The DiffPlex project is a combination of a .NET Diffing Library with a Silverlight and HTML diff viewer. It is released open source under the MS-PL license. 

The library... <a href="http://matthewmanela.com/2010/02/27/diffplex-1-0-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="font-size: 18px;">The <a href="http://diffplex.codeplex.com/">DiffPlex</a> (<a href="http://diffplex.codeplex.com">http://diffplex.codeplex.com</a>) project is now available on <a href="http://codeplex.com">Codeplex</a>!</p>

<p>The DiffPlex project is a combination of a .NET Diffing Library with a Silverlight and HTML diff viewer. It is released open source under the MS-PL license.</p>

<ul>
    <li>The library allows developers to embed diffing functionality inside their applications or websites. (<a href="http://diffplex.codeplex.com/wikipage?title=library&amp;referringTitle=Home">Click here to learn how to use the api</a>)</li>
</ul>

<p><a href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/DiffPlex1.0Released_FE1E/code_2.png"><img style="display: inline; border-width: 0px;" title="code" src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/DiffPlex1.0Released_FE1E/code_thumb.png" border="0" alt="code" width="654" height="236" /></a></p>

<ul>
    <li>The Silverlight viewer allows real-time diffing of documents. (<a href="http://diffplex.codeplex.com/wikipage?title=silverlight&amp;referringTitle=Home">Click here to try it out</a>)</li>
</ul>

<p><a href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/DiffPlex1.0Released_FE1E/silverlight_2.png"><img style="display: inline; border-width: 0px;" title="silverlight" src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/DiffPlex1.0Released_FE1E/silverlight_thumb.png" border="0" alt="silverlight" width="654" height="288" /></a></p>

<ul>
    <li>The website viewer shows how to embed diffing functionality inside of a website. (<a href="http://diffplex.codeplex.com/wikipage?title=website&amp;referringTitle=Home">Click here to learn more</a>)</li>
</ul>

<p><a href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/DiffPlex1.0Released_FE1E/websiteInput_2.png"><img style="display: inline; border-width: 0px;" title="websiteInput" src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/DiffPlex1.0Released_FE1E/websiteInput_thumb.png" border="0" alt="websiteInput" width="654" height="229" /></a></p>

<p><a href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/DiffPlex1.0Released_FE1E/websiteOutput_2.png"><img style="display: inline; border-width: 0px;" title="websiteOutput" src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/DiffPlex1.0Released_FE1E/websiteOutput_thumb.png" border="0" alt="websiteOutput" width="654" height="248" /></a></p>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/xMe5o8GGKBc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/02/27/diffplex-1-0-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snippet Designer 1.2 Beta Release with Visual Studio 2010 Support</title>
		<link>http://matthewmanela.com/2010/01/22/snippet-designer-1-2-beta-release-with-visual-studio-2010-support/</link>
		<comments>http://matthewmanela.com/2010/01/22/snippet-designer-1-2-beta-release-with-visual-studio-2010-support/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 14:52:00 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Codeplex]]></category>
		<category><![CDATA[Snippet Designer]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio Gallery]]></category>

		<guid isPermaLink="false">http://blogs.msdn.com/matt/archive/2010/01/22/snippet-designer-1-2-beta-release-with-visual-studio-2010-support.aspx</guid>
		<description><![CDATA[Yesterday I released Snippet Designer 1.2 Beta. 
Codeplex Page: http://snippetdesigner.codeplex.com/
Visual Studio Gallery Page: http://visualstudiogallery.msdn.microsoft.com/en-us/B08B0375-139E-41D7-AF9B-FAEE50F68392
This release contains several bug ... <a href="http://matthewmanela.com/2010/01/22/snippet-designer-1-2-beta-release-with-visual-studio-2010-support/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><P>Yesterday I released Snippet Designer 1.2 Beta. </P><br />
<P>Codeplex Page: <A title=http://snippetdesigner.codeplex.com/ href="http://snippetdesigner.codeplex.com/" mce_href="http://snippetdesigner.codeplex.com/">http://snippetdesigner.codeplex.com/</A></P><br />
<P>Visual Studio Gallery Page: <A title=http://visualstudiogallery.msdn.microsoft.com/en-us/B08B0375-139E-41D7-AF9B-FAEE50F68392 href="http://visualstudiogallery.msdn.microsoft.com/en-us/B08B0375-139E-41D7-AF9B-FAEE50F68392" mce_href="http://visualstudiogallery.msdn.microsoft.com/en-us/B08B0375-139E-41D7-AF9B-FAEE50F68392">http://visualstudiogallery.msdn.microsoft.com/en-us/B08B0375-139E-41D7-AF9B-FAEE50F68392</A></P><br />
<P>This release contains several bug fixes but more importantly it now includes support for Visual Studio 2010. </P><br />
<P>I am super excited for this since now you can install the Snippet Designer from inside of Visual Studio using the new extension manager. Just open up the extension manager and search for “Snippet Designer”.</P><br />
<P><A href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/Sni.2BetaReleasewithVisualStudio2010Supp_F28A/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/Sni.2BetaReleasewithVisualStudio2010Supp_F28A/image_2.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; WIDTH: 658px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 488px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/Sni.2BetaReleasewithVisualStudio2010Supp_F28A/image_thumb.png" width=817 height=566 mce_src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/Sni.2BetaReleasewithVisualStudio2010Supp_F28A/image_thumb.png"></A></P><br />
<P>Then you just need to install it and restart Visual Studio.</P><br />
<P><A href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/Sni.2BetaReleasewithVisualStudio2010Supp_F28A/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/Sni.2BetaReleasewithVisualStudio2010Supp_F28A/image_6.png"><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; WIDTH: 655px; DISPLAY: inline; HEIGHT: 475px; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/Sni.2BetaReleasewithVisualStudio2010Supp_F28A/image_thumb_2.png" width=815 height=565 mce_src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/Sni.2BetaReleasewithVisualStudio2010Supp_F28A/image_thumb_2.png"></A> </P><br />
<P>Enjoy!</P></p>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/IPeHdvOHD7w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/01/22/snippet-designer-1-2-beta-release-with-visual-studio-2010-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regex based Lexer with F#</title>
		<link>http://matthewmanela.com/2010/01/19/regex-based-lexer-with-f-2/</link>
		<comments>http://matthewmanela.com/2010/01/19/regex-based-lexer-with-f-2/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 14:52:00 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[F#]]></category>

		<guid isPermaLink="false">/b/matt/archive/2010/01/19/regex-lexer-with-f.aspx</guid>
		<description><![CDATA[This lexer allows you to define your regular expression based rules in a very declarative way using F# computation expressions. open Lexer
let definitions = 
    lexerDefinitions {
        do! addNextlineDefinition "NEWLINE" @"(\n\r)&#124;\n&#124;\r"
        do!... <a href="http://matthewmanela.com/2010/01/19/regex-based-lexer-with-f-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This lexer allows you to define your regular expression based rules in a very declarative way using F# computation expressions.</p>

<pre class="brush:f#">open Lexer
let definitions =
    lexerDefinitions {
        do! addNextlineDefinition "NEWLINE" @"(\n\r)|\n|\r"
        do! addIgnoreDefinition "WS"        @"\s"
        do! addDefinition "LET"             "let"
        do! addDefinition "ID"              "(?i)[a-z][a-z0-9]*"
        do! addDefinition "FLOAT"           @"[0-9]+\.[0-9]+"
        do! addDefinition "INT"             "[0-9]+"
        do! addDefinition "OPERATOR"      @"[+*=!/&amp;|&lt;&gt;\^\-]+"
    }</pre>

<p>With those defined you can execute the lexer with:</p>

<pre class="brush:f#">open Lexer
let lex input =
    try
        let y = Lexer.tokenize definitions input
        printfn "%A" y
    with e -&gt; printf "%s" e.Message
lex "let a = 5"</pre>

<p>Which will result in:</p>

<p style="padding-left: 30px;">seq [</p>

<p style="padding-left: 30px;">{name = "LET";
text = "let";
pos = 0;
column = 0;
line = 0;};</p>

<p style="padding-left: 30px;">{name = "ID";
text = "a";
pos = 4;
column = 4;
line = 0;};</p>

<p style="padding-left: 30px;">{name = "OPERATOR";
text = "=";
pos = 6;
column = 6;
line = 0;};</p>

<p style="padding-left: 30px;">{name = "INT";
text = "5";
pos = 8;
column = 8;
line = 0;}]</p>

<p>The lexer’s code is structured in three parts.  The first part is a state monad using the F# computation expressions.  This enables the declarative approach (seen above) to setup your lexer rules.</p>

<pre class="brush:f#">module StateMonad
type State&lt;'s,'a&gt; = State of ('s -&gt; ('a *'s))
let runState (State f) = f
type StateBuilder() =
    member b.Return(x) = State (fun s -&gt; (x,s))
    member b.Delay(f) = f() : State&lt;'s,'a&gt;
    member b.Zero() = State (fun s -&gt; ((),s))
    member b.Bind(State p,rest) = State (fun s -&gt; let v,s2 = p s in  (runState (rest v)) s2)
    member b.Get () = State (fun s -&gt; (s,s))
    member b.Put s = State (fun _ -&gt; ((),s))</pre>

<p>The second part are the combinators that are used to define your lexer rules.  There are three main combinators:  <strong>AddDefinition</strong> which lets you define a name / regex pair, <strong>AddIgnoreDefinition </strong>which lets you define characters which the lexer should ignore and <strong>AddNextlineDefinition </strong>which lets you define what characters determine a new line.</p>

<pre class="brush:f#">type LexDefinitions =
  {regexes : string list;
   names : string list;
   nextlines : bool list;
   ignores : bool list; }

let buildDefinition name pattern nextLine ignore =
    state {
        let! x = state.Get()
        do! state.Put { regexes = x.regexes @  [sprintf @"(?&lt;%s&gt;%s)" name pattern];
                        names = x.names @ [name];
                        nextlines  = x.nextlines @ [nextLine];
                        ignores = x.ignores @ [ignore]}
    }
let addDefinition name pattern = buildDefinition name pattern false false
let addIgnoreDefinition name pattern = buildDefinition name pattern false true
let addNextlineDefinition name pattern = buildDefinition name pattern true true</pre>

<p>And the final part is the code that performs the tokenizing.  It uses the Seq.unfold method to create the list of tokens.  Unfold is a function which takes a single item and generates a list of new items from it.  It is the opposite of Seq.fold which takes a list of items and turns it into a single item.  The tokenize function used Seq.unfold to generate each token while keeping track of the current line number, position in that line and position in the input string.</p>

<pre class="brush:f#">type Token =
    { name : string;
      text: string;
      pos :int;
      column: int;
      line: int }

let createLexDefs pb =  (runState pb) {regexes = []; names = []; nextlines = []; ignores = []} |&gt; snd
let tokenize lexerBuilder (str:string) =
    let patterns = createLexDefs lexerBuilder
    let combinedRegex =  Regex(List.fold (fun acc reg -&gt; acc + "|" + reg) (List.head patterns.regexes) (List.tail patterns.regexes))
    let nextlineMap = List.zip patterns.names patterns.nextlines |&gt; Map.ofList
    let ignoreMap = List.zip patterns.names patterns.ignores |&gt; Map.ofList
    let tokenizeStep (pos,line,lineStart) =
        if pos &gt;= str.Length then
            None
        else
            let getMatchedGroupName (grps:GroupCollection) names = List.find (fun (name:string) -&gt; grps.[name].Length &gt; 0) names
            match combinedRegex.Match(str, pos) with
                | mt when mt.Success &amp;&amp; pos = mt.Index  -&gt;
                    let groupName = getMatchedGroupName mt.Groups patterns.names
                    let column = mt.Index - lineStart
                    let nextPos = pos + mt.Length
                    let (nextLine, nextLineStart) = if nextlineMap.Item groupName then (line + 1, nextPos) else (line,lineStart)
                    let token = if ignoreMap.Item groupName
                                then None
                                else Some {
                                        name = groupName;
                                        text = mt.Value;
                                        pos = pos;
                                        line = line;
                                        column = column; }
                    Some(token, (nextPos, nextLine, nextLineStart))
                | otherwise -&gt;
                    let textAroundError = str.Substring(pos, min (pos + 5) str.Length)
                    raise (ArgumentException (sprintf "Lexing error occured at line:%d and column:%d near the text:%s" line (pos - lineStart) textAroundError))
    Seq.unfold tokenizeStep (0, 0, 0) |&gt; Seq.filter (fun x -&gt; x.IsSome) |&gt; Seq.map (fun x -&gt; x.Value)</pre>

<p>Lastly, here are the unit tests written using <a href="http://xunit.codeplex.com/">XUnit.Net</a>:</p>

<pre class="brush:f#">module LexerFacts
open Xunit
open Lexer
open System.Linq
let simpleDefs =
    state {
        do! addNextlineDefinition "NextLine"           "/"
        do! addIgnoreDefinition "IgnoredSymbol"        "=+"
        do! addDefinition "String"                     "[a-zA-Z]+"
        do! addDefinition "Number"                     "\d+"
        do! addDefinition "Name"                       "Matt"
    }

[&lt;Fact&gt;]
let Will_return_no_tokens_for_empty_string() =
    let tokens = Lexer.tokenize simpleDefs ""
    Assert.Equal(0, tokens.Count())

[&lt;Fact&gt;]
let Will_throw_exception_for_invalid_token() =
    let tokens = Lexer.tokenize simpleDefs "-"
    let ex = Assert.ThrowsDelegateWithReturn(fun () -&gt; upcast tokens.Count()) |&gt; Record.Exception
    Assert.NotNull(ex)
    Assert.True(ex :? System.ArgumentException)

[&lt;Fact&gt;]
let Will_ignore_symbols_defined_as_ignore_symbols() =
    let tokens = Lexer.tokenize simpleDefs "========="
    Assert.Equal(0, tokens.Count())

[&lt;Fact&gt;]
let Will_get_token_with_correct_position_and_type() =
    let tokens = Lexer.tokenize simpleDefs "1one=2=two"
    Assert.Equal("Number",tokens.ElementAt(2).name)
    Assert.Equal("2",tokens.ElementAt(2).text)
    Assert.Equal(5,tokens.ElementAt(2).pos)
    Assert.Equal(5,tokens.ElementAt(2).column)
    Assert.Equal(0,tokens.ElementAt(2).line)

[&lt;Fact&gt;]
let Will_tokenize_string_with_alernating_numbers_and_strings() =
    let tokens = Lexer.tokenize simpleDefs "1one2two"
    Assert.Equal("1",tokens.ElementAt(0).text)
    Assert.Equal("one",tokens.ElementAt(1).text)
    Assert.Equal("2",tokens.ElementAt(2).text)
    Assert.Equal("two",tokens.ElementAt(3).text)

[&lt;Fact&gt;]
let Will_increment_line_with_newline_symbol() =
    let tokens = Lexer.tokenize simpleDefs "1one/2two"
    Assert.Equal("Number",tokens.ElementAt(2).name)
    Assert.Equal("2",tokens.ElementAt(2).text)
    Assert.Equal(5,tokens.ElementAt(2).pos)
    Assert.Equal(0,tokens.ElementAt(2).column)
    Assert.Equal(1,tokens.ElementAt(2).line)

[&lt;Fact&gt;]
let Will_give_priority_to_lexer_definitions_defined_earlier() =
    let tokens = Lexer.tokenize simpleDefs "Matt"
    Assert.Equal("String",tokens.ElementAt(0).name)</pre>

<p>I attached a zip containing all the code mentioned above: <a href="http://matthewmanela.com/download/Lexer.zip" alt="F# Regex Lexer"><b>F# Regex Lexer</b></a></p>

<p><br class="spacer_" /></p>
<img src="http://feeds.feedburner.com/~r/Farblondzshet/~4/X2E-zcDncj8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2010/01/19/regex-based-lexer-with-f-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
