<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Matt Manela's Blog</title><link>http://blogs.msdn.com/matt/default.aspx</link><description>Farblondzshet in code.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Snippet Designer 1.2 Beta Release with Visual Studio 2010 Support</title><link>http://blogs.msdn.com/matt/archive/2010/01/22/snippet-designer-1-2-beta-release-with-visual-studio-2010-support.aspx</link><pubDate>Fri, 22 Jan 2010 14:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9951993</guid><dc:creator>MattManela</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/matt/comments/9951993.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9951993</wfw:commentRss><description>&lt;P&gt;Yesterday I released Snippet Designer 1.2 Beta. &lt;/P&gt;
&lt;P&gt;Codeplex Page: &lt;A title=http://snippetdesigner.codeplex.com/ href="http://snippetdesigner.codeplex.com/" mce_href="http://snippetdesigner.codeplex.com/"&gt;http://snippetdesigner.codeplex.com/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Visual Studio Gallery Page: &lt;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"&gt;http://visualstudiogallery.msdn.microsoft.com/en-us/B08B0375-139E-41D7-AF9B-FAEE50F68392&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This release contains several bug fixes but more importantly it now includes support for Visual Studio 2010. &lt;/P&gt;
&lt;P&gt;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”.&lt;/P&gt;
&lt;P&gt;&lt;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"&gt;&lt;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"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Then you just need to install it and restart Visual Studio.&lt;/P&gt;
&lt;P&gt;&lt;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"&gt;&lt;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"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9951993" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/matt/archive/tags/Snippet+Designer/default.aspx">Snippet Designer</category><category domain="http://blogs.msdn.com/matt/archive/tags/Codeplex/default.aspx">Codeplex</category><category domain="http://blogs.msdn.com/matt/archive/tags/Visual+Studio+Gallery/default.aspx">Visual Studio Gallery</category></item><item><title>Regex based Lexer with F#</title><link>http://blogs.msdn.com/matt/archive/2010/01/19/regex-lexer-with-f.aspx</link><pubDate>Tue, 19 Jan 2010 14:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9950348</guid><dc:creator>MattManela</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/matt/comments/9950348.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9950348</wfw:commentRss><description>&lt;P&gt;This lexer allows you to define your regular expression based rules in a very declarative way using F# computation expressions. &lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;open Lexer
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; definitions = 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    lexerDefinitions {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addNextlineDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;NEWLINE&lt;/SPAN&gt;" @"&lt;SPAN style="COLOR: #8b0000"&gt;(\n\r)|\n|\r&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addIgnoreDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;WS&lt;/SPAN&gt;"        @"&lt;SPAN style="COLOR: #8b0000"&gt;\s&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;LET&lt;/SPAN&gt;"             "&lt;SPAN style="COLOR: #8b0000"&gt;let&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;ID&lt;/SPAN&gt;"              "&lt;SPAN style="COLOR: #8b0000"&gt;(?i)[a-z][a-z0-9]*&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;FLOAT&lt;/SPAN&gt;"           @"&lt;SPAN style="COLOR: #8b0000"&gt;[0-9]+\.[0-9]+&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;INT&lt;/SPAN&gt;"             "&lt;SPAN style="COLOR: #8b0000"&gt;[0-9]+&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;OPERATOR&lt;/SPAN&gt;"      @"&lt;SPAN style="COLOR: #8b0000"&gt;[+*=!/&amp;amp;|&amp;lt;&amp;gt;\^\-]+&lt;/SPAN&gt;"   
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    }&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;With those defined you can execute the lexer with:&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;open Lexer
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; lex input = 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;try&lt;/SPAN&gt;    
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; y = Lexer.tokenize definitions input
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        printfn "&lt;SPAN style="COLOR: #8b0000"&gt;%A&lt;/SPAN&gt;" y
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;with&lt;/SPAN&gt; e -&amp;gt; printf "&lt;SPAN style="COLOR: #8b0000"&gt;%s&lt;/SPAN&gt;" e.Message
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;lex "&lt;SPAN style="COLOR: #8b0000"&gt;let a = 5&lt;/SPAN&gt;"&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will result in:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P align=left&gt;seq [{name = "LET"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text = "let"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pos = 0; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column = 0; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line = 0;}; {name = "ID"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text = "a"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pos = 4; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column = 4; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line = 0;}; {name = "OPERATOR"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text = "="; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pos = 6; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column = 6; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line = 0;}; {name = "INT"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text = "5"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pos = 8; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column = 8; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line = 0;}]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P align=left&gt;The lexer’s code is structured in three parts.&amp;nbsp; The first part is a state monad using the F# computation expressions.&amp;nbsp; This enables the declarative approach (seen above) to setup your lexer rules.&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;module StateMonad
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;type State&amp;lt;'s,'a&amp;gt; = State of ('s -&amp;gt; ('a *'s))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; runState (State f) = f
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;type StateBuilder() = 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    member b.Return(x) = State (fun s -&amp;gt; (x,s))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    member b.Delay(f) = f() : State&amp;lt;'s,'a&amp;gt;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    member b.Zero() = State (fun s -&amp;gt; ((),s))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    member b.Bind(State p,rest) = State (fun s -&amp;gt; &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; v,s2 = p s &lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt;  (runState (rest v)) s2)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    member b.&lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt; () = State (fun s -&amp;gt; (s,s))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    member b.Put s = State (fun _ -&amp;gt; ((),s))&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;The second part are the combinators that are used to define your lexer rules.&amp;nbsp; There are three main combinators:&amp;nbsp; &lt;STRONG&gt;AddDefinition&lt;/STRONG&gt; which lets you define a name / regex pair, &lt;STRONG&gt;AddIgnoreDefinition &lt;/STRONG&gt;which lets you define characters which the lexer should ignore and &lt;STRONG&gt;AddNextlineDefinition &lt;/STRONG&gt;which lets you define what characters determine a new line.&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;type LexDefinitions = 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;  {regexes : &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; list;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   names : &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; list;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   nextlines : bool list;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   ignores : bool list; }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; buildDefinition name pattern nextLine ignore =
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    state {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt;! x = state.&lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;()
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! state.Put { regexes = x.regexes @  [sprintf @"&lt;SPAN style="COLOR: #8b0000"&gt;(?&amp;lt;%s&amp;gt;%s)&lt;/SPAN&gt;" name pattern];
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                        names = x.names @ [name]; 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                        nextlines  = x.nextlines @ [nextLine];
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                        ignores = x.ignores @ [ignore]}
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; addDefinition name pattern = buildDefinition name pattern false false
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; addIgnoreDefinition name pattern = buildDefinition name pattern false true
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; addNextlineDefinition name pattern = buildDefinition name pattern true true    &lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;And the final part is the code that performs the tokenizing.&amp;nbsp; It uses the Seq.unfold method to create the list of tokens.&amp;nbsp; Unfold is a function which takes a single item and generates a list of new items from it.&amp;nbsp; It is the opposite of Seq.fold which takes a list of items and turns it into a single item.&amp;nbsp; 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.&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;type Token = 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    { name : &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;      text: &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;; 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;      pos :&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;      column: &lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;      line: &lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt; }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; createLexDefs pb =  (runState pb) {regexes = []; names = []; nextlines = []; ignores = []} |&amp;gt; snd
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt; 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; tokenize lexerBuilder (str:&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;) = 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; patterns = createLexDefs lexerBuilder
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; combinedRegex =  Regex(List.fold (fun acc reg -&amp;gt; acc + "&lt;SPAN style="COLOR: #8b0000"&gt;|&lt;/SPAN&gt;" + reg) (List.head patterns.regexes) (List.tail patterns.regexes))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; nextlineMap = List.zip patterns.names patterns.nextlines |&amp;gt; Map.ofList
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; ignoreMap = List.zip patterns.names patterns.ignores |&amp;gt; Map.ofList
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; tokenizeStep (pos,line,lineStart) = 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; pos &amp;gt;= str.Length &lt;SPAN style="COLOR: #0000ff"&gt;then&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            None
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; getMatchedGroupName (grps:GroupCollection) names = List.find (fun (name:&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;) -&amp;gt; grps.[name].Length &amp;gt; 0) names
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;match&lt;/SPAN&gt; combinedRegex.&lt;SPAN style="COLOR: #0000ff"&gt;Match&lt;/SPAN&gt;(str, pos) &lt;SPAN style="COLOR: #0000ff"&gt;with&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                | mt when mt.Success &amp;amp;&amp;amp; pos = mt.Index  -&amp;gt; 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; groupName = getMatchedGroupName mt.Groups patterns.names
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; column = mt.Index - lineStart
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; nextPos = pos + mt.Length
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; (nextLine, nextLineStart) = &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; nextlineMap.Item groupName &lt;SPAN style="COLOR: #0000ff"&gt;then&lt;/SPAN&gt; (line + 1, nextPos) &lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt; (line,lineStart)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; token = &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; ignoreMap.Item groupName 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                                &lt;SPAN style="COLOR: #0000ff"&gt;then&lt;/SPAN&gt; None 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                                &lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt; Some {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                                        name = groupName; 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                                        text = mt.Value; 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                                        pos = pos; 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                                        line = line; 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                                        column = column; }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    Some(token, (nextPos, nextLine, nextLineStart))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                | otherwise -&amp;gt; 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; textAroundError = str.Substring(pos, min (pos + 5) str.Length)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    raise (ArgumentException (sprintf "&lt;SPAN style="COLOR: #8b0000"&gt;Lexing error occured at line:%d and column:%d near the text:%s&lt;/SPAN&gt;" line (pos - lineStart) textAroundError))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Seq.unfold tokenizeStep (0, 0, 0) |&amp;gt; Seq.&lt;SPAN style="COLOR: #0000ff"&gt;filter&lt;/SPAN&gt; (fun x -&amp;gt; x.IsSome) |&amp;gt; Seq.map (fun x -&amp;gt; x.Value)&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;Lastly, here are the unit tests written using &lt;A href="http://xunit.codeplex.com/" mce_href="http://xunit.codeplex.com/"&gt;XUnit.Net&lt;/A&gt;:&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;module LexerFacts
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;open Xunit
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;open Lexer
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;open System.Linq
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; simpleDefs = 
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    state {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addNextlineDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;NextLine&lt;/SPAN&gt;"           "&lt;SPAN style="COLOR: #8b0000"&gt;/&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addIgnoreDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;IgnoredSymbol&lt;/SPAN&gt;"        "&lt;SPAN style="COLOR: #8b0000"&gt;=+&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;String&lt;/SPAN&gt;"                     "&lt;SPAN style="COLOR: #8b0000"&gt;[a-zA-Z]+&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;Number&lt;/SPAN&gt;"                     "&lt;SPAN style="COLOR: #8b0000"&gt;\d+&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;do&lt;/SPAN&gt;! addDefinition "&lt;SPAN style="COLOR: #8b0000"&gt;Name&lt;/SPAN&gt;"                       "&lt;SPAN style="COLOR: #8b0000"&gt;Matt&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;[&amp;lt;Fact&amp;gt;]
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; Will_return_no_tokens_for_empty_string() =
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;  
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; tokens = Lexer.tokenize simpleDefs "&lt;SPAN style="COLOR: #8b0000"&gt;&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal(0, tokens.Count())
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;[&amp;lt;Fact&amp;gt;]
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; Will_throw_exception_for_invalid_token() =
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;  
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; tokens = Lexer.tokenize simpleDefs "&lt;SPAN style="COLOR: #8b0000"&gt;-&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; ex = Assert.ThrowsDelegateWithReturn(fun () -&amp;gt; upcast tokens.Count()) |&amp;gt; Record.Exception
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.NotNull(ex)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.True(ex :? System.ArgumentException)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;[&amp;lt;Fact&amp;gt;]
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; Will_ignore_symbols_defined_as_ignore_symbols() =
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;  
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; tokens = Lexer.tokenize simpleDefs "&lt;SPAN style="COLOR: #8b0000"&gt;=========&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal(0, tokens.Count())
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;[&amp;lt;Fact&amp;gt;]
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; Will_get_token_with_correct_position_and_type() =
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;  
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; tokens = Lexer.tokenize simpleDefs "&lt;SPAN style="COLOR: #8b0000"&gt;1one=2=two&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal("&lt;SPAN style="COLOR: #8b0000"&gt;Number&lt;/SPAN&gt;",tokens.ElementAt(2).name)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal("&lt;SPAN style="COLOR: #8b0000"&gt;2&lt;/SPAN&gt;",tokens.ElementAt(2).text)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal(5,tokens.ElementAt(2).pos)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal(5,tokens.ElementAt(2).column)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal(0,tokens.ElementAt(2).line)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;[&amp;lt;Fact&amp;gt;]
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; Will_tokenize_string_with_alernating_numbers_and_strings() =
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;  
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; tokens = Lexer.tokenize simpleDefs "&lt;SPAN style="COLOR: #8b0000"&gt;1one2two&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal("&lt;SPAN style="COLOR: #8b0000"&gt;1&lt;/SPAN&gt;",tokens.ElementAt(0).text)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal("&lt;SPAN style="COLOR: #8b0000"&gt;one&lt;/SPAN&gt;",tokens.ElementAt(1).text)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal("&lt;SPAN style="COLOR: #8b0000"&gt;2&lt;/SPAN&gt;",tokens.ElementAt(2).text)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal("&lt;SPAN style="COLOR: #8b0000"&gt;two&lt;/SPAN&gt;",tokens.ElementAt(3).text)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;[&amp;lt;Fact&amp;gt;]
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; Will_increment_line_with_newline_symbol() =
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;  
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; tokens = Lexer.tokenize simpleDefs "&lt;SPAN style="COLOR: #8b0000"&gt;1one/2two&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal("&lt;SPAN style="COLOR: #8b0000"&gt;Number&lt;/SPAN&gt;",tokens.ElementAt(2).name)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal("&lt;SPAN style="COLOR: #8b0000"&gt;2&lt;/SPAN&gt;",tokens.ElementAt(2).text)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal(5,tokens.ElementAt(2).pos)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal(0,tokens.ElementAt(2).column)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal(1,tokens.ElementAt(2).line)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;[&amp;lt;Fact&amp;gt;]
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; Will_give_priority_to_lexer_definitions_defined_earlier() =
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;  
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;let&lt;/SPAN&gt; tokens = Lexer.tokenize simpleDefs "&lt;SPAN style="COLOR: #8b0000"&gt;Matt&lt;/SPAN&gt;"
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    Assert.Equal("&lt;SPAN style="COLOR: #8b0000"&gt;String&lt;/SPAN&gt;",tokens.ElementAt(0).name)&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I attached a zip (&lt;A href="http://blogs.msdn.com/matt/attachment/9950348.ashx" mce_href="http://blogs.msdn.com/matt/attachment/9950348.ashx"&gt;Lexer.zip&lt;/A&gt;) containing all the code mentioned above.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9950348" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/matt/attachment/9950348.ashx" length="2225" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/matt/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/matt/archive/tags/F_2300_/default.aspx">F#</category></item><item><title>Count the number of lines in your project with one line of Powershell</title><link>http://blogs.msdn.com/matt/archive/2009/12/11/count-the-number-of-lines-in-your-project-with-one-line-of-powershell.aspx</link><pubDate>Fri, 11 Dec 2009 14:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9935693</guid><dc:creator>MattManela</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/matt/comments/9935693.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9935693</wfw:commentRss><description>&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;ls * -recurse -include *.aspx, *.ascx, *.cs, *.ps1 | Get-Content | Measure-Object -Line&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Just replace the file extensions with the ones you use in your project.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9935693" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>Useful Moq Extension Method</title><link>http://blogs.msdn.com/matt/archive/2009/11/24/useful-moq-extension-method.aspx</link><pubDate>Wed, 25 Nov 2009 00:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9928293</guid><dc:creator>MattManela</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/matt/comments/9928293.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9928293</wfw:commentRss><description>&lt;P&gt;I have been working with ASP .NET MVC and I use the &lt;A href="http://code.google.com/p/moq/" mce_href="http://code.google.com/p/moq/"&gt;Moq&lt;/A&gt; mocking library to help test the code I write.&amp;nbsp;&amp;nbsp; Often in ASP MVC anonymous objects are passed around as function arguments.&amp;nbsp; This is especially common in calls to RouteUrl.&amp;nbsp; Since I want to be able to test this and verify that it is called correctly I wrote a handy extension method to make it easier called &lt;STRONG&gt;AsMatch&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;To be able to test the UrlHelper (since it doesn't have an interface or virtual methods) I wrote a simple wrapper around it with an interface to enable testing.&amp;nbsp; Using that with this extension method makes testing route generation a breeze.&lt;/P&gt;
&lt;P&gt;Given a call to generate a Url like this:&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;var url = Url.RouteUrl("&lt;SPAN style="COLOR: #8b0000"&gt;Show&lt;/SPAN&gt;", &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; { projectName="&lt;SPAN style="COLOR: #8b0000"&gt;matt&lt;/SPAN&gt;" });&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;You can write a setup on your Mock of the Url helper using a similar syntax:&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;UrlHelperMock
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;.Setup(x =&amp;gt; x.RouteUrl("&lt;SPAN style="COLOR: #8b0000"&gt;Show&lt;/SPAN&gt;",&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;{ projectName="&lt;SPAN style="COLOR: #8b0000"&gt;matt&lt;/SPAN&gt;"}.AsMatch()))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;.Return("&lt;SPAN style="COLOR: #8b0000"&gt;someUrlToTest&lt;/SPAN&gt;");&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the code that defines the AsMatch extension method:&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&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;class&lt;/SPAN&gt; ObjectMoqExtensions
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&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;object&lt;/SPAN&gt; AsMatch(&lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; @&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; Match&amp;lt;&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&amp;gt;.Create(testObject =&amp;gt; DoObjectsMatch(@&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;, testObject));
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;bool&lt;/SPAN&gt; DoObjectsMatch(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;1, &lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;2)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            var props1 = ToDictionary(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;1);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            var props2 = ToDictionary(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;2);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            var query = from prop1 &lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt; props1
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                        join prop2 &lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt; props2 on prop1.Key equals prop2.Key
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                        select prop1.Value.Equals(prop2.Value);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; query.Count(x =&amp;gt; x) == Math.Max(props1.Count(), props2.Count());
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt; Dictionary&amp;lt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&amp;gt; ToDictionary(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; @&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            var dictionary = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; Dictionary&amp;lt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&amp;gt;();
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            var properties = TypeDescriptor.GetProperties(@&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;foreach&lt;/SPAN&gt; (PropertyDescriptor property &lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt; properties)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                dictionary.Add(property.Name, property.GetValue(@&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;));
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; dictionary;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    }&lt;/PRE&gt;&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9928293" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/matt/archive/tags/ASP+.NET+MVC/default.aspx">ASP .NET MVC</category><category domain="http://blogs.msdn.com/matt/archive/tags/Moq/default.aspx">Moq</category></item><item><title>Converting RTF to HTML</title><link>http://blogs.msdn.com/matt/archive/2009/09/28/converting-rtf-to-html.aspx</link><pubDate>Mon, 28 Sep 2009 21:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9900386</guid><dc:creator>MattManela</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/matt/comments/9900386.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9900386</wfw:commentRss><description>&lt;P&gt;Have you ever had the desire to convert some RTF text into HTML? Probably not. But if you do, then you are in luck! I recently had the need to do this conversion and after some searching found out a way to do it by enhancing a sample distributed in the MSDN library.&amp;nbsp; The sample is called: &lt;A href="http://msdn.microsoft.com/en-us/library/aa972129.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa972129.aspx"&gt;XAML to HTML Conversion Demo&lt;/A&gt;.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The sample has code which converts HTML to and from a XAML Flow Document.&amp;nbsp; But this doesn’t make things easier until you realize that there is a way to convert RTF to XAML easily. The key is to use &lt;A title=http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.aspx href="http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.aspx"&gt;System.Windows.Controls.RichTextBox&lt;/A&gt; which can load RTF from a stream and save it as XAML.&amp;nbsp; This conversion is shown below:&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; ConvertRtfToXaml(&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; rtfText)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            var richTextBox = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; RichTextBox();
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(rtfText)) &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; "&lt;SPAN style="COLOR: #8b0000"&gt;&lt;/SPAN&gt;";
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            var textRange = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; (var rtfMemoryStream = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; MemoryStream())
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                &lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; (var rtfStreamWriter = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; StreamWriter(rtfMemoryStream))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    rtfStreamWriter.Write(rtfText);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    rtfStreamWriter.Flush();
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    rtfMemoryStream.Seek(0, SeekOrigin.Begin);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    textRange.Load(rtfMemoryStream, DataFormats.Rtf);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; (var rtfMemoryStream = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; MemoryStream())
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                textRange = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                textRange.Save(rtfMemoryStream, DataFormats.Xaml);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                rtfMemoryStream.Seek(0, SeekOrigin.Begin);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                &lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; (var rtfStreamReader = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; StreamReader(rtfMemoryStream))
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                    &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; rtfStreamReader.ReadToEnd();
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;                }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        }&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;With this code we have all we need to convert RTF to HTML. I modified the sample to add this RTF To XAML conversation and then I run that XAML through HTML converter which results in the HTML text. I added an interface to these conversion utilities and converted the sample into a library so that I would be able to use it from other projects.&amp;nbsp; Here is the interface:&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt; &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;interface&lt;/SPAN&gt; IMarkupConverter
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; ConvertXamlToHtml(&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; xamlText);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; ConvertHtmlToXaml(&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; htmlText);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; ConvertRtfToHtml(&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; rtfText);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt; MarkupConverter : IMarkupConverter
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; ConvertXamlToHtml(&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; xamlText)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; HtmlFromXamlConverter.ConvertXamlToHtml(xamlText, &lt;SPAN style="COLOR: #0000ff"&gt;false&lt;/SPAN&gt;);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; ConvertHtmlToXaml(&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; htmlText)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; HtmlToXamlConverter.ConvertHtmlToXaml(htmlText, &lt;SPAN style="COLOR: #0000ff"&gt;true&lt;/SPAN&gt;);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; ConvertRtfToHtml(&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; rtfText)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        {
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; RtfToHtmlConverter.ConvertRtfToHtml(rtfText);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;    }&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;With this I am now able to convert from RTF to HTML.&amp;nbsp; However, there is one catch - the conversion uses the RichTextBox WPF control which requires a single threaded apartment (STA).&amp;nbsp; Therefore in order to run your code that calls the ConvertRtfToHtml function, it must also be running in a STA.&amp;nbsp; If you can’t have your program run in a STA then you must create a new STA thread to run the conversion. Like this:&lt;/P&gt;&lt;PRE style="BORDER-BOTTOM: #cecece 1px solid; BORDER-LEFT: #cecece 1px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fbfbfb; MIN-HEIGHT: 40px; PADDING-LEFT: 5px; WIDTH: 650px; PADDING-RIGHT: 5px; OVERFLOW: auto; BORDER-TOP: #cecece 1px solid; BORDER-RIGHT: #cecece 1px solid; PADDING-TOP: 5px"&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;MarkupConverter markupConverter = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; MarkupConverter();
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; ConvertRtfToHtml(&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; rtfText)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;{
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   var thread = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; Thread(ConvertRtfInSTAThread);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   var threadData = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; ConvertRtfThreadData { RtfText = rtfText };
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   thread.SetApartmentState(ApartmentState.STA);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   thread.Start(threadData);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   thread.Join();
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; threadData.HtmlText;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;}
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; ConvertRtfInSTAThread(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; rtf)
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;{
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   var threadData = rtf &lt;SPAN style="COLOR: #0000ff"&gt;as&lt;/SPAN&gt; ConvertRtfThreadData;
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   threadData.HtmlText = markupConverter.ConvertRtfToHtml(threadData.RtfText);
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;}
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;        
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt; ConvertRtfThreadData
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;{
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; RtfText { &lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: #0000ff"&gt;set&lt;/SPAN&gt;; }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;   &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; HtmlText { &lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: #0000ff"&gt;set&lt;/SPAN&gt;; }
&lt;/PRE&gt;&lt;PRE style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 11px"&gt;}&lt;/PRE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the zip contain the code for the Markup converter: &lt;A href="http://blogs.msdn.com/matt/attachment/9900386.ashx" mce_href="http://blogs.msdn.com/matt/attachment/9900386.ashx"&gt;MarkupConverter.zip&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9900386" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/matt/attachment/9900386.ashx" length="64021" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/matt/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/matt/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/matt/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.msdn.com/matt/archive/tags/RTF/default.aspx">RTF</category><category domain="http://blogs.msdn.com/matt/archive/tags/HTML/default.aspx">HTML</category></item><item><title>I finally got fed up with Enum.Parse</title><link>http://blogs.msdn.com/matt/archive/2009/07/24/i-finally-got-fed-up-with-enum-parse.aspx</link><pubDate>Fri, 24 Jul 2009 19:02:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9847679</guid><dc:creator>MattManela</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/matt/comments/9847679.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9847679</wfw:commentRss><description>&lt;p&gt;I don’t know why I didn’t do this long ago, but I am done writing this:&lt;/p&gt;  &lt;div&gt;   &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;var val = (SomeEnum)Enum.Parse(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(SomeEnum),”someString”);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;I have typed this too many times and it annoys me.&amp;#160; &lt;/p&gt;

&lt;p&gt;I wrote a small extension method on the string type to make this better:&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&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;class&lt;/span&gt; StringExtensions
{
    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; T ToEnum&amp;lt;T&amp;gt;(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; @&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;)
    {
        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (T)Enum.Parse(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt; (T), @&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;);
    }
}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;With this I can now write the previous line as:&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;var val = &lt;span style="color: #006080"&gt;&amp;quot;someString&amp;quot;&lt;/span&gt;.ToEnum&amp;lt;SomeEnum&amp;gt;()&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;
It is a bit shorter and I think much more readable.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9847679" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/matt/archive/tags/Programming/default.aspx">Programming</category></item><item><title>DRY and Unit Tests don’t mix well</title><link>http://blogs.msdn.com/matt/archive/2009/07/12/dry-and-unit-tests-don-t-mix-well.aspx</link><pubDate>Mon, 13 Jul 2009 06:08:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9830902</guid><dc:creator>MattManela</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/matt/comments/9830902.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9830902</wfw:commentRss><description>&lt;p&gt;When reading&lt;em&gt; &lt;/em&gt;source code, I sometimes come across unappealing code(sometimes even my own).&amp;#160; However, there is one kind of “bad code” I see quite frequently.&amp;#160; It is a set of unit tests which have had the &lt;a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself" target="_blank"&gt;DRY (Don't Repeat Yourself)&lt;/a&gt; principle unduly forced upon them.&amp;#160; DRY is the idea that you shouldn’t have to write the same code over and over; abstract it in a function or a class and just call the abstraction.&amp;#160; This is all well and good in most cases, but I find it misguided when applied to a test case.&amp;#160; &lt;/p&gt;  &lt;p&gt;A test case should be like a simple short story.&amp;#160; The characters are introduced, action/conflict occurs and then resolution takes place (sometimes with a moral).&amp;#160; This (kind of) corresponds to the 3 steps of a unit test: arrange, act and assert.&amp;#160; You arrange and setup what you need for your test to run, you perform the action that you are trying to test and then you assert the results. The issue I find is that a coder, in attempting to apply DRY to his test cases, will abstract away all of the arrange step into a function often with a name like SetupExpectations or just Setup.&amp;#160; This goes against the point of a test case. A test case needs to be concise and tell me everything I need to know about how that one bit of functionality works. I don’t want to jump around the test class trying to read one test case. To me, this is like reading a book that says, “If you want to learn about the characters in this book please open this other book.”&amp;#160; This doesn’t stop you from understanding the test, but it slows you down…and is just annoying.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;That is why I will come out and say &lt;strong&gt;do not apply DRY haphazardly to test cases&lt;/strong&gt;. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9830902" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/matt/archive/tags/testing/default.aspx">testing</category></item><item><title>How to teach your girlfriend Hexadecimal?</title><link>http://blogs.msdn.com/matt/archive/2009/05/06/how-to-teach-your-girlfriend-hexadecimal.aspx</link><pubDate>Wed, 06 May 2009 23:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9592379</guid><dc:creator>MattManela</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/matt/comments/9592379.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9592379</wfw:commentRss><description>&lt;P&gt;It is an age old question: How do you teach your girlfriend hex? &lt;/P&gt;  &lt;P&gt;I encountered this problem when I was a web developer in college for a late night student activities program aptly named  Late Nite Binghamton.  My co-worker and girlfriend &lt;A href="http://baconwrappedlife.com/" mce_href="http://baconwrappedlife.com/"&gt;Mallory&lt;/A&gt; was a graduate assistant for the program and had many ideas for how to make the website better and more engaging.  While working with her she would often see me typing in the hexadecimal color codes in css such as:&lt;/P&gt;  &lt;P&gt;color: #F24A7D&lt;/P&gt;  &lt;P&gt;As I am inept with what color look good (I often say that I never learnt colors) I would often ask her for help with picking out colors and I decided that if she was able to give me these colors in their hex color codes it would make us more efficient :) I sat her down and described to her how they work but after talking for a bit I realized that although she understood everything that I said she wouldn’t gain a feel for what hex numbers related to what colors just from hearing me talk.&lt;/P&gt;  &lt;P&gt;In order to help her gain this feel I created a simple game called &lt;A href="http://mallory.jemts.com" mce_href="http://mallory.jemts.com"&gt;The Mallory Color Guessing Game&lt;/A&gt;.  The game is a webpage which shows you a large colored box and it is your job to guess what the hex color code is.  &lt;/P&gt;  &lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/HowtoteachyourgirlfriendHexadecimal_EAD0/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/HowtoteachyourgirlfriendHexadecimal_EAD0/image_2.png"&gt;&lt;IMG style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/HowtoteachyourgirlfriendHexadecimal_EAD0/image_thumb.png" mce_src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/HowtoteachyourgirlfriendHexadecimal_EAD0/image_thumb.png" width="634" height="484"&gt;&lt;/A&gt; &lt;/P&gt;  &lt;P&gt; &lt;/P&gt;  &lt;P&gt;After you guess it tells you how close you were to the actual color:&lt;/P&gt;  &lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/HowtoteachyourgirlfriendHexadecimal_EAD0/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/HowtoteachyourgirlfriendHexadecimal_EAD0/image_4.png"&gt;&lt;IMG style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/HowtoteachyourgirlfriendHexadecimal_EAD0/image_thumb_1.png" mce_src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/HowtoteachyourgirlfriendHexadecimal_EAD0/image_thumb_1.png" width="638" height="484"&gt;&lt;/A&gt; &lt;/P&gt;  &lt;P&gt; &lt;/P&gt;  &lt;P&gt;This game was a hit! Mallory loved it and she would compete with me to see who could guess the color the best.  Pretty quickly she gained a feel for what the hex digits meant and what color they represented. And that is how I taught my girlfriend hex!&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;NOTE: Mallory consistently gets over 80% at the Mallory Color Guessing Game. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9592379" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Personal/default.aspx">Personal</category></item><item><title>Snippet Designer in April’s MSDN Magazine!</title><link>http://blogs.msdn.com/matt/archive/2009/04/14/snippet-designer-in-april-s-msdn-magazine.aspx</link><pubDate>Wed, 15 Apr 2009 02:33:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9549664</guid><dc:creator>MattManela</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/matt/comments/9549664.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9549664</wfw:commentRss><description>&lt;p&gt;I am excited to announce that the &lt;a href="http://snippetdesigner.codeplex.com/"&gt;Snippet Designer&lt;/a&gt; is featured in the April issue of MSDN Magazine.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/dd569763.aspx#id0080016"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="msdnMag" border="0" alt="msdnMag" align="left" src="http://blogs.msdn.com/blogfiles/matt/WindowsLiveWriter/SnippetDesignerinAprilsMSDNMagazine_E895/msdnMag_3.gif" width="189" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;It is featured in the &lt;a href="http://msdn.microsoft.com/en-us/magazine/dd569763.aspx#id0080016"&gt;Toolbox column&lt;/a&gt; where they highlight useful tools and blogs. Here is a snippet of what it says:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Creating Code Snippets is a lot easier when using Snippet Designer (version 1.1), a free, open-source Add-In for Visual Studio 2008 for creating and editing Code Snippets directly within the IDE. Once you install it, creating a new Code Snippet is as easy as going to the File menu and creating a new Code Snippet File.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;That is so cool! If you are interested go and download the &lt;a href="http://snippetdesigner.codeplex.com/"&gt;Snippet Designer&lt;/a&gt; from the Codeplex website and give me more feedback.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Also, in the same article my friend &lt;a href="http://blogs.msdn.com/saraford/"&gt;Sara Ford&lt;/a&gt; had her blog featured.&amp;#160; When I found out the Snippet Designer and Sara’s blog were in the magazine I quickly emailed to ask Sara if she knew about it.&amp;#160; She already did and also had an extra copy of the magazine for me!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9549664" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Personal/default.aspx">Personal</category><category domain="http://blogs.msdn.com/matt/archive/tags/Snippet+Designer/default.aspx">Snippet Designer</category></item><item><title>A functional take on console program loop in F#</title><link>http://blogs.msdn.com/matt/archive/2009/04/13/a-functional-take-on-console-program-loop-in-f.aspx</link><pubDate>Tue, 14 Apr 2009 07:51:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9547889</guid><dc:creator>MattManela</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/matt/comments/9547889.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9547889</wfw:commentRss><description>&lt;p&gt;Often when learning a new technology I start with a simple console application in which the program is run in a loop it continues to prompt you for more input until you give some command like quit or exit or whatever you choose:&lt;/p&gt;  &lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 418px; padding-right: 5px; height: 133px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 11px"&gt;Enter input: someInput&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 11px"&gt;someOutput&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 11px"&gt;Enter input: otherInput&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 11px"&gt;someoutPut&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 11px"&gt;Enter input: quit&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 11px"&gt;Thanks! Come again!&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;The code for this is in an imperative language is usually something like:&lt;/p&gt;

&lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     Console.Write(&lt;span style="color: #006080"&gt;&amp;quot;\nEnter input:&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     var line = Console.ReadLine();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(line == &lt;span style="color: #006080"&gt;&amp;quot;quit&amp;quot;&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     doSomething(line);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt; }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt; Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;Thanks! Come Again&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;While reading some F# samples, I saw some code doing essentially the same thing which looked something like:&lt;/p&gt;

&lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; Console.Write &lt;span style="color: #006080"&gt;&amp;quot;\nEnter input:&amp;quot;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;let&lt;/span&gt; mutable input = Console.ReadLine()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;while&lt;/span&gt; input &amp;lt;&amp;gt; &lt;span style="color: #006080"&gt;&amp;quot;quit&amp;quot;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;do&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; input &amp;lt;&amp;gt; &lt;span style="color: #006080"&gt;&amp;quot;quit&amp;quot;&lt;/span&gt; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;then&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;         doSomething input&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;         Console.Write &lt;span style="color: #006080"&gt;&amp;quot;\nEnter input:&amp;quot;&lt;/span&gt; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;         input &amp;lt;- Console.ReadLine()&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Now this just feels dirty! In a functional language explicit loop constructs like a while loop feel wrong.&amp;#160; I different way of doing this which is more functional is to create an infinite list of actions.&amp;#160; Where each action represents one iteration of any of the above loops. Then you just execute each action until some condition is met (like seeing the input “quit”).&lt;/p&gt;

&lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; height: 255px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;let&lt;/span&gt; action = fun _ -&amp;gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;     Console.Write &lt;span style="color: #006080"&gt;&amp;quot;\nEnter input: &amp;quot;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     Console.ReadLine()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;let&lt;/span&gt; readlines = Seq.init_infinite (fun _ -&amp;gt; action())&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;let&lt;/span&gt; run item = &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; item = &lt;span style="color: #006080"&gt;&amp;quot;quit&amp;quot;&lt;/span&gt; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;then&lt;/span&gt; Some(item) &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;                     parse item &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;                     None&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt; Seq.first run readlines |&amp;gt; ignore&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt; Console.WriteLine &lt;span style="color: #006080"&gt;&amp;quot;Thanks! Come Again&amp;quot;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This code makes use of the Seq.init_infinite which create a infinite sequence and Seq.first which enumerates the sequence until the passed in function returns Some.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9547889" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/matt/archive/tags/F_2300_/default.aspx">F#</category></item><item><title>Synchronizing Scrollbars using JQuery</title><link>http://blogs.msdn.com/matt/archive/2009/03/19/synchronizing-scrollbars-using-jquery.aspx</link><pubDate>Thu, 19 Mar 2009 23:29:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9491068</guid><dc:creator>MattManela</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/matt/comments/9491068.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9491068</wfw:commentRss><description>&lt;p&gt;I just wrote this simple plugin for &lt;a href="http://jquery.com/"&gt;JQuery&lt;/a&gt; which lets you synchronize the scroll bars of any collection of elements.&amp;#160; This lets you move the scrollbar of one div it have the scrollbars’ of the rest of the divs move the same exact amount.&lt;/p&gt;  &lt;p&gt;Here is the code:&lt;/p&gt;  &lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;   &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; jQuery.fn.synchronizeScroll = &lt;span style="color: #0000ff"&gt;function&lt;/span&gt;() {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;            &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; elements = &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (elements.length &amp;lt;= 1) &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;            elements.scroll(&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;            &lt;span style="color: #0000ff"&gt;function&lt;/span&gt;() {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;                &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; left = $(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).scrollLeft();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;                &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; top = $(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).scrollTop();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;                elements.each(&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;                &lt;span style="color: #0000ff"&gt;function&lt;/span&gt;() {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ($(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).scrollLeft() != left) $(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).scrollLeft(left);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ($(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).scrollTop() != top) $(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).scrollTop(top);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;                }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;                );&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;            });&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt;        }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Using this is SUPER simple.&amp;#160; Lets say you have several divs defined as:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&amp;lt;div class=”scrollDiv” style=”overflow:auto;”&amp;gt; .. some large content&amp;lt;/div&amp;gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To synchronize the scrollbars’ on all divs with the class scrollDiv all you need to write is:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;$(“.scrollDiv”).synchronizeScroll();&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9491068" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/matt/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://blogs.msdn.com/matt/archive/tags/JQuery/default.aspx">JQuery</category></item><item><title>Prime Factorization using Unfold in Haskell</title><link>http://blogs.msdn.com/matt/archive/2009/03/17/prime-factorization-using-unfold-in-haskell.aspx</link><pubDate>Tue, 17 Mar 2009 16:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9483663</guid><dc:creator>MattManela</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/matt/comments/9483663.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9483663</wfw:commentRss><description>&lt;P&gt;I randomly yesterday started thinking about the &lt;STRONG&gt;unfoldr &lt;/STRONG&gt;function in &lt;A href="http://en.wikipedia.org/wiki/Haskell_(programming_language)" target=_blank mce_href="http://en.wikipedia.org/wiki/Haskell_(programming_language)"&gt;Haskell&lt;/A&gt; while working out at the gym (how nerdy is that, I am lifting iron but thinking of functional programming). Unfoldr take a single and an unfolding function and turns it into a list (the opposite of fold).&amp;nbsp; At the gym I was thinking about an application where I can use this and I decided that when I got home I would use it to write a prime factorization function.&amp;nbsp; This is a method that when given a number returns the list of its prime factors. &lt;/P&gt;
&lt;P&gt;It was easy to write the only part I am not pleased about is the code I used to deal with tuples.&amp;nbsp; It seems clumsy and I am still looking for a way to clean that up. &lt;/P&gt;
&lt;P&gt;One note: The code below references a list of prime numbers called primes , which is not shown. &lt;/P&gt;
&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 172px; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; primeFactors x = unfoldr findFactor x&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt;                  where&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt;                    first (a,b,c) = a&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt;                    findFactor 1 = Nothing&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;                    findFactor b = (\(_,d,p)-&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt; Just (p, d))&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt;                                   $ head $ filter ((==0).first) &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt;                                   $  map (\p -&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt; (b `mod` p, b `div` p, p))  primes&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;This function will take any number which is greater than 1 and return a list of its prime factors.&amp;nbsp; But don’t take my word for it, I wrote a quickcheck property to ensure the prime factors multiply back to the original number:&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 54px; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; HEIGHT: 2em; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; prop_factors num =  num &lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt; 1 ==&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt; num == (foldr1 (*) $ primeFactors num)&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;When&amp;nbsp;running quickcheck on this property you see the following:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quickCheck prop_factors &lt;BR&gt;OK, passed 100 tests.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9483663" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Haskell/default.aspx">Haskell</category><category domain="http://blogs.msdn.com/matt/archive/tags/Programming/default.aspx">Programming</category></item><item><title>My xUnit.net Visual Studio Code Snippets</title><link>http://blogs.msdn.com/matt/archive/2009/03/02/my-xunit-net-vs-code-snippets.aspx</link><pubDate>Tue, 03 Mar 2009 02:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9455475</guid><dc:creator>MattManela</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/matt/comments/9455475.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9455475</wfw:commentRss><description>&lt;P&gt;The &lt;A href="http://xunit.codeplex.com/" mce_href="http://xunit.codeplex.com/"&gt;xUnit .Net&lt;/A&gt; codeplex page &lt;A href="http://xunit.codeplex.com/Wiki/View.aspx?title=VsSnippets" mce_href="http://xunit.codeplex.com/Wiki/View.aspx?title=VsSnippets"&gt;lists one&lt;/A&gt; useful Visual Studio code snippet for creating a Fact.&amp;nbsp; As you &lt;A href="http://snippetdesigner.codeplex.com/" mce_href="http://snippetdesigner.codeplex.com"&gt;can tell&lt;/A&gt; I am fairly fond of code snippets so I created a few more which I use when writing xUnit.net facts. These are one line snippets that I find very convenient when writing my assertions.&lt;/P&gt;
&lt;P&gt;Below is a table which shows the shortcut you use to access the snippet and the code the snippet generates&lt;/P&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=2 width=362&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=90&gt;&lt;STRONG&gt;Shortcut&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=270&gt;&lt;STRONG&gt;Snippet&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=90&gt;ae&lt;/TD&gt;
&lt;TD vAlign=top width=270&gt;Assert.Equal($expected$,$actual$)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=90&gt;ane&lt;/TD&gt;
&lt;TD vAlign=top width=270&gt;Assert.NotEqual($expected$,$actual$)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=90&gt;an&lt;/TD&gt;
&lt;TD vAlign=top width=270&gt;Assert.Null($actual$)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=90&gt;ann&lt;/TD&gt;
&lt;TD vAlign=top width=270&gt;Assert.NotNull($actual$)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=90&gt;at&lt;/TD&gt;
&lt;TD vAlign=top width=270&gt;Assert.True($actual$)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=90&gt;af&lt;/TD&gt;
&lt;TD vAlign=top width=270&gt;Assert.False($actual$)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;I have included a &lt;A title="xUunit.net Snippets" href="http://blogs.msdn.com/matt/attachment/9455475.ashx" mce_href="http://blogs.msdn.com/matt/attachment/9455475.ashx"&gt;zip containing these snippets&lt;/A&gt;.&amp;nbsp;&amp;nbsp; Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9455475" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/matt/attachment/9455475.ashx" length="3703" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/matt/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/matt/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/matt/archive/tags/Snippets/default.aspx">Snippets</category></item><item><title>Code Assumptions</title><link>http://blogs.msdn.com/matt/archive/2009/02/01/code-assumptions.aspx</link><pubDate>Mon, 02 Feb 2009 07:13:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9389368</guid><dc:creator>MattManela</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/matt/comments/9389368.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9389368</wfw:commentRss><description>&lt;p&gt;My co-workers and I recently came across a piece of code which exposed some assumptions we had about the “correct” behavior of two functions; these assumptions turned out to be false.&amp;#160; The code dealt with determining if the IP of a&amp;#160; request coming into to a website matches a certain range of IP address. The range of IP address was defined in a config file and could look something like this:&lt;/p&gt;  &lt;p&gt;156.27.1.2, 156.*.*.*, 127.0.0.* &lt;/p&gt;  &lt;p&gt;Where the * acts as a wild card and each comma-separated IP format is matched against the incoming IP address. The code’s intended behavior is that specifying no IP address formats in the config would mean that no IP addresses would match the format.&amp;#160; We noticed that this wasn’t holding true.&amp;#160; We went to examine the code that was performing the matching (which none of us had written and sadly has NO test cases around it).&amp;#160; The code boiled down to something like this:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; DoesIPMatchIPFormat(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; incomingIpAddress, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; ipFormatsFromConfig)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt;(var ipFormat &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; ipFormatsFromConfig.Split(&lt;span style="color: #006080"&gt;','&lt;/span&gt;))&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;         Regex re = ConvertFormatIntoRegex(ipFormat);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(rs.Match(incomingIpAddress).Success) &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Where ipFormatsFromConfig is the ip range of formats shown above separated by “,” or an empty string if no formats are given. On first glance we all were confused by why this didn’t work and then as we looked into it we realized we had made some incorrect assumptions.&lt;/p&gt;

&lt;p&gt;First, we assumed that “”.Split(‘,’) would return a zero element array.&amp;#160; This assumption is false. It returns a 1 element array containing the empty string.&amp;#160; &lt;/p&gt;

&lt;p&gt;After we learned this we encountered our second assumption.&amp;#160; We assumed that a regular expression whose pattern was an empty string would not match anything. (ConvertFormatIntoRegex returned just that).&amp;#160; This assumption is also false.&amp;#160; After learning the true behavior, it makes sense why it behaves this way.&amp;#160; (A DFA with only one state must accept every input. ) &lt;/p&gt;

&lt;p&gt;Our assumptions about the “correct” behavior of functions reflect similar mistakes made by all programmers; assuming that you don’t make these kinds of assumptions is a very dangerous way to program and reinforces the importance of unit testing.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9389368" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/matt/archive/tags/testing/default.aspx">testing</category></item><item><title>Snippet Designer 1.1 Released</title><link>http://blogs.msdn.com/matt/archive/2009/01/05/snippet-designer-1-1-released.aspx</link><pubDate>Tue, 06 Jan 2009 05:11:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9284420</guid><dc:creator>MattManela</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/matt/comments/9284420.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=9284420</wfw:commentRss><description>&lt;p&gt;I just released &lt;a href="http://www.codeplex.com/SnippetDesigner" target="_blank"&gt;Snippet Designer&lt;/a&gt; 1.1.&amp;#160; This is not a major release but just some bug fixes and often requested changes to make the snippet designer more useful.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Some of the most notable changes are:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Languages Service are turned OFF by default now.&amp;#160; Since I was unable to figure out a way to host the C# and VB language services in the snippet editor without causing fake errors in projects I decided to give the users an option to turn them on or off.&amp;#160; If you are ok with the fake error you can turn this back on but since it really annoyed me I have it off.&amp;#160; I plan in a future release to provide some basic color coding outside of the language service so you can at least have color coded code.&lt;/li&gt;    &lt;li&gt;Many more aspects of the plug in are now configurable through the options menu under Snippet Designer.&amp;#160; you can now set the location of the snippet index, set preferences for which snippet languages you would like to appear in the snippet explorer.&lt;/li&gt;    &lt;li&gt;Several bug fixes to how the highlighting of replacements works and performance improvements with it also.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Hopefully these changes will make it much more useful so please download it and try it out &lt;a href="http://www.codeplex.com/SnippetDesigner" target="_blank"&gt;here&lt;/a&gt;.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;The future…&lt;/h3&gt;  &lt;p&gt;My plans for the future are still up in the air but some of the things I would like to add are:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;More bug fixes and more feature enhancements suggested by many helpful users on the &lt;a href="http://www.codeplex.com/SnippetDesigner" target="_blank"&gt;Snippet Designer&lt;/a&gt; Codeplex page.&lt;/li&gt;    &lt;li&gt;Ability to color code snippets without using the language service.&amp;#160; I have a few options here I have been looking at.&lt;/li&gt;    &lt;li&gt;Create a website to host snippets and allow you to consume and publish from Visual Studio to this website.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;I don’t know how much time I will have to commit to any of these but hopefully I will be able to get more work done on this.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Thanks!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9284420" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/matt/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/matt/archive/tags/Personal/default.aspx">Personal</category><category domain="http://blogs.msdn.com/matt/archive/tags/Snippet+Designer/default.aspx">Snippet Designer</category></item></channel></rss>