<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>voyce &#187; Visual Studio</title>
	<atom:link href="http://www.voyce.com/index.php/category/software-development/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.voyce.com</link>
	<description>Programming and debugging tidbits</description>
	<lastBuildDate>Sat, 03 Jul 2010 12:40:51 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Calling MSBuild tasks with F#</title>
		<link>http://www.voyce.com/index.php/2010/03/31/calling-msbuild-tasks-with-fsharp/</link>
		<comments>http://www.voyce.com/index.php/2010/03/31/calling-msbuild-tasks-with-fsharp/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 17:31:15 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[msbuild]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=774</guid>
		<description><![CDATA[It's easy to call MSBuild tasks directly from F#. Although possibly unnecessary.]]></description>
			<content:encoded><![CDATA[<p>The other day I was trying to understand some strange behaviour in msbuild with regard to how it resolves referenced assemblies. I thought I&#8217;d try directly invoking the tasks that are used during the build, specifically <a href="http://msdn.microsoft.com/en-us/library/9ad3f294.aspx">ResolveAssemblyReference</a>, so that I could experiment with them in F# interactive. It turned out to be pretty straightforward.<br />
<span id="more-774"></span><br />
In this example I&#8217;m attempting to resolve a reference to &#8220;class1.dll&#8221; from the GAC, taking into account the contents of the app.config (which can be used change the version resolution in MSBuild):</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;"><span style="color: #066; font-weight: bold;">#I @&quot;C:\winnt\Microsoft.NET\Framework\v2.0.50727\&quot;</span>
<span style="color: #066; font-weight: bold;">#r @&quot;Microsoft.Build.Tasks.dll&quot;</span>
<span style="color: #066; font-weight: bold;">#r @&quot;Microsoft.Build.Utilities.dll&quot;</span>
<span style="color: #066; font-weight: bold;">#r @&quot;Microsoft.Build.Framework.dll&quot;</span>
<span style="color: #066; font-weight: bold;">#r @&quot;Microsoft.Build.Engine.dll&quot;</span>
&nbsp;
<span style="color: #06c; font-weight: bold;">open</span> System
<span style="color: #06c; font-weight: bold;">open</span> Microsoft<span style="color: #000080;">.</span><span style="color: #505090;">Build</span><span style="color: #000080;">.</span><span style="color: #505090;">Framework</span>
<span style="color: #06c; font-weight: bold;">open</span> Microsoft<span style="color: #000080;">.</span><span style="color: #505090;">Build</span><span style="color: #000080;">.</span><span style="color: #505090;">Utilities</span>
<span style="color: #06c; font-weight: bold;">open</span> Microsoft<span style="color: #000080;">.</span><span style="color: #505090;">Build</span><span style="color: #000080;">.</span><span style="color: #505090;">Tasks</span>
&nbsp;
<span style="color: #06c; font-weight: bold;">do</span>
    <span style="color: #06c; font-weight: bold;">let</span> t <span style="color: #000080;">=</span> 
        ResolveAssemblyReference<span style="color: #000080;">&#40;</span>Silent <span style="color: #000080;">=</span> <span style="color: #06c; font-weight: bold;">true</span>,
            Assemblies <span style="color: #000080;">=</span> <span style="color: #000080;">&#91;</span><span style="color: #000080;">|</span> <span style="color: #06c; font-weight: bold;">upcast</span> TaskItem<span style="color: #000080;">&#40;</span> ItemSpec<span style="color: #000080;">=</span><span style="color: #008080;">&quot;class1&quot;</span> <span style="color: #000080;">&#41;</span> <span style="color: #000080;">|</span><span style="color: #000080;">&#93;</span>,
            AllowedAssemblyExtensions <span style="color: #000080;">=</span> <span style="color: #000080;">&#91;</span><span style="color: #000080;">|</span><span style="color: #008080;">&quot;.dll&quot;</span><span style="color: #000080;">|</span><span style="color: #000080;">&#93;</span>,
            AppConfigFile <span style="color: #000080;">=</span> <span style="color: #008080;">&quot;c:<span style="color: #008080; font-weight: bold;">\\</span>dev<span style="color: #008080; font-weight: bold;">\\</span>myapp<span style="color: #008080; font-weight: bold;">\\</span>myapp.exe.config&quot;</span>,
            SearchPaths <span style="color: #000080;">=</span> <span style="color: #000080;">&#91;</span><span style="color: #000080;">|</span><span style="color: #008080;">&quot;{GAC}&quot;</span><span style="color: #000080;">|</span><span style="color: #000080;">&#93;</span>
            <span style="color: #000080;">&#41;</span>
    <span style="color: #06c; font-weight: bold;">match</span> t<span style="color: #000080;">.</span><span style="color: #505090;">Execute</span><span style="color: #000080;">&#40;</span><span style="color: #000080;">&#41;</span> <span style="color: #06c; font-weight: bold;">with</span>
    <span style="color: #000080;">|</span> <span style="color: #06c; font-weight: bold;">true</span>  <span style="color: #000080;">-&gt;</span> printf <span style="color: #008080;">&quot;%A<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> t<span style="color: #000080;">.</span><span style="color: #505090;">ResolvedFiles</span>
    <span style="color: #000080;">|</span> <span style="color: #06c; font-weight: bold;">false</span> <span style="color: #000080;">-&gt;</span> printf <span style="color: #008080;">&quot;Task failed&quot;</span></pre></div></div>

<p>The output is:</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;"><span style="color: #000080;">&#91;</span><span style="color: #000080;">|</span>C<span style="color: #000080;">:</span>\WINNT\assembly\GAC_MSIL\class1\1<span style="color: #000080;">.</span>1<span style="color: #000080;">.</span>8<span style="color: #000080;">.</span>0__120bce90f68b861a\class1<span style="color: #000080;">.</span><span style="color: #505090;">dll</span><span style="color: #000080;">|</span><span style="color: #000080;">&#93;</span></pre></div></div>

<p>The code makes good use of F#&#8217;s named constructor arguments, which map to property setters on the object we&#8217;ve just created. We can also create the arrays of <a href="http://msdn.microsoft.com/en-us/library/microsoft.build.utilities.taskitem.aspx">TaskItem</a>s and strings fairly easily, although an explicit upcast is required in order to obtain the ITaskItem (F# doesn&#8217;t upcast implicitly like many object oriented languages).</p>
<p>I&#8217;ve just discovered that Jomo Fisher wrote about <a href="http://blogs.msdn.com/jomo_fisher/archive/2008/05/22/programmatically-resolve-assembly-name-to-full-path-the-same-way-msbuild-does.aspx">exactly the same thing</a> back in May 2008! He mentions using an object expression in order to provide an implementation of <code>IBuildEngine</code>, which I&#8217;m getting away with by setting the <code>Silent</code> property on the <code>ResolveAssemblyReference</code> task, meaning that it never attempts to obtain the logging context from the build engine.</p>
<p>Another gotcha here is the fact that versions of various interfaces including <code>IBuildEngine</code> and <code>ITaskItem</code> exist in both the 2.0.0.0 and 3.5.0.0 versions of the <code>Microsoft.Build.Framework</code> assembly. Be careful that you reference the correct version for the task that you&#8217;re calling. Normally it will be the 2.0 versions, in which case you&#8217;ll need to use explicit file references in your script, adding the directory to the library include path:</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;"><span style="color: #066; font-weight: bold;">#I @&quot;C:\winnt\Microsoft.NET\Framework\v2.0.50727\&quot;</span>
<span style="color: #066; font-weight: bold;">#r @&quot;Microsoft.Build.Framework.dll&quot;</span></pre></div></div>

<p>Rather than partially qualified assembly references:</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;"><span style="color: #066; font-weight: bold;">#r @&quot;Microsoft.Build.Framework&quot;</span></pre></div></div>

<p>As the latter will resolve to the latest installed version of the assembly, 3.5, which is not what you want. Look out for errors like:</p>
<blockquote><p>
System.InvalidCastException: Unable to cast object of type &#8216;Microsoft.Build.Utilities.TaskItem&#8217; to type &#8216;Microsoft.Build.Framework.ITaskItem&#8217;.
</p></blockquote>
<h2>Alternatives</h2>
<p><div id="attachment_777" class="wp-caption alignleft" style="width: 310px"><a href="http://www.voyce.com/wp-content/uploads/2010/03/msbuild_verbosity.png"><img src="http://www.voyce.com/wp-content/uploads/2010/03/msbuild_verbosity-300x174.png" alt="The Tools|Options MSBuild verbosity setting" title="msbuild_verbosity" width="300" height="174" class="size-medium wp-image-777" /></a><p class="wp-caption-text">The Tools|Options MSBuild verbosity setting</p></div>Although this was a useful experiment, I discovered that it&#8217;s often much easier to just increase the MSBuild verbosity and wade through the reams of output to find what you&#8217;re after (but then <a href="http://en.wiktionary.org/wiki/yak_shaving">the Yak will remain hairy</a>). There&#8217;s an option in Tools|Options|Projects and Solutions|Build and Run to change the output level from Silent to Diagnostic. Beware: you can easily get megabytes of text output from diagnostic mode!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2010/03/31/calling-msbuild-tasks-with-fsharp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Generating and plotting random numbers</title>
		<link>http://www.voyce.com/index.php/2009/11/24/generating-and-plotting-random-numbers/</link>
		<comments>http://www.voyce.com/index.php/2009/11/24/generating-and-plotting-random-numbers/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 23:44:55 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=562</guid>
		<description><![CDATA[An example of generating random numbers in F# and visualising their distribution using the WPF charting control.]]></description>
			<content:encoded><![CDATA[<p>For a while now I&#8217;ve been planning to write a blog post about pricing financial instruments using Monte Carlo techniques in F#. As part of this I needed to generate normally distributed random numbers, and while putting together the code to do it I realised it was interesting enough to warrant its own post.</p>
<p>I&#8217;m making use of a few F#/.NET idioms to make the process easier. For instance, sequences (.NET&#8217;s <code>IEnumerable</code>) are used as the source of uniformly distributed random numbers. Also, to verify that the resulting numbers are actually normally distributed, we can easily use existing WPF/silverlight controls to visualise the values direct from within Visual Studio, in a manner similar to <a href="http://www.voyce.com/index.php/2009/06/26/black-scholes-option-pricing-using-fsharp-and-wpf/">this previous post</a> &#8211; but without having to write the plotting code ourselves.<br />
<span id="more-562"></span></p>
<h3>Implementation</h3>
<p>So firstly, we create the random number stream:</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> rr <span style="color: #000080;">=</span> System<span style="color: #000080;">.</span><span style="color: #505090;">Random</span><span style="color: #000080;">&#40;</span>System<span style="color: #000080;">.</span><span style="color: #505090;">DateTime</span><span style="color: #000080;">.</span><span style="color: #505090;">Now</span><span style="color: #000080;">.</span><span style="color: #505090;">Minute</span><span style="color: #000080;">&#41;</span>
<span style="color: #06c; font-weight: bold;">let</span> rands <span style="color: #000080;">=</span> seq <span style="color: #000080;">&#123;</span> <span style="color: #06c; font-weight: bold;">while</span> <span style="color: #06c; font-weight: bold;">true</span> <span style="color: #06c; font-weight: bold;">do</span> <span style="color: #06c; font-weight: bold;">yield</span> rr<span style="color: #000080;">.</span><span style="color: #505090;">NextDouble</span><span style="color: #000080;">&#40;</span><span style="color: #000080;">&#41;</span> <span style="color: #000080;">&#125;</span></pre></div></div>

<p>As you can see <code>rands</code> is an infinite sequence. As such, you should be wary of the &#8220;eager&#8221; functions from the Seq module that attempt to consume the entire sequence at once, they&#8217;ll obviously cause a problem here. Also notice that I&#8217;ve picked a somewhat dubious seed for the random number generator, as this is only for demonstration purposes.</p>
<p>In order to obtain normally distributed random numbers I&#8217;m using the <a href="http://en.wikipedia.org/wiki/Box–Muller_transform">Box-Muller</a> transform. I started off with an implementation transcribed from VBA (from <a href="http://www.amazon.com/gp/product/0470319585?ie=UTF8&#038;tag=wwwvoycecom-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0470319585">Wilmott</a><img src="http://www.assoc-amazon.com/e/ir?t=wwwvoycecom-20&#038;l=as2&#038;o=1&#038;a=0470319585" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> et al) &#8211; yes, yes, I know &#8211; but of course this used mutable references. Not nice. So I reworked it a little to use <code>Seq.pick</code>, which takes items from the sequence while a predicate returns <code>None</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> boxMuller <span style="color: #06c; font-weight: bold;">_</span> <span style="color: #000080;">=</span>
    <span style="color: #06c; font-weight: bold;">let</span> <span style="color: #000080;">&#40;</span>x,dist<span style="color: #000080;">&#41;</span> <span style="color: #000080;">=</span> 
        rands
        <span style="color: #000080;">|&gt;</span> Seq<span style="color: #000080;">.</span><span style="color: #505090;">pick</span> <span style="color: #000080;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> x <span style="color: #000080;">-&gt;</span>
            <span style="color: #06c; font-weight: bold;">let</span> x <span style="color: #000080;">=</span> <span style="color: #c6c;">2.0</span> <span style="color: #000080;">*</span> x <span style="color: #000080;">-</span> <span style="color: #c6c;">1.0</span>
            <span style="color: #06c; font-weight: bold;">let</span> y <span style="color: #000080;">=</span> <span style="color: #c6c;">2.0</span> <span style="color: #000080;">*</span> <span style="color: #000080;">&#40;</span><span style="color: #000080;">&#40;</span>Seq<span style="color: #000080;">.</span><span style="color: #505090;">take</span> <span style="color: #c6c;">1</span> rands<span style="color: #000080;">&#41;</span> <span style="color: #000080;">|&gt;</span> Seq<span style="color: #000080;">.</span><span style="color: #505090;">hd</span><span style="color: #000080;">&#41;</span> <span style="color: #000080;">-</span> <span style="color: #c6c;">1.0</span>
            <span style="color: #06c; font-weight: bold;">match</span> <span style="color: #000080;">&#40;</span>x <span style="color: #000080;">*</span> x <span style="color: #000080;">+</span> y <span style="color: #000080;">*</span> y<span style="color: #000080;">&#41;</span> <span style="color: #06c; font-weight: bold;">with</span>
                <span style="color: #000080;">|</span> dist <span style="color: #06c; font-weight: bold;">when</span> dist <span style="color: #000080;">&lt;</span> <span style="color: #c6c;">1.0</span> <span style="color: #000080;">-&gt;</span> Some <span style="color: #000080;">&#40;</span>x,dist<span style="color: #000080;">&#41;</span>
                <span style="color: #000080;">|</span> dist <span style="color: #000080;">-&gt;</span> None
            <span style="color: #000080;">&#41;</span> 
    x <span style="color: #000080;">*</span> Math<span style="color: #000080;">.</span><span style="color: #505090;">Sqrt</span><span style="color: #000080;">&#40;</span><span style="color: #000080;">-</span><span style="color: #c6c;">2.0</span> <span style="color: #000080;">*</span> Math<span style="color: #000080;">.</span><span style="color: #505090;">Log</span><span style="color: #000080;">&#40;</span>dist<span style="color: #000080;">&#41;</span> <span style="color: #000080;">/</span> dist<span style="color: #000080;">&#41;</span></pre></div></div>

<p>It&#8217;s not particularly efficient as we&#8217;re consuming two uniform numbers to generate one normal one &#8211; hence the additional Seq.take within the pick. Of course we could change the function to return the 2 generated numbers as an extra element in the tuple.</p>
<p>Next, let&#8217;s generate some numbers, and get them in a suitable form to display:</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> makeData <span style="color: #06c; font-weight: bold;">_</span> <span style="color: #000080;">=</span>
    Seq<span style="color: #000080;">.</span><span style="color: #505090;">init</span> <span style="color: #c6c;">100000</span> boxMuller
    <span style="color: #000080;">|&gt;</span> Seq<span style="color: #000080;">.</span><span style="color: #505090;">countBy</span> <span style="color: #000080;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> d <span style="color: #000080;">-&gt;</span> 
        <span style="color: #06c; font-weight: bold;">let</span> d <span style="color: #000080;">=</span> decimal d
        Math<span style="color: #000080;">.</span><span style="color: #505090;">Round</span><span style="color: #000080;">&#40;</span>d, <span style="color: #c6c;">1</span><span style="color: #000080;">&#41;</span><span style="color: #000080;">&#41;</span>
    <span style="color: #000080;">|&gt;</span> Seq<span style="color: #000080;">.</span><span style="color: #505090;">sortBy</span> fst</pre></div></div>

<p>We initialise a sequence with an arbitrary amount of numbers (100000, enough to get a good distribution, hopefully), then use <code>Seq.countBy</code> to do a naive grouping that allows us to see how the numbers are distributed, i.e. counting how many numbers fit in each 0.10 bucket. We then sort the output by bucket. </p>
<h3>Visualisation</h3>
<p>Now we can display what we&#8217;ve got. We can create a simple WPF object-model using imperative code, including the very useful chart control from the WpfToolkit. The chart control enables us to add a series and set our <code>seq&lt;decimal * float&gt;</code> directly as the series ItemsSource, which is the standard way to specify the items for a collection control. If you specify the tuple <code>Item1</code> and <code>Item2</code> properties for the bindings, WPF will be able to access the data from each element, and that&#8217;s all you need.</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;">    <span style="color: #06c; font-weight: bold;">let</span> series <span style="color: #000080;">=</span> 
        ColumnSeries<span style="color: #000080;">&#40;</span>
            IndependentValueBinding <span style="color: #000080;">=</span> Data<span style="color: #000080;">.</span><span style="color: #505090;">Binding</span><span style="color: #000080;">&#40;</span><span style="color: #008080;">&quot;Item1&quot;</span><span style="color: #000080;">&#41;</span>,
            DependentValueBinding <span style="color: #000080;">=</span> Data<span style="color: #000080;">.</span><span style="color: #505090;">Binding</span><span style="color: #000080;">&#40;</span><span style="color: #008080;">&quot;Item2&quot;</span><span style="color: #000080;">&#41;</span>,
            ItemsSource <span style="color: #000080;">=</span> makeData <span style="color: #000080;">&#40;</span><span style="color: #000080;">&#41;</span><span style="color: #000080;">&#41;</span>
    <span style="color: #06c; font-weight: bold;">let</span> chart <span style="color: #000080;">=</span> Chart<span style="color: #000080;">&#40;</span><span style="color: #000080;">&#41;</span>
    chart<span style="color: #000080;">.</span><span style="color: #505090;">Series</span><span style="color: #000080;">.</span><span style="color: #505090;">Add</span> series
    Window<span style="color: #000080;">&#40;</span>
        Name<span style="color: #000080;">=</span><span style="color: #008080;">&quot;Plot&quot;</span>,
        Title<span style="color: #000080;">=</span><span style="color: #008080;">&quot;Normally distributed random numbers&quot;</span>,
        Width<span style="color: #000080;">=</span><span style="color: #c6c;">900.0</span>,
        Height<span style="color: #000080;">=</span><span style="color: #c6c;">700.0</span>,
        Content<span style="color: #000080;">=</span>chart,
        Visibility<span style="color: #000080;">=</span>Visibility<span style="color: #000080;">.</span><span style="color: #505090;">Visible</span><span style="color: #000080;">&#41;</span></pre></div></div>

<p>Here&#8217;s the resulting output:<br />
<img src="http://www.voyce.com/wp-content/uploads/2009/11/dist-300x233.png" alt="dist" title="dist" width="300" height="233" class="alignleft size-medium wp-image-576" />As I&#8217;ve mentioned before, this is a fantastically immediate way of doing numerical development in Visual Studio. You can enter all of this code directly into F# interactive within VS, iterate, and quickly see the effect that your changes have. It&#8217;s just as interactive as using the graph features in Excel, and the resulting code is much more easily reusable.</p>
<p><span style="visibility:hidden"> XD5RRV3XDNHN </span><br />
<script type="text/javascript" src="http://www.assoc-amazon.com/s/link-enhancer?tag=wwwvoycecom-20&#038;o=1">
</script><br />
<noscript><br />
    <img src="http://www.assoc-amazon.com/s/noscript?tag=wwwvoycecom-20" alt="" /><br />
</noscript></p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2009/11/24/generating-and-plotting-random-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pinned DataTips in Visual Studio 2010 Beta 2</title>
		<link>http://www.voyce.com/index.php/2009/11/02/pinned-datatips-in-visual-studio-2010-beta-2/</link>
		<comments>http://www.voyce.com/index.php/2009/11/02/pinned-datatips-in-visual-studio-2010-beta-2/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 23:59:38 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=511</guid>
		<description><![CDATA[I&#8217;ve just noticed a nice little feature in Visual Studio 2010 Beta 2: pinned DataTips. Values displayed in the debugger as you hover over a variable can now be pinned in place and remain aligned with the source. They can even have annotations added&#8230; Tasty!
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.voyce.com/wp-content/uploads/2009/11/vs2010_pinned_datatips.png"><img src="http://www.voyce.com/wp-content/uploads/2009/11/vs2010_pinned_datatips-300x42.png" alt="vs2010_pinned_datatips" title="vs2010_pinned_datatips" width="300" height="42" class="alignleft size-medium wp-image-512" /></a>I&#8217;ve just noticed a nice little feature in Visual Studio 2010 Beta 2: pinned DataTips. Values displayed in the debugger as you hover over a variable can now be pinned in place and remain aligned with the source. They can even have annotations added&#8230; Tasty!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2009/11/02/pinned-datatips-in-visual-studio-2010-beta-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparing lambdas in C++ and F#</title>
		<link>http://www.voyce.com/index.php/2009/10/23/comparing-lambdas-in-c-and-f/</link>
		<comments>http://www.voyce.com/index.php/2009/10/23/comparing-lambdas-in-c-and-f/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 19:51:27 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=461</guid>
		<description><![CDATA[Lambdas in C++ and F#: compare and contrast.]]></description>
			<content:encoded><![CDATA[<p>The other day someone pointed me to the new <a href="http://msdn.microsoft.com/en-us/library/dd293608(VS.100).aspx">MSDN article on C++ lambdas</a> in Visual Studio 2010. Interesting. C++0x has been a long time coming, but in my opinion anything that makes C++ usable at a higher level of abstraction is a good thing. There&#8217;s nothing wrong with a little abstraction, as long as you can get to the fundamentals if you need to. Otherwise you wouldn&#8217;t be using C++, would you?</p>
<p>But one of the things I couldn&#8217;t get over from that article is the verbosity. I&#8217;ve just got too used to the succintness of F#. I know this is only example code, so it&#8217;s intended to demonstrate usage, but the whole point of lambdas is to reduce boilerplate and make the intent of your code more obvious. So, let&#8217;s compare the C++0x implementation with the F# version.<br />
<span id="more-461"></span><br />
Here&#8217;s the C++ version, with the comments removed (including the &#8220;increment the counter&#8221; comment from the original article&#8230; Oh, please):</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;algorithm&gt;</span>
<span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #339900;">#include &lt;vector&gt;</span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   vector<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> v<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> <span style="color: #0000dd;">10</span><span style="color: #008080;">;</span> <span style="color: #000040;">++</span>i<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      v.<span style="color: #007788;">push_back</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #0000ff;">int</span> evenCount <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
   for_each<span style="color: #008000;">&#40;</span>v.<span style="color: #007788;">begin</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, v.<span style="color: #007788;">end</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, <span style="color: #008000;">&#91;</span><span style="color: #000040;">&amp;</span>evenCount<span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> n<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> n<span style="color: #008080;">;</span>
&nbsp;
      <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>n <span style="color: #000040;">%</span> <span style="color: #0000dd;">2</span> <span style="color: #000080;">==</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; is even &quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
&nbsp;
         evenCount<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
      <span style="color: #008000;">&#125;</span>
      <span style="color: #0000ff;">else</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; is odd &quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
   <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;There are &quot;</span> <span style="color: #000080;">&lt;&lt;</span> evenCount <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; even numbers in the vector.&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>As well as the verbosity, notice the weird syntax used to capture the <code>evenCount</code> variable.</p>
<p>Without further ado, here&#8217;s an F# version &#8211; not a definitive one necessarily &#8211; that returns the value rather than doing nasty side-effecting IO by printing it out to the screen:</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;">seq <span style="color: #000080;">&#123;</span> 0<span style="color: #000080;">..</span>9 <span style="color: #000080;">&#125;</span> <span style="color: #000080;">|&gt;</span> Seq<span style="color: #000080;">.</span><span style="color: #505090;">filter</span> <span style="color: #000080;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> e <span style="color: #000080;">-&gt;</span> e <span style="color: #000080;">%</span> <span style="color: #c6c;">2</span> <span style="color: #000080;">=</span> <span style="color: #c6c;">0</span><span style="color: #000080;">&#41;</span> <span style="color: #000080;">|&gt;</span> Seq<span style="color: #000080;">.</span><span style="color: #505090;">length</span></pre></div></div>

<p>If you want to make it a bit more like the original code, you can add back the  <code>printf</code>s, and lay it out a bit more logically:</p>

<div class="wp_syntax"><div class="code"><pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> count <span style="color: #000080;">=</span>
    seq <span style="color: #000080;">&#123;</span> 0<span style="color: #000080;">..</span>9 <span style="color: #000080;">&#125;</span>
    <span style="color: #000080;">|&gt;</span> Seq<span style="color: #000080;">.</span><span style="color: #505090;">fold</span> <span style="color: #000080;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> count e <span style="color: #000080;">-&gt;</span>
        <span style="color: #06c; font-weight: bold;">match</span> e <span style="color: #000080;">%</span> <span style="color: #c6c;">2</span> <span style="color: #06c; font-weight: bold;">with</span>
        <span style="color: #000080;">|</span> <span style="color: #c6c;">0</span> <span style="color: #000080;">-&gt;</span> printf <span style="color: #008080;">&quot;%d is even<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> e<span style="color: #000080;">;</span> count <span style="color: #000080;">+</span> <span style="color: #c6c;">1</span>
        <span style="color: #000080;">|</span> <span style="color: #06c; font-weight: bold;">_</span> <span style="color: #000080;">-&gt;</span> printf <span style="color: #008080;">&quot;%d is odd<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> e<span style="color: #000080;">;</span> count<span style="color: #000080;">&#41;</span> <span style="color: #c6c;">0</span>
printf <span style="color: #008080;">&quot;There are %d even numbers&quot;</span> count</pre></div></div>

<p>I guess the comparison isn&#8217;t really a fair one. The fundamental difference between C++ and F# lambdas is that they&#8217;re an afterthought in C++. In F# they&#8217;re a core, fundamental part of the language, and have been from day one. Functions are created, passed and bound as a matter of course.</p>
<p>The C++ heritage becomes obvious when you look at the finer points of its lambda syntax. For instance, having to specify whether to capture variables by reference or by value, in the &#8220;capture clause&#8221; or lambda-introducer. This is the type of distinction that both .NET programmers and functional programmers are not used to having to make.</p>
<h2>Other nice F# features</h2>
<p>Although not directly related to lambdas, there are some other F# language features that help make code more concise and understandable:</p>
<ol>
<li>
<h3>Sequence expressions</h3>
<p>F# has an extremely terse syntax for generating and manipulating sequences &#8211; collections that implement IEnumerable. This means you can easily generate collections and iterate over them, without the potential for off-by-one errors, the scourge of <code>for</code loops.
</li>
<li>
<h3>Fewer brackets</h3>
<p>In F#, whitespace is significant. It takes some time to get used to, but it ultimately results in cleaner code. It's been interesting to see the use of <code>#light</code> gradually become more and more standard as F# has neared an official release. Now it's implicit in all code. Try it, you'll like it.
</li>
<li>
<h3>Type-safe printf</h3>
<p>For some reason I always preferred the C style <code>printf</code> string formatting to C++s <code>cout</code> stream based version. There's something more readable about printf, but it suffers from a terrible lack of compile time type safety. This can be disastrous if, for instance, you happen to wrongly type the insert in an error message or other code path that's rarely hit. The one time you need it, the error handling itself generates an error! Ouch.</p>
<p><a href="http://72.47.193.211/wp-content/uploads/2009/10/printf_tooltip.png"><img src="http://www.voyce.com/wp-content/uploads/2009/10/printf_tooltip-150x64.png" alt="printf_tooltip" title="printf_tooltip" width="150" height="64" class="alignleft size-thumbnail wp-image-474" /></a><br />
Luckily, F# combines the best of both worlds with a compile-time type-safe printf! At first glance this can seem like some kind of magic to C++ developers (well, it did for me).
</li>
</ol>
<p>Now that F# is officially "out there" and available as a first class citizen in Visual Studio 2010, you should really take a look. I'm increasingly convinced that the cost of using C++, not necessarily the <a href="http://www.rachelslabnotes.com/2009/10/the-hidden-cost-of-c/">raw, low-level cost</a>, but the business costs involved with writing performant, maintainable, manageable code in C++, is getting too much to bear. But that's probably the basis for another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2009/10/23/comparing-lambdas-in-c-and-f/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FormatException in WPF DataBinding</title>
		<link>http://www.voyce.com/index.php/2009/10/14/formatexception-in-wpf-databinding/</link>
		<comments>http://www.voyce.com/index.php/2009/10/14/formatexception-in-wpf-databinding/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 11:09:26 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[DataBinding]]></category>
		<category><![CDATA[FormatException]]></category>
		<category><![CDATA[visualstudio]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=446</guid>
		<description><![CDATA[A FormatException is generated by the WPF DataBinding diagnostics if the original exception text contains curly brackets.]]></description>
			<content:encoded><![CDATA[<p>While working on some F#/C# WPF code the other day, I kept hitting a fatal FormatException when running under the debugger. Annoyingly, the app would quit with:<br />
<code><br />
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll<br />
Additional information: Input string was not in a correct format.<br />
</code><br />
But it worked fine when started from Expression Blend, or when run using Start Without Debugging in Visual Studio. Let&#8217;s take a closer look&#8230;<br />
<span id="more-446"></span><br />
Looking at the output window, there seemed to be an intial exception before the FormatException, and from the stack trace the second one seemed to be generated as WPF was trying to log the first one:</p>
<p><a href="http://72.47.193.211/wp-content/uploads/2009/10/callstack.png"><img src="http://www.voyce.com/wp-content/uploads/2009/10/callstack-300x113.png" alt="callstack" title="callstack" width="300" height="113" class="size-medium wp-image-449" /></a></p>
<p>I had a look at the text of the first exception, and from that it was obvious:</p>
<p><code><br />
Unable to cast COM object of type 'System.__ComObject' to interface type 'IWhatever'. This operation failed because the QueryInterface call on the COM component for the interface with IID '<b>{</b>CAD939D0-5E5D-11D7-AA0B-0002B33FE9DX<b>}</b>' failed due to the following error: Bad variable type. (Exception from HRESULT: 0x80020008 (DISP_E_BADVARTYPE)).<br />
</code></p>
<p>The message contains curly brackets around the IID, and they&#8217;re being intrepreted as insertion points by a call to String.Format!</p>
<h2>Workaround</h2>
<p>So that explained why it only happens in debugger runs; as <a href="http://blogs.msdn.com/mikehillberg/archive/2006/09/14/WpfTraceSources.aspx">this post</a> helpfully points out the WPF databinding is enabled by default in that case. To workaround it, you can disable logging programmatically or using the App.config file to only display <code>Critical</code> output. So if your app is named foo.exe, create a file foo.exe.config that contains:</p>
<div style="font-family: Consolas; font-size: 10pt; color: black; background: white;">
<pre style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">configuration</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">&nbsp; &lt;</span><span style="color: #a31515;">system.diagnostics</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">&nbsp; &nbsp; &lt;</span><span style="color: #a31515;">sources</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">&nbsp; &nbsp; &nbsp; &lt;</span><span style="color: #a31515;">source</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">System.Windows.Data</span>"<span style="color: blue;"> </span><span style="color: red;">switchName</span><span style="color: blue;">=</span>"<span style="color: blue;">SourceSwitch</span>"<span style="color: blue;">/&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">&nbsp; &nbsp; &lt;/</span><span style="color: #a31515;">sources</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;">&nbsp;</pre>
<pre style="margin: 0px;"><span style="color: blue;">&nbsp; &nbsp; &lt;</span><span style="color: #a31515;">switches</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">&nbsp; &nbsp; &nbsp; &lt;</span><span style="color: #a31515;">add</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">SourceSwitch</span>"<span style="color: blue;"> </span><span style="color: red;">value</span><span style="color: blue;">=</span>"<span style="color: blue;">Critical</span>"<span style="color: blue;"> /&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">&nbsp; &nbsp; &lt;/</span><span style="color: #a31515;">switches</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;">&nbsp;</pre>
<pre style="margin: 0px;"><span style="color: blue;">&nbsp; &lt;/</span><span style="color: #a31515;">system.diagnostics</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">configuration</span><span style="color: blue;">&gt;</span></pre>
</div>
<h2>Fix&#8230;?</h2>
<p>Hopefully there&#8217;ll be a fix for this at some point soon, as disabling the logging is a pretty large hammer to crack this small nut.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2009/10/14/formatexception-in-wpf-databinding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Windows SDK breaks F# Visual Studio integration</title>
		<link>http://www.voyce.com/index.php/2009/04/14/windows-sdk-breaks-fsharp-integration/</link>
		<comments>http://www.voyce.com/index.php/2009/04/14/windows-sdk-breaks-fsharp-integration/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 09:00:22 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[intellisense]]></category>
		<category><![CDATA[winsdk]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=116</guid>
		<description><![CDATA[Beware! If you install the Windows SDK &#8211; perhaps to get access to the interesting looking WPF performance tools &#8211; you&#8217;ll find that it hoses your F# Visual Studio integration. I found that it causes intellisense tooltips to stop appearing, and the integrated F# interactive to crash Visual Studio. Both of these issues are a [...]]]></description>
			<content:encoded><![CDATA[<p>Beware! If you install the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&#038;displaylang=en">Windows SDK</a> &#8211; perhaps to get access to the interesting looking <a href="http://blogs.msdn.com/jgoldb/archive/2008/09/25/updated-wpfperf-performance-profiling-tools-for-wpf.aspx">WPF performance tools</a> &#8211; you&#8217;ll find that it hoses your F# Visual Studio integration. I found that it causes intellisense tooltips to stop appearing, and the integrated F# interactive to crash Visual Studio. Both of these issues are a real pain; especially the inability to see the inferred types &#8220;live&#8221;, which is pretty much essential for F# development &#8211; where the focus is on compile time correctness.</p>
<p>I remembered seeing a <a href="http://blogs.msdn.com/windowssdk/comments/7850578.aspx">post on that Windows SDK blog</a> that I&#8217;d come across relating to a similar issue with the XAML editor (I&#8217;ve been doing some work with WPF recently, more on that in a later post) so thought I&#8217;d try the steps they recommend, in short, re-registering TextMgrP.dll:</p>
<p><code>regsvr32 "%CommonProgramFiles%\Microsoft Shared\MSEnv\TextMgrP.dll"</code></p>
<p>&#8230;and all my problems went away. Hope you find this useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2009/04/14/windows-sdk-breaks-fsharp-integration/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Visual Studio Toggle Brackets Macro</title>
		<link>http://www.voyce.com/index.php/2009/02/09/visual-studio-toggle-brackets-macro/</link>
		<comments>http://www.voyce.com/index.php/2009/02/09/visual-studio-toggle-brackets-macro/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 12:35:28 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[brackets]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[parentheses]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=85</guid>
		<description><![CDATA[After using a F# heavily for a while, I often found myself wanting to add brackets (or rather, parentheses) around some text. This is normally when adding a type specification to an argument in order to be able to use dot notation, e.g. going from:

let typeName t = t.Name

which causes &#8220;error FS0072: Lookup on object [...]]]></description>
			<content:encoded><![CDATA[<p>After using a F# heavily for a while, I often found myself wanting to add brackets (or rather, parentheses) around some text. This is normally when adding a type specification to an argument in order to be able to use dot notation, e.g. going from:</p>
<div style="font-family: Lucida Sans Typewriter; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">let</span> typeName t = t.Name</p>
</div>
<p>which causes &#8220;error FS0072: Lookup on object of indeterminate type based on information prior to this program point&#8221;, to the correct:</p>
<div style="font-family: Lucida Sans Typewriter; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">let</span> typeName <strong>(t:Type)</strong> = t.Name</p>
</div>
<p>(These are obviously simplistic examples!)</p>
<p>So I broke out the Visual Studio macro editor for the first time in a while, and put together something to toggle brackets around the currently selected text. It&#8217;s naive, but, combined with Shift+Alt+Left Arrow to select the previous word, it&#8217;s effective:</p>
<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">Public</span> <span style="color: blue;">Sub</span> AddBrackets()</p>
<p style="margin: 0px;"><span style="color: blue;"> Dim</span> s <span style="color: blue;">As</span> <span style="color: blue;">Object</span> = DTE.ActiveWindow.Selection()</p>
<p style="margin: 0px;"><span style="color: blue;"> If</span> s.Text.StartsWith(<span style="color: #a31515;">&#8220;(&#8221;</span>) <span style="color: blue;">And</span> s.Text.EndsWith(<span style="color: #a31515;">&#8220;)&#8221;</span>) <span style="color: blue;">Then</span></p>
<p style="margin: 0px;">s.Text = s.Text.Substring(1, s.Text.Length &#8211; 2)</p>
<p style="margin: 0px;"><span style="color: blue;"> Else</span></p>
<p style="margin: 0px;">s.Text = <span style="color: #a31515;">&#8220;(&#8221;</span> + s.Text + <span style="color: #a31515;">&#8220;)&#8221;</span></p>
<p style="margin: 0px;"><span style="color: blue;"> End</span> <span style="color: blue;">If</span></p>
<p style="margin: 0px;"><span style="color: blue;">End</span> <span style="color: blue;">Sub</span></p>
</div>
<p>Copy this text into a module within your macro project, and assign a suitable keystroke using Tools|Customize|Keyboard.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2009/02/09/visual-studio-toggle-brackets-macro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(My) Essential Visual Studio add-ins</title>
		<link>http://www.voyce.com/index.php/2007/08/15/my-essential-visual-studio-add-ins/</link>
		<comments>http://www.voyce.com/index.php/2007/08/15/my-essential-visual-studio-add-ins/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 22:42:29 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=18</guid>
		<description><![CDATA[Thought you might like to know about a few Visual Studio tools and add-ins that I regularly use, and find very useful:

Copy as HTML

Fantastic little tool that lets you copy formatted text from the VS editor as HTML fragments. You can’t beat syntax highlighting to ease code readability, and this plug-in is great for adding [...]]]></description>
			<content:encoded><![CDATA[<p class="postentry">Thought you might like to know about a few Visual Studio tools and add-ins that I regularly use, and find very useful:</p>
<ul>
<li>Copy as HTML</li>
</ul>
<p style="margin-left: 40px">Fantastic little tool that lets you copy formatted text from the VS editor as HTML fragments. You can’t beat syntax highlighting to ease code readability, and this plug-in is great for adding code to blog entries, etc. Written by Colin Coller and available from <a href="http://www.jtleigh.com/CopySourceAsHtml">http://www.jtleigh.com/CopySourceAsHtml</a>.</p>
<ul>
<li>VC++ Code Snippets</li>
</ul>
<p style="margin-left: 40px">C++ has missed out on a few of the productivity boosters available for the managed languages in VS2005; one of the most annoying ones is code snippets &#8211; mainly because it’s omission seems so arbitrary, it’s not as if it needs reflection or some other CLR specific features. Anyway, it turns out that it is available, but as part of the “PowerToys” package, available from <a href="http://msdn2.microsoft.com/en-us/vstudio/bb190754.aspx">http://msdn2.microsoft.com/en-us/vstudio/bb190754.aspx</a>. As well as being good for day-to-day productivity, code snippets are also a really powerful demo tool, allowing you to give the appearance that you’re writing code “live” when it’s really just glorified copy and pasting.</p>
<ul>
<li>XPathMania</li>
</ul>
<p style="margin-left: 40px">I do quite a lot of work with XML, and this little utility proves very useful. I used to use XMLSpy, but it was really too overblown when all I wanted to do was use it’s ability to quickly run an XPath query and see what it returns. This add-in allows me to do that directly in Visual Studio… lovely! It was put together by Don Demsak, and is available from <a href="http://donxml.com/allthingstechie/archive/2006/07/07/2792.aspx">http://donxml.com/allthingstechie/archive/2006/07/07/2792.aspx</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2007/08/15/my-essential-visual-studio-add-ins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boost causes Visual Studio 2005 to crash</title>
		<link>http://www.voyce.com/index.php/2007/03/28/boost-causes-visual-studio-2005-to-crash/</link>
		<comments>http://www.voyce.com/index.php/2007/03/28/boost-causes-visual-studio-2005-to-crash/#comments</comments>
		<pubDate>Wed, 28 Mar 2007 22:45:35 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=10</guid>
		<description><![CDATA[After experiencing some nasty crashes in Visual Studio 2005 recently, I’ve discovered that the long, heavily templated type names in version 1.33.1 of the boost headers don’t play well with the internal buffer sizes in various parts of Visual Studio (including SP1). This results in crashes while generating Intellisence data (feacp.dll) and in the debugger [...]]]></description>
			<content:encoded><![CDATA[<p>After experiencing some nasty crashes in Visual Studio 2005 recently, I’ve discovered that the long, heavily templated type names in version 1.33.1 of the boost headers don’t play well with the internal buffer sizes in various parts of Visual Studio (including SP1). This results in crashes while generating Intellisence data (feacp.dll) and in the debugger itself. It’s fairly easy to reproduce, essentially all you have to do is #include <a href="http://www.boost.org/libs/graph/doc/adjacency_list.html">adjacency_list</a> from the graph part of the boost library. I’ve raised a support incident with Microsoft, so we’ll see what they have to say about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2007/03/28/boost-causes-visual-studio-2005-to-crash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symbol loading in Visual Studio 2005 and 2008</title>
		<link>http://www.voyce.com/index.php/2007/02/16/symbol-loading-in-visual-studio-2005-and-2008/</link>
		<comments>http://www.voyce.com/index.php/2007/02/16/symbol-loading-in-visual-studio-2005-and-2008/#comments</comments>
		<pubDate>Fri, 16 Feb 2007 22:35:44 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=7</guid>
		<description><![CDATA[I don’t know if I’ve been spoilt by the lazy symbol loading in WinDbg, but it seems incredibly slow to start up unmanaged processes under Visual Studio 2005. It spends a huge amount of time attempting to load symbols for every single DLL that gets loaded. As far as I can tell it doesn’t do [...]]]></description>
			<content:encoded><![CDATA[<p class="postentry">I don’t know if I’ve been spoilt by the lazy symbol loading in WinDbg, but it seems incredibly slow to start up unmanaged processes under Visual Studio 2005. It spends a huge amount of time attempting to load symbols for every single DLL that gets loaded. As far as I can tell it doesn’t do any caching or recording of the fact that symbols aren’t available for specific binaries. It just blindly tries every time.</p>
<p>Anyway, I’ve found a way to improve matters slightly. It turns out you can use the symbol server DLL &#8211; symsrv.dll &#8211; from the most recent version of WinDbg (6.6.3.5 at the last check) to replace the version that ships with Visual Studio 2005.</p>
<p>One of the additional features that the WinDbg version offers in the exclusions list. You can use this to avoid loading symbols for anything other than the DLL under test. Simply copy the DLL into C:\Program Files\Microsoft Visual Studio 8\Common7\IDE and create a symsrv.ini file with the following contents:</p>
<p>[exclusions]<br />
*.*</p>
<p>This should make your symbol loading fly… yet it still loads the symbols required to debug as normal. Magic!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2007/02/16/symbol-loading-in-visual-studio-2005-and-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
